MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestWaitSumMetric_Nan

Function TestWaitSumMetric_Nan

integration/e2e/service_test.go:115–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestWaitSumMetric_Nan(t *testing.T) {
116 // Listen on a random port before starting the HTTP server, to
117 // make sure the port is already open when we'll call WaitSumMetric()
118 // the first time (this avoid flaky tests).
119 ln, err := net.Listen("tcp", "localhost:0")
120 require.NoError(t, err)
121 defer ln.Close()
122
123 // Get the port.
124 _, addrPort, err := net.SplitHostPort(ln.Addr().String())
125 require.NoError(t, err)
126
127 port, err := strconv.Atoi(addrPort)
128 require.NoError(t, err)
129
130 // Start an HTTP server exposing the metrics.
131 srv := &http.Server{
132 Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
133 _, _ = w.Write([]byte(`
134# HELP metric_c cheescake
135# TYPE metric_c GAUGE
136metric_c 20
137# HELP metric_a cheescake
138# TYPE metric_a GAUGE
139metric_a 1
140metric_a{first="value1"} 10
141metric_a{first="value1", something="x"} 4
142metric_a{first="value1", something2="a"} 203
143metric_a{first="value1", something3="b"} Nan
144metric_a{first="value2"} 2
145metric_a{second="value1"} 1
146# HELP metric_b cheescake
147# TYPE metric_b GAUGE
148metric_b 1000
149`))
150 }),
151 }
152 defer srv.Close()
153
154 go func() {
155 _ = srv.Serve(ln)
156 }()
157
158 s := &HTTPService{
159 httpPort: 0,
160 ConcreteService: &ConcreteService{
161 networkPortsContainerToLocal: map[int]int{
162 0: port,
163 },
164 },
165 }
166
167 s.SetBackoff(backoff.Config{
168 MinBackoff: 300 * time.Millisecond,
169 MaxBackoff: 600 * time.Millisecond,
170 MaxRetries: 50,
171 })
172 require.NoError(t, s.WaitSumMetrics(Equals(math.NaN()), "metric_a"))

Callers

nothing calls this directly

Calls 6

WaitSumMetricsMethod · 0.95
EqualsFunction · 0.85
SetBackoffMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected