-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stagger timestamps in exact aggregator tests #1569
Conversation
I could swear I tried this while I was trying to debug these tests and it didn't work, but this is definitely working now. I am, however, still seeing errors in the --- FAIL: TestMergeBehavior (0.00s)
--- FAIL: TestMergeBehavior/Int64Kind (0.00s)
--- FAIL: TestMergeBehavior/Int64Kind/Forward=false (0.00s)
exact_test.go:347:
Error Trace: exact_test.go:347
Error: Should be true
Test: TestMergeBehavior/Int64Kind/Forward=false
--- FAIL: TestMergeBehavior/Int64Kind/Forward=true (0.00s)
exact_test.go:347:
Error Trace: exact_test.go:347
Error: Should be true
Test: TestMergeBehavior/Int64Kind/Forward=true
--- FAIL: TestMergeBehavior/Float64Kind (0.00s)
--- FAIL: TestMergeBehavior/Float64Kind/Forward=false (0.00s)
exact_test.go:347:
Error Trace: exact_test.go:347
Error: Should be true
Test: TestMergeBehavior/Float64Kind/Forward=false
--- FAIL: TestMergeBehavior/Float64Kind/Forward=true (0.00s)
exact_test.go:347:
Error Trace: exact_test.go:347
Error: Should be true
Test: TestMergeBehavior/Float64Kind/Forward=true
FAIL
FAIL go.opentelemetry.io/otel/sdk/metric/aggregator/exact 0.038s These can be addressed by inverting the ordering check in that test as was done earlier in the other tests in that file: diff --git a/sdk/metric/aggregator/exact/exact_test.go b/sdk/metric/aggregator/exact/exact_test.go
index 10e0c615..0a8f1cb4 100644
--- a/sdk/metric/aggregator/exact/exact_test.go
+++ b/sdk/metric/aggregator/exact/exact_test.go
@@ -344,7 +344,7 @@ func TestMergeBehavior(t *testing.T) {
received.Append(s.Number)
if i > 0 {
- require.True(t, pts[i-1].Time.Before(pts[i].Time))
+ require.False(t, pts[i-1].Time.After(pts[i].Time))
}
} It may be worthwhile to put the sleeps into that test as well since it does the same ordered contents check that was flaking in the other test. |
Thanks for the catch @Aneurysm9! Do you think it's better to use sleep across the board and revert the relaxed time comparisons (which should be unnecessary once the timestamps are guaranteed to be distinct)? |
I think perhaps we should keep both the sleep and the not-after check. The sleep helps ensure that the same order test is unambiguous and the not-after check validates what the code actually does. I think the implementation would need to change if we wanted to ensure that the points from checkpoint 1 always ended up first in a merged checkpoint when points from both checkpoints were recorded at the same instant. |
Codecov Report
@@ Coverage Diff @@
## main #1569 +/- ##
=======================================
- Coverage 78.2% 78.0% -0.3%
=======================================
Files 127 127
Lines 6577 6597 +20
=======================================
+ Hits 5149 5151 +2
- Misses 1183 1201 +18
Partials 245 245
|
* Stagger timestamps in exact aggregator tests Fixes open-telemetry#1559. * Missed one * Yield while you wait * Just sleep for a teeny tiny bit * Oops, wrong PR in Changelog * Make sure that *some* time passes * Keep time comparisons relaxed
Fixes #1559.