(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func TestMetrics(t *testing.T) { |
| 223 | mp := testMetricsProvider{} |
| 224 | t0 := time.Unix(0, 0) |
| 225 | c := clock.NewFakeClock(t0) |
| 226 | mf := queueMetricsFactory{metricsProvider: &mp} |
| 227 | m := mf.newQueueMetrics("test", c) |
| 228 | q := newQueue(c, m, time.Millisecond) |
| 229 | defer q.ShutDown() |
| 230 | for !c.HasWaiters() { |
| 231 | // Wait for the go routine to call NewTicker() |
| 232 | time.Sleep(time.Millisecond) |
| 233 | } |
| 234 | |
| 235 | q.Add("foo") |
| 236 | if e, a := 1.0, mp.adds.gaugeValue(); e != a { |
| 237 | t.Errorf("expected %v, got %v", e, a) |
| 238 | } |
| 239 | |
| 240 | if e, a := 1.0, mp.deprecatedAdds.gaugeValue(); e != a { |
| 241 | t.Errorf("expected %v, got %v", e, a) |
| 242 | } |
| 243 | |
| 244 | if e, a := 1.0, mp.depth.gaugeValue(); e != a { |
| 245 | t.Errorf("expected %v, got %v", e, a) |
| 246 | } |
| 247 | |
| 248 | if e, a := 1.0, mp.deprecatedDepth.gaugeValue(); e != a { |
| 249 | t.Errorf("expected %v, got %v", e, a) |
| 250 | } |
| 251 | |
| 252 | c.Step(50 * time.Microsecond) |
| 253 | |
| 254 | // Start processing |
| 255 | i, _ := q.Get() |
| 256 | if i != "foo" { |
| 257 | t.Errorf("Expected %v, got %v", "foo", i) |
| 258 | } |
| 259 | |
| 260 | if e, a := 5e-05, mp.latency.observationValue(); e != a { |
| 261 | t.Errorf("expected %v, got %v", e, a) |
| 262 | } |
| 263 | if e, a := 1, mp.latency.observationCount(); e != a { |
| 264 | t.Errorf("expected %v, got %v", e, a) |
| 265 | } |
| 266 | if e, a := 50.0, mp.deprecatedLatency.observationValue(); e != a { |
| 267 | t.Errorf("expected %v, got %v", e, a) |
| 268 | } |
| 269 | if e, a := 1, mp.deprecatedLatency.observationCount(); e != a { |
| 270 | t.Errorf("expected %v, got %v", e, a) |
| 271 | } |
| 272 | if e, a := 0.0, mp.depth.gaugeValue(); e != a { |
| 273 | t.Errorf("expected %v, got %v", e, a) |
| 274 | } |
| 275 | if e, a := 0.0, mp.deprecatedDepth.gaugeValue(); e != a { |
| 276 | t.Errorf("expected %v, got %v", e, a) |
| 277 | } |
| 278 | |
| 279 | // Add it back while processing; multiple adds of the same item are |
nothing calls this directly
no test coverage detected