jbonofre opened a new pull request, #2973:
URL: https://github.com/apache/karaf/pull/2973

   Integration tests fail randomly on CI in classes unrelated to the change 
being built. For example on #2972, which only touches `ConfigExampleTest`:
   
   - `JmsSshCommandSecurityTest`: `Bundle cannot be installed`, caused by 
`BundleException: Resolver hook prevented resolution. Unresolved requirements: 
[]`
   - `JaasTest.testLoginSingleReg` and `KarSshCommandSecurityTest`: 
`ClassNotFoundException: ... not found by PAXEXAM-PROBE-...`
   - `RejectedExecutionException` from 
`FeaturesServiceImpl.doProvisionInThread`, on an executor that is terminated 
after exactly one completed task (hidden by the retry rule)
   
   All of them happen in the first moments of a test, right after the boot 
features are installed.
   
   ### Cause
   
   `BaseActivator` schedules a run (`doStop()` + `doStart()`) each time a 
tracked service or the configuration changes. If a tracked service shows up 
while a run is in progress, `doStart()` can already see it and start the 
activator completely. The run scheduled for that same change then stops and 
starts everything again.
   
   The features activator tracks the `mvn` URL handler, which is registered 
asynchronously, when ConfigurationAdmin delivers the `org.ops4j.pax.url.mvn` 
configuration. When this lands while the features activator processes its first 
run:
   
   1. the boot features are installed and `BootFinished` is published
   2. the `FeaturesService` and the region hooks are unregistered, then 
registered again
   
   Pax Exam installs the test probe at that very moment (the remote bundle 
context is started by the boot features), so:
   
   - the region resolver hook is registered before the probe is assigned to a 
region, which prevents its resolution
   - the `FeaturesService` the test got has been stopped, so installing a 
feature is rejected
   
   ### Change
   
   `doStart()` now works on the tracked services and the configuration read at 
the beginning of the run, and a run is skipped when they are the ones the 
activator has already been started with. A tracked service or a configuration 
that really changes restarts the activator as before.
   
   ### Tests
   
   - New `BaseActivatorTest`. `startsOnceWhenServiceShowsUpWhileStarting` fails 
without the change, as the activator is started twice.
   - To reproduce, I delayed the first run of the features activator so that 
the `mvn` handler always shows up in the meantime, and ran 
`JaasTest,WrapperTest,ConfigExampleTest` in a loop:
   
     | | Test containers | Features service restarted after boot | Failed runs |
     |---|---|---|---|
     | Without the change | 80 | 75 | 2 of 10, both with `Resolver hook 
prevented resolution` |
     | With the change | 40 | 0 | 0 of 5 |
   
     I did not reproduce the `ClassNotFoundException` and the 
`RejectedExecutionException`, but they are consistent with the same restart: 
dynamic imports go through the same resolver hook, and the terminated executor 
is the one of the stopped `FeaturesService`.
   - `WrapperTest` also failed on #2972 with `No matching features for 
wrapper/0`. I did not reproduce it and can't tell if it has the same origin.
   - On JDK 17: unit tests of `util` and `features/core`, and `mvn -Ptest -f 
itests/test/pom.xml test` for `ConfigTest`, `ConfigExampleTest`, `FeatureTest`, 
`HttpTest`, `InstanceTest`, `JaasTest`, `KarTest`, `JmsSshCommandSecurityTest`, 
`KarSshCommandSecurityTest`, `SystemTest` and `WrapperTest`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to