Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
Yes, it sounds good to me :) The purpose of providing KarafTestSupport is to simplify the dependency (a kind of bom) and use. Regards JB On Fri, Mar 24, 2023 at 10:12 PM Steinar Bang wrote: > > > Steinar Bang : > > > No, provisioning once with @Configuration will be fine, if that > > actually loads the feature I'm adding. > > > I just wasn't sure if @Configuration would work here, since the base > > class was different, and the example didn't use it, and I have never > > investigated how the setup of KarafTestSupport classes actually work. > > > I thought maybe the installAndAssertFeature() function was necessary to > > load the feature? (but I have never investigated) > > Well... that turned out to be much easier than I thought. > > The BaseTest in > > https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/DiagnosticTest.java > wasn't very mysterious... > > https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/BaseTest.java > > It's just a KarafTestSupport subclass that adds a @Configuration. > > So what I did, was: > 1. Add the feaure to the feature repo option, ie change > features(modelstoreFeatureRepo) > to > features(modelstoreFeatureRepo, "modelstore.backend") > 2. Remove the following from all tests > installAndAssertFeature("modelstore.backend"); > > and then all tests went green! > > Amazing! > > Looks like I was overcomplicating things? > > Thanks all! >
Re: Custom Karaf hangs on first boot if containing folder is renamed
This is "classic", it can happen due to "mistake" in the assembly. Do you have the standard features in runtime scope (not compile scope) ? org.apache.karaf.features standard 4.2.6 features xml compile The scope is important when you create your custom distro. It's important to have pax-url before the features service. Regards JB On Fri, Mar 24, 2023 at 12:09 PM Maurice Betzel wrote: > Steven, > > > > your comment inspired me to do some more experimentation, the issue is > indeed intermittent on Linux as well. > > I could reduce it so far that if I add the upgraded feature > pax-web-http-jetty version 8.0.18 to the boot features, it hangs like > before but now also displays the following on the console: > > > > platform.bat: KARAF_LOG doesn't exist: > "C:\Users\betzm\Downloads\runtime3\bin\..\data\log" > > platform.bat: Creating "C:\Users\betzm\Downloads\runtime3\bin\..\data\log" > > Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 > > org.apache.karaf.features.core > [org.apache.karaf.features.internal.service.FeaturesServiceImpl] ERROR : > Unknown protocol: mvn > > java.net.MalformedURLException: Unknown protocol: mvn > > at java.base/java.net.URL.(URL.java:708) > > at java.base/java.net.URL.(URL.java:569) > > at java.base/java.net.URL.(URL.java:516) > > at > org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304) > > at > org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173) > > at > org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185) > > at > org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) > > at > java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) > > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) > > at java.base/java.lang.Thread.run(Thread.java:833) > > Caused by: java.lang.IllegalStateException: Unknown protocol: mvn > > at > org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:362) > > at java.base/java.net.URL.(URL.java:703) > > ... 13 more > > org.apache.karaf.features.core > [org.apache.karaf.features.internal.service.BootFeaturesInstaller] ERROR : > Error installing boot features > > java.net.MalformedURLException: Unknown protocol: mvn > > at java.base/java.net.URL.(URL.java:708) > > at java.base/java.net.URL.(URL.java:569) > > at java.base/java.net.URL.(URL.java:516) > > at > org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304) > > at > org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173) > > at > org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185) > > at > org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) > > at > org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) > > at > java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) > > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) > > at java.base/java.lang.Thread.run(Thread.java:833) > > Caused by: java.lang.IllegalStateException: Unknown protocol: mvn > > at > org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:362) > > at java.base/java.net.URL.(URL.java:703) > > ... 13 more > > > > *Van:* Steven Huypens > *Verzonden:* donderdag 23 maart 2023 18:10 > *Aan:* user@karaf.apache.org > *Onderwerp:* Re: Custom Karaf hangs on first boot if containing folder is > renamed
Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
> Steinar Bang : > No, provisioning once with @Configuration will be fine, if that > actually loads the feature I'm adding. > I just wasn't sure if @Configuration would work here, since the base > class was different, and the example didn't use it, and I have never > investigated how the setup of KarafTestSupport classes actually work. > I thought maybe the installAndAssertFeature() function was necessary to > load the feature? (but I have never investigated) Well... that turned out to be much easier than I thought. The BaseTest in https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/DiagnosticTest.java wasn't very mysterious... https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/BaseTest.java It's just a KarafTestSupport subclass that adds a @Configuration. So what I did, was: 1. Add the feaure to the feature repo option, ie change features(modelstoreFeatureRepo) to features(modelstoreFeatureRepo, "modelstore.backend") 2. Remove the following from all tests installAndAssertFeature("modelstore.backend"); and then all tests went green! Amazing! Looks like I was overcomplicating things? Thanks all!
Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
> Eric Lilja : > The reactor strategy decides if a new container should be spawned per > method or per class. If I have a bunch of different tests in the same > class, I would not want to spawn the container more than once, if I > could avoid it, since it's expensive. The provisioned bundles etc are > typically defined in the @Configuration-method, so the set of > provisioned bundles is shared by all tests, regardless of reactor > strategy. It sounds like you want to re-use the container for the > tests in a given test class but tweak the provisioning between tests, > meaning you cannot rely on the shared @Configuration-method, but have > to also provision stuff in the test themselves. No, provisioning once with @Configuration will be fine, if that actually loads the feature I'm adding. I just wasn't sure if @Configuration would work here, since the base class was different, and the example didn't use it, and I have never investigated how the setup of KarafTestSupport classes actually work. I thought maybe the installAndAssertFeature() function was necessary to load the feature? (but I have never investigated)
Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
The reactor strategy decides if a new container should be spawned per method or per class. If I have a bunch of different tests in the same class, I would not want to spawn the container more than once, if I could avoid it, since it's expensive. The provisioned bundles etc are typically defined in the @Configuration-method, so the set of provisioned bundles is shared by all tests, regardless of reactor strategy. It sounds like you want to re-use the container for the tests in a given test class but tweak the provisioning between tests, meaning you cannot rely on the shared @Configuration-method, but have to also provision stuff in the test themselves. I have never written a Pax Exam test that works like that, not sure how robust it's going to be. - Eric L On Fri, Mar 24, 2023 at 8:02 PM Steinar Bang wrote: > > Jean-Baptiste Onofré : > > > Like this one: > > > > https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/DiagnosticTest.java > > > For example, in this class we have several tests using a single Karaf > > instance (depending of the @ExamReactorStrategy(PerClass.class) > > annotation, PerClass meaning a single Karaf instance for all test > > methods in the class). > > Nice! Can I add a feature repo and an extra feature to load easily on a > class basis? > > I could do it with command line commands, I guess? > > I.e. add > executeCommand("feature:repo-add > mvn:no.priv.bang.modeling.modelstore/modelstore.backend/LATEST/xml/features"); > executeCommand("feature:install modelstore.backend"); > to all test methods? > > (it shouldn't matter much if I did in each test...? It should be a no-op > if the feature is already loaded...?) > >
Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
> Jean-Baptiste Onofré : > Like this one: > https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/DiagnosticTest.java > For example, in this class we have several tests using a single Karaf > instance (depending of the @ExamReactorStrategy(PerClass.class) > annotation, PerClass meaning a single Karaf instance for all test > methods in the class). Nice! Can I add a feature repo and an extra feature to load easily on a class basis? I could do it with command line commands, I guess? I.e. add executeCommand("feature:repo-add mvn:no.priv.bang.modeling.modelstore/modelstore.backend/LATEST/xml/features"); executeCommand("feature:install modelstore.backend"); to all test methods? (it shouldn't matter much if I did in each test...? It should be a no-op if the feature is already loaded...?)
RE: Custom Karaf hangs on first boot if containing folder is renamed
Steven, your comment inspired me to do some more experimentation, the issue is indeed intermittent on Linux as well. I could reduce it so far that if I add the upgraded feature pax-web-http-jetty version 8.0.18 to the boot features, it hangs like before but now also displays the following on the console: platform.bat: KARAF_LOG doesn't exist: "C:\Users\betzm\Downloads\runtime3\bin\..\data\log" platform.bat: Creating "C:\Users\betzm\Downloads\runtime3\bin\..\data\log" Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 org.apache.karaf.features.core [org.apache.karaf.features.internal.service.FeaturesServiceImpl] ERROR : Unknown protocol: mvn java.net.MalformedURLException: Unknown protocol: mvn at java.base/java.net.URL.(URL.java:708) at java.base/java.net.URL.(URL.java:569) at java.base/java.net.URL.(URL.java:516) at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304) at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173) at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185) at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.IllegalStateException: Unknown protocol: mvn at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:362) at java.base/java.net.URL.(URL.java:703) ... 13 more org.apache.karaf.features.core [org.apache.karaf.features.internal.service.BootFeaturesInstaller] ERROR : Error installing boot features java.net.MalformedURLException: Unknown protocol: mvn at java.base/java.net.URL.(URL.java:708) at java.base/java.net.URL.(URL.java:569) at java.base/java.net.URL.(URL.java:516) at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304) at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173) at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185) at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.IllegalStateException: Unknown protocol: mvn at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:362) at java.base/java.net.URL.(URL.java:703) ... 13 more Van: Steven Huypens Verzonden: donderdag 23 maart 2023 18:10 Aan: user@karaf.apache.org Onderwerp: Re: Custom Karaf hangs on first boot if containing folder is renamed CAUTION: This email originated from outside of Gaston Schul. Do not click links or open attachments unless you recognize the sender and know the content is safe. For what it's worth, we faced an issue which this reminded me of. We concluded that the start order of bundles with the same start level depends on the full path of each bundle. As a result, renaming the karaf folder will have an impact on the boot procedure of your Karaf distro. We experienced this on both Windows and Linux. Kind regards, Steven On Thu, Mar 23, 2023 at 5:37 PM Jean-Baptiste Onofré mailto:j...@nanthrax.net>> wrote: OK, that's what I thought: it's windows platform related issue. As Apache contributor, I should have ac
Re: Is it possible to have multiple tests in a KarafTestSupport test class, all using the same service?
Hi Steinar, Like this one: https://github.com/apache/karaf/blob/main/itests/test/src/test/java/org/apache/karaf/itests/DiagnosticTest.java For example, in this class we have several tests using a single Karaf instance (depending of the @ExamReactorStrategy(PerClass.class) annotation, PerClass meaning a single Karaf instance for all test methods in the class). Regards JB On Thu, Mar 23, 2023 at 10:11 PM Steinar Bang wrote: > > I am trying to rewrite an old pax exam test into being based on > KarafTestSupport. > > The old test fired up a karaf instance with a feature that exposes a > service, and then injected that service into the test class and used the > service in multiple @Test methods. > > However the class based on KarafTestSupport seems to only work with a > single @Test method. > > If I try to have more than one @Test methods, all tests fail with > ClassNotFoundException on the service interface. > > Is it possible to have more than one @Test method in a KarafTestSuppor > class. > > I could break up the test class into multiple test classes, but then I > would have to boot karaf once for each test class, and that's kind of > costly. > > I would prefer to boot karaf only once for all tests. > > Is it possible? > > Thanks! > > > - Steinar >