Start adding support for writing measurements to disk
This commit is contained in:
@@ -37,15 +37,15 @@ func init() {
|
||||
}
|
||||
|
||||
Init = func() (*ooni.Config, *ooni.Context, error) {
|
||||
var c *ooni.Config
|
||||
var config *ooni.Config
|
||||
var err error
|
||||
|
||||
if *configPath != "" {
|
||||
log.Debugf("Reading config file from %s", *configPath)
|
||||
c, err = ooni.ReadConfig(*configPath)
|
||||
config, err = ooni.ReadConfig(*configPath)
|
||||
} else {
|
||||
log.Debug("Reading default config file")
|
||||
c, err = ooni.ReadDefaultConfigPaths()
|
||||
config, err = ooni.ReadDefaultConfigPaths()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -62,9 +62,13 @@ func init() {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
o := ooni.New(c, db)
|
||||
o.Init()
|
||||
return c, o, nil
|
||||
ctx := ooni.New(config, db)
|
||||
err = ctx.Init()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return config, ctx, nil
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package run
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin"
|
||||
@@ -37,7 +39,11 @@ func init() {
|
||||
|
||||
for _, nt := range group.Nettests {
|
||||
log.Debugf("Running test %T", nt)
|
||||
ctl := nettests.NewController(ctx, result)
|
||||
msmtPath := filepath.Join(ctx.TempDir,
|
||||
fmt.Sprintf("msmt-%s-%T.jsonl", nt,
|
||||
time.Now().UTC().Format(time.RFC3339Nano)))
|
||||
|
||||
ctl := nettests.NewController(ctx, result, msmtPath)
|
||||
if err := nt.Run(ctl); err != nil {
|
||||
log.WithError(err).Errorf("Failed to run %s", group.Label)
|
||||
return err
|
||||
@@ -47,6 +53,7 @@ func init() {
|
||||
// 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
|
||||
// 4. Move the msmtPath into the final location ~/.ooni/msmts/
|
||||
}
|
||||
// result.Update(ctx.DB)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user