Skip to content

Fix timing-dependent MavenResolver itests - #3145

Merged
jbonofre merged 1 commit into
apache:mainfrom
jbonofre:fix-mavenresolver-itest-race
Nov 22, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
jbonofre:fix-mavenresolver-itest-race

Conversation

@jbonofre

Copy link
Copy Markdown
Member

Problem

Since #3116 re-enabled them, MavenResolverRegisteredBeforeConfigAdminTest.mavenResolverAvailable fails on test (macos-latest) with:

There should be two registrations/unregistrations of MavenResolver before final (ConfigAdmin based) registration expected:<5> but was:<3>

It fails on main (run 44907370033, f0541e5) and on all 3 attempts of #3143 (run 44903955446). The other OS jobs pass.

Cause

The test counts org.ops4j.pax.url.mvn.MavenResolver service events. pax-url-aether registers a resolver when it starts (service property configuration=bundlecontext). Each ManagedService.updated() call from ConfigAdmin then registers a new resolver and unregisters the old one, which is 2 events:

  • 5 events: ConfigAdmin first calls updated(null) (another bundlecontext resolver), then delivers the etc/org.ops4j.pax.url.mvn.cfg configuration (configadmin resolver).
  • 3 events: FileInstall has already created the configuration when ConfigAdmin first calls updated(), so there is one call only.

Both are valid startups. Which one happens depends on the timing between FileInstall and ConfigAdmin's update thread. The 3-event case reproduces locally by starting pax-url-aether after FileInstall and ConfigAdmin (start level 12 in etc/startup.properties): [REGISTERED(bundlecontext), REGISTERED(configadmin), UNREGISTERING(bundlecontext)].

Fix

  • KarafMinimalMonitoredTestSupport.awaitFinalRegistration waits (up to 30 s) until a single MavenResolver is left registered and it was built from the ConfigAdmin configuration. The registrations happen on ConfigAdmin's thread, so the probe can also run before the last one.
  • MavenResolverRegisteredBeforeConfigAdminTest then checks that the first registration was made from the bundle context, i.e. before ConfigAdmin, which is what the test is about, instead of an exact count.
  • MavenResolverRegisteredOnlyAfterConfigAdminTest waits the same way, then still requires exactly one registration. Its Javadoc, copied from the other test, is corrected.
  • Failure messages list the events, e.g. [REGISTERED(bundlecontext), REGISTERED(configadmin), UNREGISTERING(bundlecontext)], as CI doesn't upload the container logs.
  • ServiceMonitor is filled by the registering threads while the probe reads it, so it now uses a CopyOnWriteArrayList instead of a LinkedList.

Testing

Against a build of main on macOS arm64, JDK 21:

  • Normal startup: both tests pass in 3/3 rounds (6–8 s each, as before).
  • pax-url-aether at start level 12 (3 events): the old assertion fails with 3, the new one passes (2/2).
  • Final registration arriving late (configuration deleted in the probe, then recreated 2 s later): the new assertion waits about 2 s, then passes.

Both tests are still @Ignored on karaf-4.4.x, so no backport is needed.

MavenResolverRegisteredBeforeConfigAdminTest asserted exactly 5
MavenResolver service events. pax-url-aether registers a resolver when it
starts, then re-registers it on every ManagedService.updated() call from
ConfigAdmin, so 5 events means two calls: updated(null), then the
etc/org.ops4j.pax.url.mvn.cfg configuration. When FileInstall creates
that configuration before ConfigAdmin first calls updated(), there is
only one call and 3 events, which fails on the macOS CI runners.

Wait until a single MavenResolver built from the ConfigAdmin
configuration is left registered, then check that the first registration
was made from the bundle context, i.e. before ConfigAdmin. The
"only after" test waits the same way before checking for a single
registration. Failure messages now list the events.

ServiceMonitor is filled by the registering threads while the probe
reads it, so use a CopyOnWriteArrayList instead of a LinkedList.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Test Results

1 112 files  ±0  1 112 suites  ±0   1h 27m 54s ⏱️ -15s
1 367 tests ±0  1 236 ✅ +1  131 💤 ±0  0 ❌  - 1 
5 468 runs  ±0  4 942 ✅ +1  526 💤 ±0  0 ❌  - 1 

Results for commit e1488b1. ± Comparison against base commit f0541e5.

♻️ This comment has been updated with latest results.

@jbonofre
jbonofre merged commit e568396 into apache:main Nov 22, 2026
23 of 25 checks passed
@jbonofre
jbonofre deleted the fix-mavenresolver-itest-race branch November 22, 2026 04:20
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.

1 participant