Search code examples
dockerwildflyjboss-arquillian

Configure Wildfly in Docker so that Arquillian can deploy to it


I would like to create Arquillian tests that run on a Wildfly server in a Docker container.

Step 1: let's keep it simple, and leave Docker out of the picture

I have written Arquillian tests that deploy on a remote Wildfly.

When I set up an unchanged, empty, standalone Wildfly server, Arquillian deploys the tests + dependent ears and then they run without any issue. Awesome!

Step 2 (here comes the problem): let's replace the local Wildfly with a containerized Wildfly

The next step is to put Wildfly in a Docker container, and let my Arquillian tests run on that containerised Wildfly. As far as I can tell, I have to make sure that

  • the right ports are open, more specifically 8080
  • there is an administrator user configured, which Arquillian can use to do deployments

I think I have done that correctly. When I run my Docker image,

  • I get an empty Wildfly,
  • which I can reach on localhost:8080 (Welcome to Wildlfly screen)
  • and localhost:9990 (administrator console, I can log in as administrator)

When I run the tests, I get

Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

Weird, since I can get in the browser to the management console just fine.

Does anyone see my oversight? Did I forget anything?

Docker-compose.yml

version: '2'
services:
  arquillian-cube-wildfly-test:
    build: .
    ports:
      - "8080:8080"
      - "9990:9990"
      - "8787:8787"

Dockerfile

# Base image: Wildfly 10 with 8080 port exposed
FROM jboss/wildfly:10.1.0.Final

# Open management port
EXPOSE 9990
EXPOSE 8787

# Add management user with password
RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent

# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

The test project

Check out https://github.com/stainii/arquillian-cube-and-multiple-deployments-experiment. It's a multi-module Maven project, containing

  • first-webapp (dummy project, which will be tested by the tests)
  • second-webapp (dummy project, which will be tested by the tests)
  • integration-tests (the project that contains the tests)

To run this:

  1. start up the Docker container by going to src/test/resources/wildfly, and execute docker-compose up.
  2. Build the project and start the tests with mvn clean dependency:copy-dependencies install. The 2 webapps will be built, their ears will be copied to the target of the test project, and the Arquillian tests will deploy these ears and run tests.

Solution

  • There are two issues in your projects.

    1.Wrong configuration in arquillian.xml. Check https://git.io/vNaYu for correct configuration of arquillian.xml

    2.You are using old version of arquillian-container in your profile arq-widlfly-remote. It should be

    <dependency>
      <groupId>org.wildfly.arquillian</groupId>
      <artifactId>wildfly-arquillian-container-remote</artifactId>
      <version>2.0.0.Final</version>
      <scope>test</scope>
    </dependency>