fix(test): fix parallel test Props contamination and empty-list guards#2796
Merged
Conversation
Three resource docs used hardcoded name strings ("createBank", "updateBank",
"createAccount") instead of nameOf(...). The literal value equals the val name
in each case, so this is behaviour-neutral — it brings the file in line with
the other 39 resource docs in Http4s500 and matches the cosmetic-fix
pre-condition used in the v5.1.0 retirement (commit 88f46f8).
Pre-condition for the upcoming OBPAPI5_0_0 rewire and APIMethods500 stub.
…outes The v500ToV400Bridge and v6→v5.1→v5.0 cascade are already operational, and Http4s500 has all 41 v5.0.0-native endpoints with 42 resourceDocs. This commit removes the parallel Lift dispatch path: - OBPAPI5_0_0: drop all `with APIMethods130 … with APIMethods500` mixins, drop `endpointsOf5_0_0` and `getAllowedEndpoints(...)`. routes=Nil. allResourceDocs now aggregates Http4s500.resourceDocs (42 docs) on top of OBPAPI4_0_0.allResourceDocs, replacing the previous reference to APIMethods500's inner-class Implementations5_0_0.resourceDocs (37 docs). The Lift CORS this.serve(...) block is removed — http4s corsHandler handles OPTIONS preflight. Re-exports `Implementations5_0_0 = Http4s500.Implementations5_0_0` to keep test imports compiling after APIMethods500 is stubbed in the next commit. - ResourceDocsAPIMethods: add `case ApiVersion.v5_0_0 => resourceDocs` to the skip filter. Without this, /resource-docs/v5.0.0/obp would filter the aggregated docs by Lift route class (now empty) and return nothing. After this commit APIMethods500 is dead code — no longer mixed in or referenced. Behaviour is unchanged: all v5.0.0 requests already routed through Http4s500 before this commit; only the (unused) Lift fallback path is removed.
All v5.0.0 Lift endpoints live in Http4s500. APIMethods500 is dead code. Replace the 2,524-line implementation with an empty trait stub + re-export object so any existing import of APIMethods500.Implementations5_0_0 still resolves (delegates to Http4s500.Implementations5_0_0). Original code kept as block comments for grep-ability.
Http4s500 declares getBanks, getProduct, getProducts with implementedInApiVersion=v5.0.0. These were served by Http4s500 before but absent from the old APIMethods500 resourceDocs snapshot. Regenerate with FrozenClassUtil to record the correct stable API set.
# Conflicts: # obp-api/src/main/scala/code/api/v6_0_0/Http4s600.scala
…cenario block setPropsValues calls in a feature(...) block body run at class-init time, not inside any scenario. PropsReset.afterEach is never called between class init and the first scenario, so api_enabled_versions=[OBPv4.0.0] leaked into global Props during parallel test execution, causing all v5.0.0/v5.1.0/v6.0.0 endpoints to return 404.
Scenarios set api_disabled_versions and api_enabled_versions without any cleanup, leaving contaminated Props for subsequent parallel tests.
…etup nextInt(0) throws IllegalArgumentException when the list is empty.
… against empty list in V510ServerSetup nextInt(0) throws IllegalArgumentException when the accounts list is empty.
# Conflicts: # obp-api/src/main/scala/code/api/v6_0_0/Http4s600.scala # obp-api/src/test/scala/code/util/APIUtilHeavyTest.scala
|
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
setPropsValuescalls inAPIUtilHeavyTestinside ascenarioblock so they no longer run during class initialisation in parallel test execution, preventing Props contamination that caused widespread 404 failures in v5.x/v6.x test suites.PropsResettoGetScannedApiVersionsTestsoapi_enabled_versionsprops set in scenarios are cleaned up after each test.randomBankIdinV500ServerSetupagainst an empty banks list to preventIllegalArgumentException: bound must be positive.randomPrivateAccount/randomPrivateAccountViaEndpointinV510ServerSetupagainst empty account lists for the same reason.Root cause
APIUtilHeavyTesthadsetPropsValues("api_enabled_versions" -> "[OBPv4.0.0]")directly in afeature(...)block body. In ScalaTest FeatureSpec, code in thefeatureblock body (outsidescenario) runs during class instantiation, not as a test. Maven Surefire runs test classes in parallel in the same JVM, so this initialisation call setapi_enabled_versions=[OBPv4.0.0]globally while other v5.x/v6.x test suites were executing — causingResourceDocMiddleware.endpointIsEnabled()to return 404 for all non-v4.0.0 endpoints.Test plan
./run_all_tests.sh)