test: isolate shared cloud resources to prevent concurrent CI flakes - #4608
Open
lqiu96 wants to merge 5 commits into
Open
test: isolate shared cloud resources to prevent concurrent CI flakes#4608lqiu96 wants to merge 5 commits into
lqiu96 wants to merge 5 commits into
Conversation
lqiu96
force-pushed
the
fix-ci-concurrent-test-isolation
branch
from
August 28, 2026 04:38
27d1981 to
1d8743f
Compare
- Pub/Sub Reactive sample:
- Make topic and subscription configurable via sample.topic and sample.subscription.
- Await publishing futures in MessageSenderController.publish() to guarantee messages are enqueued before responding.
- Dynamically generate unique topic and subscription names per test in ReactiveReceiverApplicationIntegrationTest and manage their lifecycle via PubSubAdmin.
- Datastore samples:
- Add application-test.properties with a unique random UUID namespace for spring-cloud-gcp-data-datastore-basic-sample and bind via @TestPropertySource.
- Include ${random.uuid} in test namespaces for spring-cloud-gcp-data-datastore-sample and spring-cloud-gcp-data-multi-sample to prevent cross-PR / cross-runner collision.
- Cloud SQL & AlloyDB samples:
- Make table creation idempotent with CREATE TABLE IF NOT EXISTS users in schema.sql.
- Make initial row insertion idempotent (ON CONFLICT (email) DO NOTHING for Postgres/AlloyDB, INSERT IGNORE for MySQL).
- Remove destructive @AfterEach DROP TABLE calls and cleanup.sql table drops that break concurrent test runners sharing database instances.
- Document table persistence and manual cleanup instructions in each sample's README.adoc.
lqiu96
force-pushed
the
fix-ci-concurrent-test-isolation
branch
from
August 28, 2026 04:45
1d8743f to
fad35e8
Compare
…ts now that tests isolate schemas
…ub/Sub UUID isolation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR resolves concurrent test collisions and flakiness across parallel matrix runners and simultaneous CI runs by ensuring all integration tests use isolated or idempotent cloud resources:
Pub/Sub Reactive Sample (
spring-cloud-gcp-pubsub-reactive-sample):sample.topicandsample.subscription.MessageSenderController.publish()to await all publishing futures before redirecting, guaranteeing that messages are published before the test checks for them.ReactiveReceiverApplicationIntegrationTestwith@DynamicPropertySourceusing unique UUID-suffixed topic/subscription names, and manage creation/teardown viaPubSubAdminin@BeforeAll/@AfterAll.Datastore Samples (
datastore-basic,datastore,multi-sample):application-test.propertiesforspring-cloud-gcp-data-datastore-basic-sampleand wired it via@TestPropertySourceonDatastoreBookshelfExampleIntegrationTests.${random.uuid}(spring-demo-${java.specification.version}-${random.uuid}) acrossspring-cloud-gcp-data-datastore-sample,spring-cloud-gcp-data-multi-sample, andspring-cloud-gcp-data-datastore-basic-sample. This prevents concurrent CI runs across different PRs on the same Java version from mutating or deleting each other's test data.Cloud SQL & AlloyDB Samples (
sql-postgres,sql-postgres-r2dbc,alloydb,sql-mysql):schema.sqlto useCREATE TABLE IF NOT EXISTS usersanddata.sqlto use non-conflicting inserts (ON CONFLICT (email) DO NOTHINGfor Postgres/AlloyDB;INSERT IGNOREfor MySQL).@AfterEachDROP TABLE IF EXISTS usersfromAlloyDbSampleApplicationIntegrationTests,SqlPostgresSampleApplicationIntegrationTests, andSqlMysqlSampleApplicationIntegrationTests, and madecleanup.sqlin the R2DBC sample a no-op.README.adocand Java comments that theuserstable persists after running the sample and instructions for manual cleanup if desired.