Improve the output and extraction of psiphon metrics
This commit is contained in:
+19
-4
@@ -1,5 +1,7 @@
|
||||
package nettests
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
// Psiphon test implementation
|
||||
type Psiphon struct {
|
||||
}
|
||||
@@ -17,14 +19,27 @@ func (h Psiphon) Run(ctl *Controller) error {
|
||||
|
||||
// PsiphonTestKeys contains the test keys
|
||||
type PsiphonTestKeys struct {
|
||||
IsAnomaly bool `json:"-"`
|
||||
IsAnomaly bool `json:"-"`
|
||||
BootstrapTime float64 `json:"bootstrap_time"`
|
||||
Failure string `json:"failure"`
|
||||
}
|
||||
|
||||
// GetTestKeys generates a summary for a test run
|
||||
func (h Psiphon) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
||||
return PsiphonTestKeys{
|
||||
IsAnomaly: tk["failure"] != nil,
|
||||
}, nil
|
||||
var err error
|
||||
testKeys := PsiphonTestKeys{IsAnomaly: false, Failure: ""}
|
||||
if tk["failure"] != nil {
|
||||
testKeys.IsAnomaly = true
|
||||
testKeys.Failure, ok = tk["failure"].(string)
|
||||
if !ok {
|
||||
err = errors.Wrap(err, "failure key invalid")
|
||||
}
|
||||
}
|
||||
testKeys.BootstrapTime, ok = tk["bootstrap_time"].(float64)
|
||||
if !ok {
|
||||
err = errors.Wrap(err, "bootstrap_time key invalid")
|
||||
}
|
||||
return testKeys, err
|
||||
}
|
||||
|
||||
// LogSummary writes the summary to the standard output
|
||||
|
||||
Reference in New Issue
Block a user