Skip to content

fix(test): fix parallel test Props contamination and empty-list guards#2796

Merged
simonredfern merged 10 commits into
OpenBankProject:developfrom
hongwei1:develop-obp
May 20, 2026
Merged

fix(test): fix parallel test Props contamination and empty-list guards#2796
simonredfern merged 10 commits into
OpenBankProject:developfrom
hongwei1:develop-obp

Conversation

@hongwei1
Copy link
Copy Markdown
Contributor

Summary

  • Wrap all setPropsValues calls in APIUtilHeavyTest inside a scenario block 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.
  • Add PropsReset to GetScannedApiVersionsTest so api_enabled_versions props set in scenarios are cleaned up after each test.
  • Guard randomBankId in V500ServerSetup against an empty banks list to prevent IllegalArgumentException: bound must be positive.
  • Guard randomPrivateAccount / randomPrivateAccountViaEndpoint in V510ServerSetup against empty account lists for the same reason.

Root cause

APIUtilHeavyTest had setPropsValues("api_enabled_versions" -> "[OBPv4.0.0]") directly in a feature(...) block body. In ScalaTest FeatureSpec, code in the feature block body (outside scenario) runs during class instantiation, not as a test. Maven Surefire runs test classes in parallel in the same JVM, so this initialisation call set api_enabled_versions=[OBPv4.0.0] globally while other v5.x/v6.x test suites were executing — causing ResourceDocMiddleware.endpointIsEnabled() to return 404 for all non-v4.0.0 endpoints.

Test plan

  • All 285 test suites pass locally (./run_all_tests.sh)
  • No new failures introduced in v5.0.0, v5.1.0, v6.0.0, v4.0.0 test packages

hongwei1 added 10 commits May 19, 2026 08:08
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
@sonarqubecloud
Copy link
Copy Markdown

@simonredfern simonredfern merged commit 9de2374 into OpenBankProject:develop May 20, 2026
7 checks passed
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