Skip to content

fix(tests): Fix flaky tests and add reusable test infrastructure#399

Open
currantw wants to merge 17 commits into
valkey-io:mainfrom
currantw:94_flaky_test_TestKeyIdleTime
Open

fix(tests): Fix flaky tests and add reusable test infrastructure#399
currantw wants to merge 17 commits into
valkey-io:mainfrom
currantw:94_flaky_test_TestKeyIdleTime

Conversation

@currantw
Copy link
Copy Markdown
Collaborator

@currantw currantw commented May 13, 2026

Summary

  • Fix flaky integration tests:
    • TestKeyIdleTime
    • UpdateConnectionPasswordTests
    • ReadFromTests.ConfigurationPipeline_ClonePreservesReadFromConfiguration
    • ReadFromTests.ConfigurationPipeline_ValidationErrorPropagation
  • Introduce reusable test infrastructure including a Polling utility and ServerFixture base class.

Issue Link

Features and Behaviour Changes

⚪ None — test infrastructure only.

Implementation

  • Test infrastructure:
    • New Polling utility (tests/Valkey.Glide.TestUtils/Polling.cs): Provides AssertTrue and AssertTrueAsync methods that poll a condition with configurable timeout and interval, calling Assert.Fail on timeout. Follows the same pattern previously used in PubSubUtils.
    • New ServerFixture base class (tests/Valkey.Glide.TestUtils/Fixture.cs): Provides shared standalone/cluster servers, GetServer(bool), CreateClientAsync(bool), and IDisposable lifecycle for test fixtures that need isolated servers.
  • Flaky test fixes:
    • Fix TestKeyIdleTime: Replaced the fixed 1-second Task.Delay with a polling loop that retries for up to 10 seconds.
    • Fix UpdateConnectionPasswordTests: Introduced UpdateConnectionPasswordFixture (extends ServerFixture) with a RetryStrategy for cluster client creation to handle transient connection timeouts during cluster startup. Replaced [InlineData(true/false)] with [MemberData(nameof(ClusterMode), MemberType = typeof(Data))]. Servers are now shared via the fixture instead of created per-test.
    • Fix ReadFromTests: Use TestConfiguration.DefaultCompatibleConfig() instead of manual ConfigurationOptions setup in ConfigurationPipeline_ValidationErrorPropagation and ConfigurationPipeline_ClonePreservesReadFromConfiguration, ensuring ResponseTimeout is set to prevent timeouts in CI.
  • Refactoring
    • Refactored existing polling loops: Updated PubSubUtils.AssertSubscribedAsync, PubSubUtils.AssertNotSubscribedAsync, PubSubQueueTests, and PubSubCommandTests.AssertHandlerReceives to use the new Polling utility, reducing duplicated boilerplate.

Limitations

⚪ None

Testing

✅ All tests pass (dotnet build with zero warnings/errors).

Related Issues

Checklist

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated and all checks pass.
  • CHANGELOG.md, README.md, DEVELOPER.md, and other documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

currantw added 6 commits May 13, 2026 12:20
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw currantw self-assigned this May 13, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw currantw requested review from affonsov and alexr-bq May 13, 2026 20:31
@currantw currantw added ci CI/CD pipelines and GitHub Actions tests Unit tests, integration tests, or test utilities flaky-test Flaky test in CI release-1.2 Targeted for release 1.2 labels May 13, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
currantw added 6 commits May 13, 2026 16:09
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Comment thread tests/Valkey.Glide.IntegrationTests/ReadFromTests.cs
currantw added 3 commits May 14, 2026 08:46
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw currantw changed the title fix(tests): Fix flaky TestKeyIdleTime and add reusable Polling utility fix(tests): Fix flaky tests and add reusable test infrastructure May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD pipelines and GitHub Actions flaky-test Flaky test in CI release-1.2 Targeted for release 1.2 tests Unit tests, integration tests, or test utilities

Projects

None yet

2 participants