(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func 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 | }, |
nothing calls this directly
no test coverage detected