Last active
August 29, 2015 14:07
-
-
Save aslakknutsen/68c52e9b3a9ddb3d9ada to your computer and use it in GitHub Desktop.
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
<arquillian> | |
<container qualifier="wildfly"> | |
<configuration> | |
<property name="managementPort">9990</property> | |
</configuration> | |
</container> | |
<extension qualifier="docker"> | |
<property name="suiteContainers">database/postgres</property> | |
<property name="controlledByDocker">wildfly:jboss/wildfly,mail/server</property> | |
</extension> | |
</arquillian> | |
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
public class DockerObserver { | |
@Inject | |
private Instance<ArquillianDescriptor> desc; | |
@Inject | |
private Instance<ContainerRegistry> reg; | |
public void startDockerImage(@Observess(precedence = 0) BeforeSuite event) { | |
String[] dockerImageIds = getImageId(); | |
if(dockerImageIds != null) { | |
for(Stirng dockerImageId : dockerImageIds) { | |
docker.startAndWaitForPort(dockerImageId); | |
} | |
} | |
} | |
public void stopDockerImage(@Observers AfterSuite event) { | |
String[] dockerImageIds = getImageId(); | |
if(dockerImageIds != null) { | |
for(String dockerImageId : dockerImageIds) { | |
docker.stopAndWait(dockerImageId); | |
} | |
} | |
} | |
public void startDockerImage(@Observers BeforeStart event) { | |
String[] dockerImageIds = getImageIdForContainer(event.getContainer()); | |
if(dockerImageIds != null) { | |
for(Stirng dockerImageId : dockerImageIds) { | |
String port = desc.get().getContainer().getProperty("managementPort") // figure out which port the container attempts to connect to | |
docker.startAndWaitForPort(dockerImageId, port); | |
} | |
} | |
} | |
public void stopDockerImage(@Observers AfterStop event) { | |
String[] dockerImageIds = getImageIdForContainer(event.getContainer()); | |
if(dockerImageIds != null) { | |
for(String dockerImageId : dockerImageIds) { | |
docker.stopAndWait(dockerImageId); | |
} | |
} | |
} | |
public String[] getImageIdForContainer(Container c) { | |
return desc.get().getExtension().getProperty("controlledByDocker").contains(c.name()) // locate extension with name docker | |
} | |
public String[] getImageIds() { | |
return desc.get().getExtension().getProperty("suiteContainers").contains(c.name()) // locate extension with name docker | |
} | |
} |
Author
aslakknutsen
commented
Oct 22, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment