(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func 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 |
| 136 | metric_c 20 |
| 137 | # HELP metric_a cheescake |
| 138 | # TYPE metric_a GAUGE |
| 139 | metric_a 1 |
| 140 | metric_a{first="value1"} 10 |
| 141 | metric_a{first="value1", something="x"} 4 |
| 142 | metric_a{first="value1", something2="a"} 203 |
| 143 | metric_a{first="value1", something3="b"} Nan |
| 144 | metric_a{first="value2"} 2 |
| 145 | metric_a{second="value1"} 1 |
| 146 | # HELP metric_b cheescake |
| 147 | # TYPE metric_b GAUGE |
| 148 | metric_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")) |
nothing calls this directly
no test coverage detected