Get some data into the database

This commit is contained in:
Arturo Filastò
2018-02-13 18:11:22 +02:00
parent d3d3ce9d78
commit e7ee54436e
6 changed files with 137 additions and 65 deletions
+26 -4
View File
@@ -1,10 +1,14 @@
package run
import (
"time"
"github.com/alecthomas/kingpin"
"github.com/apex/log"
"github.com/openobservatory/gooni/internal/cli/root"
"github.com/openobservatory/gooni/internal/database"
"github.com/openobservatory/gooni/internal/util"
"github.com/openobservatory/gooni/nettests"
"github.com/openobservatory/gooni/nettests/groups"
)
@@ -15,15 +19,33 @@ func init() {
cmd.Action(func(_ *kingpin.ParseContext) error {
util.Log("Starting %s", *nettestGroup)
config, ooni, err := root.Init()
_, ctx, err := root.Init()
if err != nil {
log.Errorf("%s", err)
return err
}
log.Infof("%s", config)
log.Infof("%s", ooni)
group := groups.NettestGroups[*nettestGroup]
log.Debugf("Running test group %s", group.Label)
groups.Run(*nettestGroup, ooni)
result, err := database.CreateResult(ctx.DB, database.Result{
Name: *nettestGroup,
StartTime: time.Now().UTC(), // XXX get this from MK
})
if err != nil {
log.Errorf("%s", err)
return err
}
for _, nt := range group.Nettests {
ctl := nettests.NewController(ctx)
nt.Run(ctl)
// XXX
// 1. Generate the summary
// 2. Link the measurement to the Result (this should probably happen in
// the nettest class)
// 3. Update the summary of the result and the other metadata in the db
}
result.Update(ctx.DB)
return nil
})
}