Skip to content

test(spanner): restrict pagination test to explicitly created database - #14043

Merged
sakthivelmanii merged 1 commit into
mainfrom
fix-spanner-pagination-flakiness
Aug 11, 2026
Merged

test(spanner): restrict pagination test to explicitly created database#14043
sakthivelmanii merged 1 commit into
mainfrom
fix-spanner-pagination-flakiness

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

The ITBackupTest.testPagination method previously listed all backups on the instance and asserted that only a single page of results would be returned (assertFalse(page.hasNextPage())). When running on shared integration test instances (spanner.testenv.instance), this assertion would fail if backups from other test runs were present on the instance.

This commit updates the pagination API calls to use Options.filter("database:" + databaseId), ensuring that the test only paginates over the backups associated with the uniquely generated database for the active test run. This prevents the test from failing due to unrelated backups in the shared test environment.

@sakthivelmanii
sakthivelmanii requested review from a team as code owners August 11, 2026 17:07

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the testPagination method in ITBackupTest.java to filter backups by database name and asserts that the number of paginated backups matches the initial backup count. The reviewer identified a logic issue where the assertFalse(page.hasNextPage()) assertion prevents the pagination loop from executing or causes failures when multiple backups exist. Additionally, the reviewer recommended extracting the repeated database filter option into a local variable to improve readability.

@sakthivelmanii
sakthivelmanii force-pushed the fix-spanner-pagination-flakiness branch from 0194748 to 114f3cd Compare August 11, 2026 17:16
The `ITBackupTest.testPagination` method previously listed all backups on the instance and asserted that only a single page of results would be returned (`assertFalse(page.hasNextPage())`). When running on shared integration test instances (`spanner.testenv.instance`), this assertion would fail if backups from other test runs were present on the instance.

This commit updates the pagination API calls to use `Options.filter("database:" + databaseId)`, ensuring that the test only paginates over the backups associated with the uniquely generated database for the active test run. This prevents the test from failing due to unrelated backups in the shared test environment.
@sakthivelmanii
sakthivelmanii force-pushed the fix-spanner-pagination-flakiness branch from 114f3cd to 1a263f2 Compare August 11, 2026 17:25
@sakthivelmanii

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the testPagination method in ITBackupTest.java to accept a Database object and filter backups by the database ID. It also replaces the assertion on the number of backups with an exact match check against the initial backups size. A review comment points out a compilation error where database.getId().getName() is used instead of database.getId().getDatabase(), which needs to be resolved.

private void testPagination(Database database) {
logger.info("Listing backups using pagination");
Options.ListOption filter =
Options.filter(String.format("database:%s", database.getId().getName()));

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.

critical

The DatabaseId class does not have a getName() method. Calling database.getId().getName() will result in a compilation error. It should be replaced with database.getId().getDatabase() to correctly retrieve the database name.

Suggested change
Options.filter(String.format("database:%s", database.getId().getName()));
Options.filter(String.format("database:%s", database.getId().getDatabase()));

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.

I double-checked this, and DatabaseId actually does have a getName() method. It retrieves the fully-qualified Spanner resource name (projects/%s/instances/%s/databases/%s), whereas getDatabase() only returns the short string ID.

Since the Options.filter("database:" + ...) API natively accepts the fully-qualified resource name, database.getId().getName() works perfectly here

@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) August 11, 2026 18:00
@sakthivelmanii
sakthivelmanii merged commit e4fdc6f into main Aug 11, 2026
204 of 205 checks passed
@sakthivelmanii
sakthivelmanii deleted the fix-spanner-pagination-flakiness branch August 11, 2026 18:05
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