Skip to content

[chore][receiver/sqlserverreceiver] Fix flaky sqlserverreceiver integration tests#45317

Merged
songy23 merged 4 commits intoopen-telemetry:mainfrom
osullivandonal:fix-flaky-sqlserver-integration-test
Jan 12, 2026
Merged

[chore][receiver/sqlserverreceiver] Fix flaky sqlserverreceiver integration tests#45317
songy23 merged 4 commits intoopen-telemetry:mainfrom
osullivandonal:fix-flaky-sqlserver-integration-test

Conversation

@osullivandonal
Copy link
Copy Markdown
Contributor

Description

The SQL Server integration tests are flaky when running in CI.

The reason for this is twofold: first, the LookbackTime is set to 1μs while the collection interval is 1ms. This causes issues where the lookback time window is too small to find any queries that ran. Second, the test was setting a variable inside an EventuallyWithT closure and then using that variable outside the closure, which meant the final assertion could fail even when EventuallyWithT succeeded.

The fix increases LookbackTime to 1 second and moves all validation logic inside the EventuallyWithT closure to ensure atomicity.

Link to tracking issue

Fixes #45070

Testing

Test was ran locally multiple times with no failures:

cd receiver/sqlserverreceiver
go test -tags=integration -run TestEventsScraper/TopQuery -count 5

The SQL Server integration tests are flaky when running in CI. The
reason for this is twofold: first, the LookbackTime is set to
1μs while the collection interval is 1ms. This causes issues where the
lookback time window is too small to find any queries that ran.
Second, the test was setting a variable inside an EventuallyWithT
closure and then using that variable outside the closure, which meant
the final assertion could fail even when EventuallyWithT succeeded.

The fix increases LookbackTime to 1 second and moves all validation
logic inside the EventuallyWithT closure to ensure atomicity.
@osullivandonal osullivandonal requested review from a team and crobert-1 as code owners January 9, 2026 16:55
@github-actions github-actions Bot added receiver/sqlserver Run Windows Enable running windows test on a PR labels Jan 9, 2026
@github-actions github-actions Bot requested a review from sincejune January 9, 2026 16:55
Copy link
Copy Markdown
Contributor

@dehaansa dehaansa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise LGTM.

assert.True(tt, found, "Expected query not found in logs")
}, 10*time.Second, 100*time.Millisecond)

assert.True(t, found, "Expected query not found in final validation")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, as the Eventually will fail if the last attempt fails and this won't be reached.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, I have removed this assert.

Comment thread receiver/sqlserverreceiver/integration_test.go
Comment thread receiver/sqlserverreceiver/integration_test.go
@crobert-1 crobert-1 added the ready to merge Code review completed; ready to merge by maintainers label Jan 12, 2026
@songy23 songy23 merged commit 7abc52a into open-telemetry:main Jan 12, 2026
279 checks passed
@github-actions github-actions Bot added this to the next release milestone Jan 12, 2026
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Jan 12, 2026

Thank you for your contribution @osullivandonal! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Code review completed; ready to merge by maintainers receiver/sqlserver Run Windows Enable running windows test on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug][receiver/sqlserverreceiver] integration test flake: TopQuery returns zero logs and panics on empty ResourceLogs

5 participants