MCPcopy
hub / github.com/grafana/tempo / TestSLOHook

Function TestSLOHook

modules/frontend/slos_test.go:20–164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestSLOHook(t *testing.T) {
21 tcs := []struct {
22 name string
23 cfg SLOConfig
24 bytesProcessed float64
25 httpStatusCode int
26 latency time.Duration
27 err error
28
29 totalRequests float64
30 totalCancelled float64
31 expectedWithInSLO float64
32 cancelledWithinSLO float64
33 }{
34 {
35 name: "no slo passes",
36 expectedWithInSLO: 1.0,
37 totalRequests: 1.0,
38 },
39 {
40 name: "no slo fails : error",
41 err: errors.New("foo"),
42 totalRequests: 1.0,
43 },
44 {
45 name: "no slo passes : resource exhausted grpc error",
46 err: status.Error(codes.ResourceExhausted, "foo"),
47 expectedWithInSLO: 1.0,
48 totalRequests: 1.0,
49 },
50 {
51 name: "no slo fails : 5XX status code",
52 httpStatusCode: http.StatusInternalServerError,
53 totalRequests: 1.0,
54 },
55 {
56 name: "no slo passes : 4XX status code",
57 httpStatusCode: http.StatusTooManyRequests,
58 expectedWithInSLO: 1.0,
59 totalRequests: 1.0,
60 },
61 {
62 name: "slo passes - both",
63 cfg: SLOConfig{
64 DurationSLO: 10 * time.Second,
65 ThroughputBytesSLO: 100,
66 },
67 latency: 5 * time.Second,
68 bytesProcessed: 110,
69 expectedWithInSLO: 1.0,
70 totalRequests: 1.0,
71 },
72 {
73 name: "slo passes - latency",
74 cfg: SLOConfig{
75 DurationSLO: 10 * time.Second,
76 ThroughputBytesSLO: 100,
77 },

Callers

nothing calls this directly

Calls 5

GetCounterValueFunction · 0.92
sloHookFunction · 0.85
ErrorMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected