ooni-probe-cli/nettests/dash.go

64 lines
1.5 KiB
Go
Raw Normal View History

2019-12-02 16:57:55 +01:00
package nettests
2018-03-14 14:44:37 +01:00
import (
"github.com/pkg/errors"
2018-03-14 14:44:37 +01:00
)
// Dash test implementation
type Dash struct {
}
// Run starts the test
2019-12-02 16:57:55 +01:00
func (d Dash) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder("dash")
if err != nil {
return err
}
return ctl.Run(builder, []string{""})
2018-03-14 14:44:37 +01:00
}
2018-09-10 12:41:28 +02:00
// DashTestKeys for the test
2018-03-14 14:44:37 +01:00
// TODO: process 'receiver_data' to provide an array of performance for a chart.
2018-09-10 12:41:28 +02:00
type DashTestKeys struct {
Latency float64 `json:"connect_latency"`
Bitrate float64 `json:"median_bitrate"`
2018-09-10 12:41:28 +02:00
Delay float64 `json:"min_playout_delay"`
IsAnomaly bool `json:"-"`
2018-03-14 14:44:37 +01:00
}
2018-09-10 12:41:28 +02:00
// GetTestKeys generates a summary for a test run
func (d Dash) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
var err error
testKeys := DashTestKeys{IsAnomaly: false}
simple, ok := tk["simple"].(map[string]interface{})
if !ok {
return testKeys, errors.New("simple key is not of the expected type")
}
latency, ok := simple["connect_latency"].(float64)
if !ok {
err = errors.Wrap(err, "connect_latency is invalid")
}
testKeys.Latency = latency
bitrate, ok := simple["median_bitrate"].(float64)
if !ok {
err = errors.Wrap(err, "median_bitrate is invalid")
}
testKeys.Bitrate = bitrate
delay, ok := simple["min_playout_delay"].(float64)
if !ok {
err = errors.Wrap(err, "min_playout_delay is invalid")
2018-03-14 14:44:37 +01:00
}
testKeys.Delay = delay
return testKeys, err
2018-03-14 14:44:37 +01:00
}
// LogSummary writes the summary to the standard output
func (d Dash) LogSummary(s string) error {
return nil
}