Skip to content

[itests] Fix flaky WebTest - #2981

Merged
jbonofre merged 2 commits into
apache:mainfrom
jbonofre:fix-flaky-webtest
Oct 15, 2026
Merged

jbonofre merged 2 commits into
apache:mainfrom
jbonofre:fix-flaky-webtest

Conversation

@jbonofre

@jbonofre jbonofre commented Oct 7, 2026

Copy link
Copy Markdown
Member

WebTest.installViaMBean failed intermittently on the Windows CI runner with:

InstanceNotFound org.apache.karaf:type=web,name=root

The test looked up the web MBean right after the war / pax-web-karaf features were installed, before the MBean was registered.

This change:

  • waits (up to 30s) for the web MBean to be registered before listViaMBean and installViaMBean use it
  • replaces the fixed Thread.sleep(2000) in installViaMBean with a bounded poll on WebBundles, which had the same race

Test-only change. The failure was seen on #2978 and passed on re-run with no code change.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Test Results

  729 files  ±0    729 suites  ±0   1h 19m 1s ⏱️ +4s
1 077 tests ±0    943 ✅ ±0  134 💤 ±0  0 ❌ ±0 
3 231 runs  ±0  2 829 ✅ ±0  402 💤 ±0  0 ❌ ±0 

Results for commit 0db061f. ± Comparison against base commit faad2e1.

♻️ This comment has been updated with latest results.

private void waitForMBean(MBeanServer mbeanServer, ObjectName name) throws InterruptedException {
long deadline = System.currentTimeMillis() + 30000;
while (!mbeanServer.isRegistered(name) && System.currentTimeMillis() < deadline) {
Thread.sleep(500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses active waiting - replacing this with async calls would make it less readable but may allow us to run the unit tests concurrently. Your thoughts on this tradeoff?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question. I would keep the bounded polling here. These itests share one Karaf container and its MBeanServer, and listViaMBean asserts on state that installViaMBean mutates, so async calls would not let them run concurrently. The tests would need isolated containers for that. The polling returns as soon as the condition holds, so it's no slower than an event-based wait, and it is simpler. I can extract a shared waitFor helper if you would like the duplication gone.

…ext is published

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jbonofre
jbonofre merged commit 3d00b33 into apache:main Oct 15, 2026
7 checks passed
@jbonofre
jbonofre deleted the fix-flaky-webtest branch October 15, 2026 12:30
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