From 96eab1202717e073782ec399a4e0820cae15b1bb Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 17 Aug 2017 17:19:06 -0700 Subject: Updating server dependancies. (#7246) --- vendor/github.com/armon/go-metrics/inmem_test.go | 76 ++++++++++++++---------- 1 file changed, 44 insertions(+), 32 deletions(-) (limited to 'vendor/github.com/armon/go-metrics/inmem_test.go') diff --git a/vendor/github.com/armon/go-metrics/inmem_test.go b/vendor/github.com/armon/go-metrics/inmem_test.go index ed3b521da..8d30e7c30 100644 --- a/vendor/github.com/armon/go-metrics/inmem_test.go +++ b/vendor/github.com/armon/go-metrics/inmem_test.go @@ -18,11 +18,15 @@ func TestInmemSink(t *testing.T) { // Add data points inm.SetGauge([]string{"foo", "bar"}, 42) + inm.SetGaugeWithLabels([]string{"foo", "bar"}, 23, []Label{{"a", "b"}}) inm.EmitKey([]string{"foo", "bar"}, 42) inm.IncrCounter([]string{"foo", "bar"}, 20) inm.IncrCounter([]string{"foo", "bar"}, 22) + inm.IncrCounterWithLabels([]string{"foo", "bar"}, 20, []Label{{"a", "b"}}) + inm.IncrCounterWithLabels([]string{"foo", "bar"}, 22, []Label{{"a", "b"}}) inm.AddSample([]string{"foo", "bar"}, 20) inm.AddSample([]string{"foo", "bar"}, 22) + inm.AddSampleWithLabels([]string{"foo", "bar"}, 23, []Label{{"a", "b"}}) data = inm.Data() if len(data) != 1 { @@ -35,49 +39,57 @@ func TestInmemSink(t *testing.T) { if time.Now().Sub(intvM.Interval) > 10*time.Millisecond { t.Fatalf("interval too old") } - if intvM.Gauges["foo.bar"] != 42 { + if intvM.Gauges["foo.bar"].Value != 42 { + t.Fatalf("bad val: %v", intvM.Gauges) + } + if intvM.Gauges["foo.bar;a=b"].Value != 23 { t.Fatalf("bad val: %v", intvM.Gauges) } if intvM.Points["foo.bar"][0] != 42 { t.Fatalf("bad val: %v", intvM.Points) } - agg := intvM.Counters["foo.bar"] - if agg.Count != 2 { - t.Fatalf("bad val: %v", agg) - } - if agg.Rate != 200 { - t.Fatalf("bad val: %v", agg.Rate) - } - if agg.Sum != 42 { - t.Fatalf("bad val: %v", agg) - } - if agg.SumSq != 884 { - t.Fatalf("bad val: %v", agg) - } - if agg.Min != 20 { - t.Fatalf("bad val: %v", agg) - } - if agg.Max != 22 { - t.Fatalf("bad val: %v", agg) - } - if agg.Mean() != 21 { - t.Fatalf("bad val: %v", agg) - } - if agg.Stddev() != math.Sqrt(2) { - t.Fatalf("bad val: %v", agg) - } + for _, agg := range []SampledValue{intvM.Counters["foo.bar"], intvM.Counters["foo.bar;a=b"]} { + if agg.Count != 2 { + t.Fatalf("bad val: %v", agg) + } + if agg.Rate != 200 { + t.Fatalf("bad val: %v", agg.Rate) + } + if agg.Sum != 42 { + t.Fatalf("bad val: %v", agg) + } + if agg.SumSq != 884 { + t.Fatalf("bad val: %v", agg) + } + if agg.Min != 20 { + t.Fatalf("bad val: %v", agg) + } + if agg.Max != 22 { + t.Fatalf("bad val: %v", agg) + } + if agg.AggregateSample.Mean() != 21 { + t.Fatalf("bad val: %v", agg) + } + if agg.AggregateSample.Stddev() != math.Sqrt(2) { + t.Fatalf("bad val: %v", agg) + } + + if agg.LastUpdated.IsZero() { + t.Fatalf("agg.LastUpdated is not set: %v", agg) + } - if agg.LastUpdated.IsZero() { - t.Fatalf("agg.LastUpdated is not set: %v", agg) + diff := time.Now().Sub(agg.LastUpdated).Seconds() + if diff > 1 { + t.Fatalf("time diff too great: %f", diff) + } } - diff := time.Now().Sub(agg.LastUpdated).Seconds() - if diff > 1 { - t.Fatalf("time diff too great: %f", diff) + if _, ok := intvM.Samples["foo.bar"]; !ok { + t.Fatalf("missing sample") } - if agg = intvM.Samples["foo.bar"]; agg == nil { + if _, ok := intvM.Samples["foo.bar;a=b"]; !ok { t.Fatalf("missing sample") } -- cgit v1.2.3-1-g7c22