Last active
November 11, 2015 22:15
-
-
Save lucmolinari/7bcdd1f36d7c0e08822f to your computer and use it in GitHub Desktop.
Using arquillian with Docker without any extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have a test project which main purpose is to test our software running in clustered environments. | |
For this, we have a set of containers defined as mode="manual". We extensively use | |
ContainerController and Deployer APIs to start/stop containers and deploy/undeploy applications. | |
This works fine in the jboss-as-arquillian-container-managed environemt. | |
Now we're working on a POC to use Docker in these tests. The idea is to use | |
jboss-as-arquillian-container-remote adapter and, in our code, instead of using the | |
ContainerController to start/stop the container, we'd use docker-java API. We've been able to start | |
the container as expected, but the the Deployer API can not deploy the app because it thinks the | |
container is not running. | |
java.lang.IllegalArgumentException: Deployment with name MyTestDeployment could not be deployed. | |
Container jboss_manual_managed must be started first. | |
at com.package.MyWARTest.deploy_package(MyWARTest.java:153) | |
I can see that this exception is thrown by ClientDeployer:89, as it queries some local registry to | |
check container's status and it doesn't really check whether the container is running or not. | |
Is this the expected behaviour or shoud this API check directly in the container whether it's | |
running or not? | |
Basic code: | |
@RunWith(Arquillian.class) | |
public class MyWARTest { | |
private static final String DEPLOYMENT_1 = "MyTest_d1"; | |
private static final String SERVER = "jboss_manual_managed"; | |
@ArquillianResource | |
private Deployer deployer; | |
... | |
@Deployment(name = DEPLOYMENT_1, managed = false) | |
@TargetsContainer(SERVER) | |
public static Archive<?> createTestArchive1() { | |
//create WAR archive | |
} | |
@Test | |
@InSequence(1) | |
@RunAsClient | |
public void start_container() { | |
//code using docker-java to start my images, add links, port forwarding, etc | |
//it works as expected, I can even access the container from the browser | |
} | |
@Test | |
@InSequence(2) | |
public void deploy_package() { | |
this.deployer.deploy(DEPLOYMENT_1); //It fails here | |
} | |
We have just one image with JBoss and this image is started/stopped multiple times in different | |
test cases and with different configurations (-c, JVM properties,..), that's why it seems to be | |
easier to control them from the Java code instead of using some extension, like Cube. |
I removed the mode="manual" from arquillian.xml and, along with some other fixes, it seems to be working now. I didn't check the code, but it looks like the verification regarding the container is running or not is just performed by ClientDeployer when mode="manual".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A sample project can be found at: https://github.com/lucmolinari/arquillian-docker-manual-cluster
Before running, create the image "test_wildfly" with the command (from the project root):
docker build -t "test_wildfly" .
This is a basic wildfly image with an user.
Then, just run the project mvn clean install.
In my case I'm using JBoss-EAP but this project is based on Wildfly for sake of simplicity.