ml
This commit is contained in:
1 parent
21f04d696b
commit
8f5c267444
26 files changed
+3039
-10
No files matched your search
@@ -392,6 +392,31 @@ func TestHandleIssuesAndByID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleMLDetectorTest(t *testing.T) {
|
||||
coll := New(nil, 10, nil)
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/ml/test-spike", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
coll.HandleMLDetectorTest(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected detector test success, got %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var result struct {
|
||||
Passed bool `json:"passed"`
|
||||
Row struct {
|
||||
LabelKnown bool `json:"labelKnown"`
|
||||
Label bool `json:"label"`
|
||||
BaselineErrorRate float64 `json:"baselineErrorRate"`
|
||||
FutureErrorCount int `json:"futureErrorCount"`
|
||||
} `json:"row"`
|
||||
}
|
||||
if err := json.NewDecoder(rec.Body).Decode(&result); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !result.Passed || !result.Row.LabelKnown || !result.Row.Label || result.Row.BaselineErrorRate != .1 || result.Row.FutureErrorCount != 5 {
|
||||
t.Fatalf("unexpected detector verification response: %+v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleIssuesFiltersAndPaginates(t *testing.T) {
|
||||
coll := New(noopBroadcaster{}, 10, nil)
|
||||
coll.issues.Record("span_error", "nginx", "GET /.env", issues.Sample{Timestamp: 300, SourceIP: "203.0.113.10", HTTPRoute: "/.env"})
|
||||
|
||||
Reference in new issue
Block a user