ops4j / org.ops4j.pax.exam2

Pax Exam is a testing framework for OSGi
https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/
Apache License 2.0
84 stars 100 forks source link

Regression - failure when starting two Karaf containers [PAXEXAM-940] #1020

Closed ops4j-issues closed 3 weeks ago

ops4j-issues commented 3 years ago

Amichai Rothman created PAXEXAM-940

When upgrading to Pax Exam 4.13.4 with Karaf 4.3.0, an itest that starts two Karaf containers (to test some communication between them) now fails, with the exception below. The same test has been working for years before this. My guess is that commit aa8473a2 caused the regression, where it changed how the free RMI port is detected and didn't account for this scenario.

java.lang.RuntimeException: Problem starting container
at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:195)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.setUp(EagerSingleStagedReactor.java:86)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.beforeClass(EagerSingleStagedReactor.java:136)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.beforeClass(ReactorManager.java:457)
at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:97)
at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
at com.example.itest.setup.TwoContainerPaxExam.run(TwoContainerPaxExam.java:48)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.rmi.server.ExportException: internal error: ObjID already in use
at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:186)
at sun.rmi.transport.Transport.exportObject(Transport.java:106)
at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:265)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:236)
at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:213)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:198)
at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203)
at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.openRegistryOnFreePort(KarafTestContainer.java:228)
at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:134)
... 14 more

And this is an additional side effect exception due to stop being called after the start call wasn't successful (perhaps the stop method should be made more robust, to successfully run regardless of how far the start method got):

java.lang.RuntimeException: java.lang.NullPointerException
at com.example.itest.setup.TwoContainerPaxExam.run(TwoContainerPaxExam.java:50)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.NullPointerException
at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1423)
at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.stop(KarafTestContainer.java:700)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.tearDown(EagerSingleStagedReactor.java:118)
at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.afterClass(EagerSingleStagedReactor.java:132)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.afterClass(ReactorManager.java:441)
at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:107)
at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
at com.example.itest.setup.TwoContainerPaxExam.run(TwoContainerPaxExam.java:48)
... 8 more


Affects: 4.13.4 Votes: 0, Watches: 2

ops4j-issues commented 3 years ago

Jean-Baptiste Onofre commented

I can add an option to avoid to find free port. And so the user can have the choice.

amichair commented 2 years ago

Was the option added? How does one use it?

b-q commented 2 years ago

Was the option added? How does one use it?

Hello @amichair i checked the code, the KarafTestContainer class has been modified. before 4.13.4 it will choose a free port from a range. After 4.13.4, it try always with the minimal port, that's the issue.

For my side, i did a rollback to 4.13.3.

So @jbonofre @ops4j-issues any update about this ?

Thanks

amichair commented 2 years ago

Yeah we're also stuck on 4.13.3 until this is reverted/fixed.

amichair commented 2 years ago

Still unusable in 4.13.5.

amichair commented 1 year ago

Will this be fixed?

oliverlietz commented 1 year ago

@amichair Can you please check with latest snapshot (though no support for range)?

amichair commented 1 year ago

The snapshot repository link on the project page in github is broken, where can I find it?

amichair commented 1 year ago

btw also the CI link is broken, and the latest version is way behind (on the homepage). Anyhoo, I cloned and built it locally, master branch fails to build, but I tried the 4.x branch and build was successful. Tried 4.13.6-SNAPSHOT with my two container itest and it works well, the issue seems to be resolved!

Still hitting #1093, but that's a different story :-)