Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes inconsistency with input error counting #7077

Merged
merged 2 commits into from
Feb 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixes indeterminite test result
  • Loading branch information
ssoroka committed Feb 25, 2020
commit 2ecf31061e04f6585cb3c59238743c34139f0edd
33 changes: 20 additions & 13 deletions internal/models/running_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,24 +260,31 @@ func TestMakeMetricNameSuffix(t *testing.T) {

func TestMetricErrorCounters(t *testing.T) {
ri := NewRunningInput(&testInput{}, &InputConfig{
Name: "Test",
Name: "TestMetricErrorCounters",
})

ri.Log().Error("Oh no")

require.Equal(t, int64(1), GlobalGatherErrors.Get())
// find the new input error register.
for _, r := range selfstat.Metrics() {
if r.Name() == "internal_gather" {
errCount, ok := r.GetField("errors")
if !ok {
t.Fatal("Expected error field")
getGatherErrors := func() int64 {
for _, r := range selfstat.Metrics() {
tag, hasTag := r.GetTag("input")
if r.Name() == "internal_gather" && hasTag && tag == "TestMetricErrorCounters" {
errCount, ok := r.GetField("errors")
if !ok {
t.Fatal("Expected error field")
}
return errCount.(int64)
}
require.Equal(t, int64(1), errCount)
return
}
return 0
}
t.Error("Didn't find gather error field")

before := getGatherErrors()

ri.Log().Error("Oh no")

after := getGatherErrors()

require.Greater(t, after, before)
require.GreaterOrEqual(t, int64(1), GlobalGatherErrors.Get())
}

type testInput struct{}
Expand Down