Add support for generating the web connectivity summary
This commit is contained in:
parent
f5ff3ac87a
commit
98e95b8b7e
|
@ -15,7 +15,7 @@ import (
|
||||||
type ResultSummaryFunc func(SummaryMap) (string, error)
|
type ResultSummaryFunc func(SummaryMap) (string, error)
|
||||||
|
|
||||||
// SummaryMap contains a mapping from test name to serialized summary for it
|
// SummaryMap contains a mapping from test name to serialized summary for it
|
||||||
type SummaryMap map[string]string
|
type SummaryMap map[string][]string
|
||||||
|
|
||||||
// UpdateOne will run the specified update query and check that it only affected one row
|
// UpdateOne will run the specified update query and check that it only affected one row
|
||||||
func UpdateOne(db *sqlx.DB, query string, arg interface{}) error {
|
func UpdateOne(db *sqlx.DB, query string, arg interface{}) error {
|
||||||
|
@ -210,7 +210,12 @@ func MakeSummaryMap(db *sqlx.DB, r *Result) (SummaryMap, error) {
|
||||||
return nil, errors.Wrap(err, "failed to get measurements")
|
return nil, errors.Wrap(err, "failed to get measurements")
|
||||||
}
|
}
|
||||||
for _, msmt := range msmts {
|
for _, msmt := range msmts {
|
||||||
summaryMap[msmt.Name] = msmt.Summary
|
val, ok := summaryMap[msmt.Name]
|
||||||
|
if ok {
|
||||||
|
summaryMap[msmt.Name] = append(val, msmt.Summary)
|
||||||
|
} else {
|
||||||
|
summaryMap[msmt.Name] = []string{msmt.Summary}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return summaryMap, nil
|
return summaryMap, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,27 @@ var NettestGroups = map[string]NettestGroup{
|
||||||
},
|
},
|
||||||
Summary: func(m database.SummaryMap) (string, error) {
|
Summary: func(m database.SummaryMap) (string, error) {
|
||||||
// XXX to generate this I need to create the summary map as a list
|
// XXX to generate this I need to create the summary map as a list
|
||||||
return "{}", nil
|
var summary WebsitesSummary
|
||||||
|
summary.Tested = 0
|
||||||
|
summary.Blocked = 0
|
||||||
|
for _, msmtSummaryStr := range m["WebConnectivity"] {
|
||||||
|
var wcSummary websites.WebConnectivitySummary
|
||||||
|
|
||||||
|
err := json.Unmarshal([]byte(msmtSummaryStr), &wcSummary)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("failed to unmarshal WebConnectivity summary")
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if wcSummary.Blocked {
|
||||||
|
summary.Blocked++
|
||||||
|
}
|
||||||
|
summary.Tested++
|
||||||
|
}
|
||||||
|
summaryBytes, err := json.Marshal(summary)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(summaryBytes), nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"performance": NettestGroup{
|
"performance": NettestGroup{
|
||||||
|
@ -68,12 +88,12 @@ var NettestGroups = map[string]NettestGroup{
|
||||||
dashSummary performance.DashSummary
|
dashSummary performance.DashSummary
|
||||||
summary PerformanceSummary
|
summary PerformanceSummary
|
||||||
)
|
)
|
||||||
err = json.Unmarshal([]byte(m["Dash"]), &dashSummary)
|
err = json.Unmarshal([]byte(m["Dash"][0]), &dashSummary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to unmarshal Dash summary")
|
log.WithError(err).Error("failed to unmarshal Dash summary")
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
err = json.Unmarshal([]byte(m["Ndt"]), &ndtSummary)
|
err = json.Unmarshal([]byte(m["Ndt"][0]), &ndtSummary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to unmarshal NDT summary")
|
log.WithError(err).Error("failed to unmarshal NDT summary")
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -102,12 +122,12 @@ var NettestGroups = map[string]NettestGroup{
|
||||||
hirlSummary middlebox.HTTPInvalidRequestLineSummary
|
hirlSummary middlebox.HTTPInvalidRequestLineSummary
|
||||||
summary MiddleboxSummary
|
summary MiddleboxSummary
|
||||||
)
|
)
|
||||||
err = json.Unmarshal([]byte(m["HttpHeaderFieldManipulation"]), &hhfmSummary)
|
err = json.Unmarshal([]byte(m["HttpHeaderFieldManipulation"][0]), &hhfmSummary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to unmarshal hhfm summary")
|
log.WithError(err).Error("failed to unmarshal hhfm summary")
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
err = json.Unmarshal([]byte(m["HttpInvalidRequestLine"]), &hirlSummary)
|
err = json.Unmarshal([]byte(m["HttpInvalidRequestLine"][0]), &hirlSummary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to unmarshal hirl summary")
|
log.WithError(err).Error("failed to unmarshal hirl summary")
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user