Skip to content

Commit

Permalink
Merge 427ca18 into 1e8b482
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Jan 7, 2020
2 parents 1e8b482 + 427ca18 commit 982f9f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/log/handlers/cli/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ var summarizers = map[string]func(uint64, uint64, string) []string{
},
"circumvention": func(totalCount uint64, anomalyCount uint64, ss string) []string {
return []string{
fmt.Sprintf("Detected: %v", anomalyCount > 0),
"",
fmt.Sprintf("%d tested", totalCount),
fmt.Sprintf("%d blocked", anomalyCount),
"",
}
},
Expand Down
26 changes: 22 additions & 4 deletions nettests/psiphon.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package nettests

import "github.com/pkg/errors"

// Psiphon test implementation
type Psiphon struct {
}
Expand All @@ -17,14 +19,30 @@ 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
ok bool
)
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
Expand Down

0 comments on commit 982f9f8

Please sign in to comment.