2 Replies Latest reply on Dec 15, 2018 10:42 PM by rameshsah

    Arquillian Cube : No port was specified and in all containers there are more than one bind port.

    rameshsah

      docker-compose.yml

       

       

      version: '3'

       

      services:

         fakeservice1:

         image: cicd/my-fake-service:latest

         ports:

        - "9191:8080"

         fakeservice2:

         image: cicd/my-fake-service:latest

         ports:

        - "8181:8080"

         fakeservice3:

         image: cicd/my-fake-service:latest

         ports:

        - "7171:8080"

       

       

      with docker-compose command I can see

       

       

      m-c02wt0e3htdg:arquillian-cub r0s0164$ docker-compose -f fake_service.yml up -d

       

       

      df2d61c50405        cicd/my-fake-service:latest   "java -cp app:app/li…"   About an hour ago   Up About an hour    8081/tcp, 0.0.0.0:7171->8080/tcp   arquillian-cub_fakeservice3_1

      890f86231239        cicd/my-fake-service:latest   "java -cp app:app/li…"   About an hour ago   Up About an hour    8081/tcp, 0.0.0.0:9191->8080/tcp   arquillian-cub_fakeservice1_1

      91cb29feb19e        cicd/my-fake-service:latest   "java -cp app:app/li…"   About an hour ago   Up About an hour    8081/tcp, 0.0.0.0:8181->8080/tcp   arquillian-cub_fakeservice2_1

       

       

      arquillian.xml

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <arquillian

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xmlns="http://jboss.org/schema/arquillian"

        xsi:schemaLocation="http://jboss.org/schema/arquillian

        http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

       

        <extension qualifier="docker">

       

        <property name="serverVersion">1.30</property>

        <property name="definitionFormat">COMPOSE</property>

        <property name="dockerContainersFile">fake_service.yml</property>

       

        </extension>

       

       

      </arquillian>

       

       

      When I run arquillian tests I am getting error as below. I am sure I am missing some configuration, would appreciate if one could help me with this.

       

       

       

       

      java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:165)

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:102)

      at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)

      at org.jboss.arquillian.testng.Arquillian.arquillianBeforeSuite(Arquillian.java:70)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.base/java.lang.reflect.Method.invoke(Method.java:564)

      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)

      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)

      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)

      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)

      at org.testng.SuiteRunner.run(SuiteRunner.java:240)

      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)

      at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)

      at org.testng.TestNG.run(TestNG.java:1031)

      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)

      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)

      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

      Caused by: java.lang.reflect.InvocationTargetException

      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

      at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

      at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:161)

      ... 21 more

      Caused by: java.lang.IllegalArgumentException:

       

       

       

      at org.arquillian.cube.docker.impl.util.SinglePortBindResolver.resolvePortBindPort(SinglePortBindResolver.java:161)

      at org.arquillian.cube.docker.impl.util.SinglePortBindResolver.resolveBindPort(SinglePortBindResolver.java:113)

      at org.arquillian.cube.docker.restassured.RestAssuredCustomizer.configureRequestSpecBuilder(RestAssuredCustomizer.java:57)

      at org.arquillian.cube.docker.restassured.RestAssuredCustomizer.configure(RestAssuredCustomizer.java:38)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.base/java.lang.reflect.Method.invoke(Method.java:564)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

      at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:265)

      at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)

      at org.arquillian.cube.docker.restassured.RestAssuredConfigurator.configure(RestAssuredConfigurator.java:17)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.base/java.lang.reflect.Method.invoke(Method.java:564)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

      at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:265)

      at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)

      at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:60)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.base/java.lang.reflect.Method.invoke(Method.java:564)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

      at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:290)

      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:63)

      ... 26 more

        • 1. Re: Arquillian Cube : No port was specified and in all containers there are more than one bind port.
          rameshsah

          I was debugging the port issue and I found that at one point method below is getting called

           

           

          /**

               * Method that tries to resolve a bind port by searching if there is only one binding port across all running

               * containers

               *

               * @param cubeDockerConfiguration

               *     where all docker configuration is exposed

               * @param excludedContainers

               *     where binding port search is ignored

               *

               * @return binding port

               */

              public static PortBindInfo resolvePortBindPort(CubeDockerConfiguration cubeDockerConfiguration,

                  String... excludedContainers) {

           

                  final DockerCompositions dockerContainersContent = cubeDockerConfiguration.getDockerContainersContent();

                  final Set<Map.Entry<String, CubeContainer>> containers = dockerContainersContent.getContainers().entrySet();

           

                  //if no port, we check if there is only one cube with one bind port and if not, return default one

           

                  PortBindInfo portBindInfo = null;

                  for (Map.Entry<String, CubeContainer> cubeContainerEntry : containers) {

           

                      // need to skip excluded containers

                      if (shouldBeIgnored(cubeContainerEntry.getKey(), excludedContainers)) {

                          continue;

                      }

           

                      final CubeContainer cubeContainer = cubeContainerEntry.getValue();

                      if (hasMoreThanOneBindPort(cubeContainer)) {

                          throw new IllegalArgumentException("No port was specified and a container has more than one bind port.");

                      }

           

                      if (hasOnlyOneBindPort(cubeContainer)) {

                          if (noPreviousBindPortFound(portBindInfo)) {

                              final PortBinding portBinding = cubeContainer.getPortBindings()

                                  .iterator().next();

                              int bindPort = portBinding.getBound();

                              int exposedPort = portBinding.getExposedPort().getExposed();

                              portBindInfo = new PortBindInfo(exposedPort, bindPort, cubeContainerEntry.getKey());

                          } else {

                              throw new IllegalArgumentException(

                                  "No port was specified and in all containers there are more than one bind port.");

                          }

                      }

                  }

           

          since i have multiple images in my compose file its going through the for loop and first iteration is fine. I noticed that during second iteration line below is false  because portBindInfo has a valid value

           

             if (noPreviousBindPortFound(portBindInfo))

           

          as a result exception is thrown.

          • 2. Re: Arquillian Cube : No port was specified and in all containers there are more than one bind port.
            rameshsah

            It turns out that I needed below in my arquillian.xml file to get the restAssured initialized correctly,

             

             

            <extension qualifier="restassured">

              <property name="port">1000</property>

              </extension>