Skip to content

CBG-5702 replace WaitForCondition test helpers for dbconfig - #8585

Open
torcolvin wants to merge 1 commit into
mainfrom
CBG-5702
Open

CBG-5702 replace WaitForCondition test helpers for dbconfig#8585
torcolvin wants to merge 1 commit into
mainfrom
CBG-5702

Conversation

@torcolvin

Copy link
Copy Markdown
Collaborator

CBG-5702 replace WaitForCondition test helpers for dbconfig

Remove WaitForCondition with testify helpers which give better output.

Integration Tests

@torcolvin
torcolvin requested review from a team and a lite review from Copilot August 10, 2026 19:45
@factory-droid

factory-droid Bot commented Aug 10, 2026

Copy link
Copy Markdown

Droid finished @torcolvin's task —— View job


Copilot AI left a comment

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.

Pull request overview

Updates Sync Gateway’s REST test harness and related tests to replace custom WaitForCondition* polling (used around dbconfig/config-polling scenarios) with testify’s EventuallyWithT-style helpers for clearer failure output and less bespoke polling logic.

Changes:

  • Added RestTester.WaitForDatabase and RestTester.WaitForInvalidDatabase helpers built on require.EventuallyWithT.
  • Refactored several dbconfig/config-polling tests to use the new helpers (and EventuallyWithT/Never directly in a couple spots).
  • Relaxed ServerContext.AllInvalidDatabaseNames’s testing-only signature from *testing.T to testing.TB.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
rest/utilities_testing.go Adds new RestTester wait helpers and adjusts AllInvalidDatabaseNames to accept testing.TB.
rest/config_test.go Switches invalid-db polling from inline EventuallyWithT to rt.WaitForInvalidDatabase.
rest/adminapitest/resync_test.go Replaces a generic “any db exists” poll with rt2.WaitForDatabase("db").
rest/adminapitest/admin_api_test.go Refactors multiple config-polling/invalid-config waits to use the new helpers and EventuallyWithT.
Suppressed comments (3)

rest/adminapitest/admin_api_test.go:1205

  • This call waits for "db1" to be tracked as invalid, but the previous logic required exactly one invalid database config. If that's still the intended invariant for this scenario, keep the count check to prevent the test passing with unexpected extra invalid configs.
	rt3.WaitForInvalidDatabase("db1")

rest/adminapitest/admin_api_test.go:1273

  • This wait no longer asserts that there is exactly 1 invalid database config (it only checks presence of "db1"). If the test expects a single invalid config here, add a length assertion to preserve the original check and avoid masking additional invalid configs.
	rt3.WaitForInvalidDatabase("db1")

rest/adminapitest/admin_api_test.go:1334

  • This now only waits for "db1" to appear as invalid; previously the test asserted there was exactly one invalid database. If that strictness is still desired, add a length assertion so the test fails when additional invalid configs are present unexpectedly.
	rt.WaitForInvalidDatabase("db1")

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rest/config_test.go
invalidDatabases := rt.ServerContext().AllInvalidDatabaseNames(t)
assert.Equal(c, 1, len(invalidDatabases))
}, time.Second*10, time.Millisecond*100)
rt.WaitForInvalidDatabase("db1")
return len(invalidDatabases) == 1
}, 200, 1000)
require.NoError(t, err)
rt.WaitForInvalidDatabase("db1")

@factory-droid factory-droid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Change is a straightforward refactor from bespoke wait loops to testify-based helpers and adds RestTester convenience methods. No concrete, actionable bugs found in the diff.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants