Get NDT test to run via gooni
This commit is contained in:
parent
7cf5bd2718
commit
d3d3ce9d78
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
vendor/
|
vendor/
|
||||||
/ooni
|
/ooni
|
||||||
|
*.njson
|
||||||
|
|
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -86,7 +86,7 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/measurement-kit/go-measurement-kit"
|
name = "github.com/measurement-kit/go-measurement-kit"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "93d8ecd6537d99a83845a9e6928dfd27b665ad6a"
|
revision = "bc9d9a377259df26dd4d86c9dcc0953c92dde23b"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -174,6 +174,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "348ea586d927a4a6ce2aef27d7734ba88a12917b9b074ae2d41b229731c9bc33"
|
inputs-digest = "5405ce55dbd69df4847de599c4e30d7540f208db389b67f2c9789ef6c17351d0"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/openobservatory/gooni/internal/cli/root"
|
"github.com/openobservatory/gooni/internal/cli/root"
|
||||||
"github.com/openobservatory/gooni/internal/util"
|
"github.com/openobservatory/gooni/internal/util"
|
||||||
|
"github.com/openobservatory/gooni/nettests/groups"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -21,6 +22,8 @@ func init() {
|
||||||
}
|
}
|
||||||
log.Infof("%s", config)
|
log.Infof("%s", config)
|
||||||
log.Infof("%s", ooni)
|
log.Infof("%s", ooni)
|
||||||
|
|
||||||
|
groups.Run(*nettestGroup, ooni)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/openobservatory/gooni/internal/cli/root"
|
"github.com/openobservatory/gooni/internal/cli/root"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Version = "0.0.1"
|
const Version = "3.0.0-dev.0"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmd := root.Command("version", "Show version.")
|
cmd := root.Command("version", "Show version.")
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package groups
|
package groups
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/apex/log"
|
||||||
|
ooni "github.com/openobservatory/gooni"
|
||||||
"github.com/openobservatory/gooni/nettests"
|
"github.com/openobservatory/gooni/nettests"
|
||||||
|
"github.com/openobservatory/gooni/nettests/performance"
|
||||||
"github.com/openobservatory/gooni/nettests/websites"
|
"github.com/openobservatory/gooni/nettests/websites"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,8 +17,10 @@ var NettestGroups = map[string]nettests.NettestGroup{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"performance": nettests.NettestGroup{
|
"performance": nettests.NettestGroup{
|
||||||
Label: "Performance",
|
Label: "Performance",
|
||||||
Nettests: []nettests.Nettest{},
|
Nettests: []nettests.Nettest{
|
||||||
|
performance.NDT{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"middleboxes": nettests.NettestGroup{
|
"middleboxes": nettests.NettestGroup{
|
||||||
Label: "Middleboxes",
|
Label: "Middleboxes",
|
||||||
|
@ -26,3 +31,15 @@ var NettestGroups = map[string]nettests.NettestGroup{
|
||||||
Nettests: []nettests.Nettest{},
|
Nettests: []nettests.Nettest{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run runs a specific test group
|
||||||
|
func Run(name string, ctx *ooni.Context) error {
|
||||||
|
group := NettestGroups[name]
|
||||||
|
log.Debugf("Running test group %s", group.Label)
|
||||||
|
|
||||||
|
for _, nt := range group.Nettests {
|
||||||
|
ctl := nettests.NewController(ctx)
|
||||||
|
nt.Run(ctl)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
package nettests
|
package nettests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/measurement-kit/go-measurement-kit"
|
"github.com/measurement-kit/go-measurement-kit"
|
||||||
ooni "github.com/openobservatory/gooni"
|
ooni "github.com/openobservatory/gooni"
|
||||||
"github.com/openobservatory/gooni/internal/database"
|
"github.com/openobservatory/gooni/internal/cli/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Nettest interface. Every Nettest should implement this.
|
// Nettest interface. Every Nettest should implement this.
|
||||||
type Nettest interface {
|
type Nettest interface {
|
||||||
Run(*Controller) error
|
Run(*Controller) error
|
||||||
Summary(*database.Measurement) string
|
Summary(map[string]interface{}) interface{}
|
||||||
LogSummary(string) error
|
LogSummary(string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,21 +23,38 @@ type NettestGroup struct {
|
||||||
Summary func(s string) string
|
Summary func(s string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controller is passed to the run method of every Nettest
|
// NewController creates a nettest controller
|
||||||
type Controller struct {
|
func NewController(ctx *ooni.Context) *Controller {
|
||||||
ctx *ooni.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
// New Nettest Controller
|
|
||||||
func (c *Controller) New(ctx *ooni.Context) *Controller {
|
|
||||||
return &Controller{
|
return &Controller{
|
||||||
ctx,
|
ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Controller is passed to the run method of every Nettest
|
||||||
|
type Controller struct {
|
||||||
|
ctx *ooni.Context
|
||||||
|
}
|
||||||
|
|
||||||
// Init should be called once to initialise the nettest
|
// Init should be called once to initialise the nettest
|
||||||
func (c *Controller) Init(nt *mk.Nettest) {
|
func (c *Controller) Init(nt *mk.Nettest) {
|
||||||
log.Debugf("Init: %s", nt)
|
log.Debugf("Init: %s", nt)
|
||||||
|
nt.Options = mk.NettestOptions{
|
||||||
|
IncludeIP: c.ctx.Config.Sharing.IncludeIP,
|
||||||
|
IncludeASN: c.ctx.Config.Sharing.IncludeASN,
|
||||||
|
IncludeCountry: c.ctx.Config.Advanced.IncludeCountry,
|
||||||
|
DisableCollector: false,
|
||||||
|
SoftwareName: "ooniprobe",
|
||||||
|
SoftwareVersion: version.Version,
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
GeoIPCountryPath: "",
|
||||||
|
GeoASNPath: "",
|
||||||
|
OutputPath: "",
|
||||||
|
CaBundlePath: "",
|
||||||
|
}
|
||||||
|
nt.RegisterEventHandler(func(event interface{}) {
|
||||||
|
fmt.Println("Got event", event)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnProgress should be called when a new progress event is available.
|
// OnProgress should be called when a new progress event is available.
|
||||||
|
|
55
nettests/performance/ndt.go
Normal file
55
nettests/performance/ndt.go
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package performance
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/measurement-kit/go-measurement-kit"
|
||||||
|
"github.com/openobservatory/gooni/nettests"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NDT test implementation
|
||||||
|
type NDT struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run starts the test
|
||||||
|
func (n NDT) Run(ctl *nettests.Controller) error {
|
||||||
|
nt := mk.Nettest{Name: "Ndt"}
|
||||||
|
ctl.Init(&nt)
|
||||||
|
return nt.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NDTSummary for the test
|
||||||
|
type NDTSummary struct {
|
||||||
|
Upload int64
|
||||||
|
Download int64
|
||||||
|
Ping int64
|
||||||
|
MaxRTT int64
|
||||||
|
AvgRTT int64
|
||||||
|
MinRTT int64
|
||||||
|
MSS int64
|
||||||
|
OutOfOrder int64
|
||||||
|
PacketLoss float32
|
||||||
|
Timeouts int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// Summary generates a summary for a test run
|
||||||
|
func (n NDT) Summary(tk map[string]interface{}) interface{} {
|
||||||
|
simple := tk["simple"].(map[string]interface{})
|
||||||
|
advanced := tk["advanced"].(map[string]interface{})
|
||||||
|
|
||||||
|
return NDTSummary{
|
||||||
|
Upload: simple["upload"].(int64),
|
||||||
|
Download: simple["download"].(int64),
|
||||||
|
Ping: simple["ping"].(int64),
|
||||||
|
MaxRTT: advanced["max_rtt"].(int64),
|
||||||
|
AvgRTT: advanced["avg_rtt"].(int64),
|
||||||
|
MinRTT: advanced["min_rtt"].(int64),
|
||||||
|
MSS: advanced["mss"].(int64),
|
||||||
|
OutOfOrder: advanced["out_of_order"].(int64),
|
||||||
|
PacketLoss: advanced["packet_loss"].(float32),
|
||||||
|
Timeouts: advanced["timeouts"].(int64),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogSummary writes the summary to the standard output
|
||||||
|
func (n NDT) LogSummary(s string) error {
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package websites
|
package websites
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/openobservatory/gooni/internal/database"
|
"github.com/measurement-kit/go-measurement-kit"
|
||||||
"github.com/openobservatory/gooni/nettests"
|
"github.com/openobservatory/gooni/nettests"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,12 +11,14 @@ type WebConnectivity struct {
|
||||||
|
|
||||||
// Run starts the test
|
// Run starts the test
|
||||||
func (n WebConnectivity) Run(ctl *nettests.Controller) error {
|
func (n WebConnectivity) Run(ctl *nettests.Controller) error {
|
||||||
return nil
|
nt := mk.Nettest{Name: "WebConnectivity"}
|
||||||
|
ctl.Init(&nt)
|
||||||
|
return nt.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Summary generates a summary for a test run
|
// Summary generates a summary for a test run
|
||||||
func (n WebConnectivity) Summary(m *database.Measurement) string {
|
func (n WebConnectivity) Summary(tk map[string]interface{}) interface{} {
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogSummary writes the summary to the standard output
|
// LogSummary writes the summary to the standard output
|
||||||
|
|
14
ooni.go
14
ooni.go
|
@ -33,8 +33,8 @@ func Onboarding(c *Config) error {
|
||||||
|
|
||||||
// Context for OONI Probe
|
// Context for OONI Probe
|
||||||
type Context struct {
|
type Context struct {
|
||||||
config *Config
|
Config *Config
|
||||||
db *sqlx.DB
|
DB *sqlx.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the OONI manager
|
// Init the OONI manager
|
||||||
|
@ -42,8 +42,8 @@ func (c *Context) Init() error {
|
||||||
if err := legacy.MaybeMigrateHome(); err != nil {
|
if err := legacy.MaybeMigrateHome(); err != nil {
|
||||||
return errors.Wrap(err, "migrating home")
|
return errors.Wrap(err, "migrating home")
|
||||||
}
|
}
|
||||||
if c.config.InformedConsent == false {
|
if c.Config.InformedConsent == false {
|
||||||
if err := Onboarding(c.config); err != nil {
|
if err := Onboarding(c.Config); err != nil {
|
||||||
return errors.Wrap(err, "onboarding")
|
return errors.Wrap(err, "onboarding")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ func (c *Context) Init() error {
|
||||||
// New Context instance.
|
// New Context instance.
|
||||||
func New(c *Config, d *sqlx.DB) *Context {
|
func New(c *Config, d *sqlx.DB) *Context {
|
||||||
return &Context{
|
return &Context{
|
||||||
config: c,
|
Config: c,
|
||||||
db: d,
|
DB: d,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ type Config struct {
|
||||||
Notifications config.Notifications `json:"notifications"`
|
Notifications config.Notifications `json:"notifications"`
|
||||||
AutomatedTesting config.AutomatedTesting `json:"automated_testing"`
|
AutomatedTesting config.AutomatedTesting `json:"automated_testing"`
|
||||||
NettestGroups config.NettestGroups `json:"test_settings"`
|
NettestGroups config.NettestGroups `json:"test_settings"`
|
||||||
Advanced config.Sharing `json:"advanced"`
|
Advanced config.Advanced `json:"advanced"`
|
||||||
|
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
path string
|
path string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user