Skip to content

Commit

Permalink
[chore][processor/remotetap] Fix flaky tests (#32970)
Browse files Browse the repository at this point in the history
I added more information on the issue, but it seems like the limiter
being used is especially flaky with timing in tests, so if too many
metrics/traces/logs are being sent, the limit won't get fully hit as
expected, meaning data will count as two separate intervals in the test
(thus not being limited properly). This is flakiness in testing, not the
rate limiter's fault, from what I can tell.

Also, in `assert.Equal`, the expected value should be first, and the
actual value should be second. I've swapped these as the original output
of the test failure was causing me confusion.

Resolves #32967
  • Loading branch information
crobert-1 authored May 22, 2024
1 parent 788fca7 commit 6cec2a6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions processor/remotetapprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestConsumeMetrics(t *testing.T) {
{name: "limit_0", limit: 0},
{name: "limit_1", limit: 1},
{name: "limit_10", limit: 10},
{name: "limit_50", limit: 50},
{name: "limit_30", limit: 30},
}

for _, c := range cases {
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestConsumeMetrics(t *testing.T) {

processor.cs.closeAndRemove(idx)
wg.Wait()
assert.Equal(t, receiveNum, c.limit)
assert.Equal(t, c.limit, receiveNum)

})
}
Expand All @@ -76,7 +76,7 @@ func TestConsumeLogs(t *testing.T) {
{name: "limit_0", limit: 0},
{name: "limit_1", limit: 1},
{name: "limit_10", limit: 10},
{name: "limit_50", limit: 50},
{name: "limit_30", limit: 30},
}

for _, c := range cases {
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestConsumeLogs(t *testing.T) {
processor.cs.closeAndRemove(idx)
wg.Wait()
t.Log(receiveNum)
assert.Equal(t, receiveNum, c.limit)
assert.Equal(t, c.limit, receiveNum)
})
}
}
Expand All @@ -125,7 +125,7 @@ func TestConsumeTraces(t *testing.T) {
{name: "limit_0", limit: 0},
{name: "limit_1", limit: 1},
{name: "limit_10", limit: 10},
{name: "limit_50", limit: 50},
{name: "limit_30", limit: 30},
}

for _, c := range cases {
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestConsumeTraces(t *testing.T) {

processor.cs.closeAndRemove(idx)
wg.Wait()
assert.Equal(t, receiveNum, c.limit)
assert.Equal(t, c.limit, receiveNum)
})
}
}

0 comments on commit 6cec2a6

Please sign in to comment.