add a Dash Test.

This commit is contained in:
Will Scott 2018-03-14 06:44:37 -07:00
parent 62b515e2e0
commit 1d40171e04
4 changed files with 47 additions and 4 deletions

View File

@ -36,6 +36,7 @@ func init() {
} }
for _, nt := range group.Nettests { for _, nt := range group.Nettests {
log.Debugf("Running test %T", nt)
ctl := nettests.NewController(ctx, result) ctl := nettests.NewController(ctx, result)
if err := nt.Run(ctl); err != nil { if err := nt.Run(ctl); err != nil {
log.WithError(err).Errorf("Failed to run %s", group.Label) log.WithError(err).Errorf("Failed to run %s", group.Label)

View File

@ -17,6 +17,7 @@ var NettestGroups = map[string]nettests.NettestGroup{
"performance": nettests.NettestGroup{ "performance": nettests.NettestGroup{
Label: "Performance", Label: "Performance",
Nettests: []nettests.Nettest{ Nettests: []nettests.Nettest{
performance.Dash{},
performance.NDT{}, performance.NDT{},
}, },
}, },

View File

@ -32,7 +32,7 @@ func NewController(ctx *ooni.Context, res *database.Result) *Controller {
// Controller is passed to the run method of every Nettest // Controller is passed to the run method of every Nettest
type Controller struct { type Controller struct {
ctx *ooni.Context Ctx *ooni.Context
res *database.Result res *database.Result
} }
@ -40,9 +40,9 @@ type Controller struct {
func (c *Controller) Init(nt *mk.Nettest) { func (c *Controller) Init(nt *mk.Nettest) {
log.Debugf("Init: %v", nt) log.Debugf("Init: %v", nt)
nt.Options = mk.NettestOptions{ nt.Options = mk.NettestOptions{
IncludeIP: c.ctx.Config.Sharing.IncludeIP, IncludeIP: c.Ctx.Config.Sharing.IncludeIP,
IncludeASN: c.ctx.Config.Sharing.IncludeASN, IncludeASN: c.Ctx.Config.Sharing.IncludeASN,
IncludeCountry: c.ctx.Config.Advanced.IncludeCountry, IncludeCountry: c.Ctx.Config.Advanced.IncludeCountry,
DisableCollector: false, DisableCollector: false,
SoftwareName: "ooniprobe", SoftwareName: "ooniprobe",
SoftwareVersion: version.Version, SoftwareVersion: version.Version,

View File

@ -0,0 +1,41 @@
package performance
import (
"github.com/measurement-kit/go-measurement-kit"
"github.com/openobservatory/gooni/nettests"
)
// Dash test implementation
type Dash struct {
}
// Run starts the test
func (d Dash) Run(ctl *nettests.Controller) error {
dash := mk.Nettest{Name: "Dash"}
ctl.Init(&dash)
return dash.Run()
}
// DashSummary for the test
// TODO: process 'receiver_data' to provide an array of performance for a chart.
type DashSummary struct {
Latency float32
Bitrate int64
Delay float32
}
// Summary generates a summary for a test run
func (d Dash) Summary(tk map[string]interface{}) interface{} {
simple := tk["simple"].(map[string]interface{})
return DashSummary{
Latency: simple["connect_latency"].(float32),
Bitrate: simple["median_bitrate"].(int64),
Delay: simple["min_playout_delay"].(float32),
}
}
// LogSummary writes the summary to the standard output
func (d Dash) LogSummary(s string) error {
return nil
}