Skip to content

Commit

Permalink
fix: update test values for synchronous EWMA
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed May 14, 2024
1 parent bed51ac commit 4d8e1b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 35 deletions.
6 changes: 3 additions & 3 deletions graphite/graphite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func TestWrites(t *testing.T) {
t.Errorf("%s != %s", expect, str[:len(str)-12])
}

expect = "p.bar.rate.15min 1.000000"
expect = "p.bar.rate.15min 0.000000"
if str := res["p.bar.rate.15min"]; expect != str[:len(str)-12] {
t.Errorf("%s != %s", expect, str[:len(str)-12])
}

expect = "p.bar.rate.1min 1.000000"
expect = "p.bar.rate.1min 0.000000"
if str := res["p.bar.rate.1min"]; expect != str[:len(str)-12] {
t.Errorf("%s != %s", expect, str[:len(str)-12])
}

expect = "p.bar.rate.5min 1.000000"
expect = "p.bar.rate.5min 0.000000"
if str := res["p.bar.rate.5min"]; expect != str[:len(str)-12] {
t.Errorf("%s != %s", expect, str[:len(str)-12])
}
Expand Down
12 changes: 6 additions & 6 deletions logging/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,15 @@ func TestEncodeMeter(t *testing.T) {
if line := lines[0][:len(lines[0])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "bar_foo_rate_1min 20.000000"
expect = "bar_foo_rate_1min 0.000000"
if line := lines[1][:len(lines[1])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "bar_foo_rate_5min 20.000000"
expect = "bar_foo_rate_5min 0.000000"
if line := lines[2][:len(lines[2])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "bar_foo_rate_15min 20.000000"
expect = "bar_foo_rate_15min 0.000000"
if line := lines[3][:len(lines[3])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
Expand All @@ -326,15 +326,15 @@ func TestEncodeMeter(t *testing.T) {
if line := lines[0][:len(lines[0])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "foo_rate_1min 20.000000"
expect = "foo_rate_1min 0.000000"
if line := lines[1][:len(lines[1])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "foo_rate_5min 20.000000"
expect = "foo_rate_5min 0.000000"
if line := lines[2][:len(lines[2])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
expect = "foo_rate_15min 20.000000"
expect = "foo_rate_15min 0.000000"
if line := lines[3][:len(lines[3])-11]; line != expect {
t.Errorf("Encode(): %s != %s", line, expect)
}
Expand Down
6 changes: 3 additions & 3 deletions prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ func TestPrometheusOnce(t *testing.T) {
}

expected = "name:\"meter_rate_15min\" help:\"meter_rate_15min\" type:GAUGE " +
"metric:<gauge:<value:45 > > "
"metric:<gauge:<value:0 > > "
if expected != fmt.Sprint(metrics[3]) {
t.Errorf("Once(): %s != %s", expected, metrics[3])
}

expected = "name:\"meter_rate_1min\" help:\"meter_rate_1min\" type:GAUGE " +
"metric:<gauge:<value:45 > > "
"metric:<gauge:<value:0 > > "
if expected != fmt.Sprint(metrics[4]) {
t.Errorf("Once(): %s != %s", expected, metrics[4])
}

expected = "name:\"meter_rate_5min\" help:\"meter_rate_5min\" type:GAUGE " +
"metric:<gauge:<value:45 > > "
"metric:<gauge:<value:0 > > "
if expected != fmt.Sprint(metrics[5]) {
t.Errorf("Once(): %s != %s", expected, metrics[5])
}
Expand Down
26 changes: 3 additions & 23 deletions statsd/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestWrites(t *testing.T) {
defer ln.Close()

metrics.GetOrRegisterCounter("foo", nil).Inc(2)
metrics.GetOrRegisterMeter("bar", nil).Mark(1)
metrics.GetOrRegisterGauge("bar", nil).Update(1)

ctx.Store(false)
wg.Add(1)
Expand All @@ -84,28 +84,8 @@ func TestWrites(t *testing.T) {
}
wg.Wait()

expect := "p.bar.count:1|c\n"
if str := res["p.bar.count"]; expect != str {
t.Errorf("%v != %v", expect, str)
}

expect = "p.bar.rate.15min:1.000000|g\n"
if str := res["p.bar.rate.15min"]; expect != str {
t.Errorf("%v != %v", expect, str)
}

expect = "p.bar.rate.5min:1.000000|g\n"
if str := res["p.bar.rate.5min"]; expect != str {
t.Errorf("%v != %v", expect, str)
}

expect = "p.bar.rate.1min:1.000000|g\n"
if str := res["p.bar.rate.1min"]; expect != str {
t.Errorf("%v != %v", expect, str)
}

expect = "p.bar.rate.1min:1.000000|g\n"
if str := res["p.bar.rate.1min"]; expect != str {
expect := "p.bar:1|g\n"
if str := res["p.bar"]; expect != str {
t.Errorf("%v != %v", expect, str)
}

Expand Down

0 comments on commit 4d8e1b9

Please sign in to comment.