Fix flaky GCS ADC fallback test by isolating in its own JVM#146013
Fix flaky GCS ADC fallback test by isolating in its own JVM#146013jdconrad wants to merge 11 commits intoelastic:mainfrom
Conversation
When no credentials_file is configured, GoogleCloudStorageService calls GoogleCredentials.getApplicationDefault(), which uses DefaultCredentialsProvider to discover credentials. If credential files are inaccessible (e.g. due to entitlement checks returning false from File.isFile()), it falls through to the GCE metadata server. This test exercises that code path using a mock HttpTransport that simulates the GCE metadata server, asserting that credentials are successfully obtained when no explicit credentials_file is set. Relates: elastic#145626 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
File.isFile() returns false when entitlement is denied (regardless of whether GOOGLE_APPLICATION_CREDENTIALS is set), so DefaultCredentialsProvider always falls through to the mock metadata server. The guard was redundant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The testApplicationDefaultCredentialsFallbackToComputeEngine test was failing ~38% of the time because Google's DefaultCredentialsProvider singleton caches credentials and GCE detection state across tests in the same JVM. When another test primed the singleton before this test ran, the credential discovery flow was bypassed entirely. Move the test to a dedicated GoogleCloudStorageAdcTests class run by a separate gcsAdcTest Gradle task, guaranteeing a clean singleton state. Also add auth validation and metadata request handling to the GCS test fixture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis change addresses test flakiness by restructuring how the Application Default Credentials fallback test executes. The test method 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
testApplicationDefaultCredentialsFallbackToComputeEnginefromGoogleCloudStorageServiceTeststo a newGoogleCloudStorageAdcTestsclassgcsAdcTestGradle task in its own JVM, ensuring theDefaultCredentialsProvidersingleton starts with clean state (cachedCredentials,checkedComputeEngine)The test was failing ~38% of the time (#145689) because Google's
DefaultCredentialsProvidersingleton caches credentials and GCE detection state. When another test in the same JVM primed the singleton before this test ran, the credential discovery flow (including theFile.isFile()entitlement check) was bypassed entirely.Closes #145689