| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Adds explicit reset hooks to a JVM-lifetime singleton test mock and invokes them before each test to prevent cross-test state leakage.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| operator-framework/src/test/java/io/javaoperatorsdk/operator/support/ExternalIDGenServiceMock.java | Adds a reset() method to clear the singleton mock’s internal state between tests. |
| operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/externalstate/externalstatebulkdependent/ExternalStateBulkIT.java | Resets the singleton mock before each test to avoid state leakage. |
| operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/externalstate/ExternalStateTestBase.java | Resets the singleton mock before each test in the shared base test class. |
Sorry, something went wrong.
| @BeforeEach | ||
| void resetExternalService() { | ||
| externalService.reset(); | ||
| } |
There was a problem hiding this comment.
Centralised the reset into ExternalServiceResetExtension (BeforeEachCallback) and dropped the duplicated @BeforeEach blocks. Both ExternalStateTestBase and ExternalStateBulkIT now declare @ExtendWith(ExternalServiceResetExtension.class).
Sorry, something went wrong.
|
Hi @Dennis-Mircea, thank you for the PR. Please run the spotless plugin to format the code in order for CI to pass. |
Sorry, something went wrong.
Resolved! |
Sorry, something went wrong.
…nal-state ITs Signed-off-by: Dennis-Mircea Ciupitu <dennis.mircea.ciupitu@gmail.com>
Signed-off-by: Dennis-Mircea Ciupitu <dennis.mircea.ciupitu@gmail.com>
There was a problem hiding this comment.
LGTM!
thank you @Dennis-Mircea
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes an intermittent CI failure in three integration tests (an example can be found here: https://github.com/operator-framework/java-operator-sdk/actions/runs/26563951370/job/78253684721?pr=3383):
Symptoms in CI:
The same ExternalResource@3370ff56 instance hash showed up in all three failures, which is the giveaway: an ExternalResource object was outliving the test that created it.
Root cause
operator-framework/src/test/java/io/javaoperatorsdk/operator/support/ExternalIDGenServiceMock.java is a JVM-lifetime singleton with a mutable ConcurrentHashMap field:
Each external-state test creates resources through getInstance().create(...) (entered into resourceMap) and expects the reconciler's cleanup path to remove them after the custom resource is deleted. Cleanup is asynchronous, so when the next test runs there is a race window in which the previous test's ExternalResource is still in the map. The next test creates its own resource, sees two entries, and Awaitility times out after 10 s.
Fix
Three small, test-only changes:
Concurrency note
JOSDK does not enable JUnit 5 parallel execution (no junit-platform.properties, no junit.jupiter.execution.parallel.* properties in any pom.xml). The flake addressed here is a sequential test-ordering issue, not a parallel-execution one, and the BeforeEachCallback is sufficient given that constraint. If parallel execution is ever enabled, the singleton would need to be replaced by per-test instances rather than relying on reset().
Test plan