Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing throws Exception. Fixes #194 #200

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void startDatabase() throws Exception {
.withCmdOption("-u")
.withCmdOption(String.valueOf(new UnixSystem().getUid()))
.build();
postgresDB.start();
postgresDB.run();
}

@BeforeClass
Expand Down Expand Up @@ -205,6 +205,7 @@ public void dropDatabaseSchema() {
public static void tearDown() throws Exception {
// stop DB if still running and delete data directory
postgresDB.stop();
postgresDB.remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think remove() should be called from stop() and kill() medhod...as this might be source of failures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I see here is that the method called stop removes a container. That is IMHO not desired. What I have been thinking about is implementing Closable/AutoClosable interface to have a close method. Which would care about cleanup when the container is no longer needed. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found that there can be used --rm option in docker run... which causes that container is automatically removed when stopped (or killed) what about to use it and get rid of remove();

postgresDataDir.delete();
MicroProfileFaultToleranceServerConfiguration.disableFaultTolerance();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.jboss.eap.qe.ts.common.docker;

/**
* Describes public interface available for a container (not an Arquillian one but the operating system level
* virtualization unit).
*/
public interface Container {

/**
* Start a previously stopped or killed container
*/
void start() throws ContainerStartException;

/**
* Create and start new container
*
* @throws ContainerStartException thrown when start of container fails
*/
void run() throws ContainerStartException;

/**
* @return Returns true if docker container is running. It does NOT check whether container is ready.
*/
boolean isRunning();

/**
* Stop this docker container using docker command.
*
* @throws ContainerStopException thrown when the stop command fails. This generally means that the command wasn't
* successful and container might be still running.
*/
void stop() throws ContainerStopException;

/**
* Kill this docker container using docker command. Be aware that there might occur a situation when the docker
* command might fail. This might be caused for example by reaching file descriptors limit in system.
*
* @throws ContainerKillException thrown when the kill command fails.
*/
void kill() throws ContainerKillException;

/**
* Remove a container from system
*
* @throws ContainerRemoveException thrown when removing fails
*/
void remove() throws ContainerRemoveException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jboss.eap.qe.ts.common.docker;

/**
* An exception thrown when killing a container fails
*/
public class ContainerKillException extends Exception {

public ContainerKillException() {
super();
}

public ContainerKillException(String message) {
super(message);
}

public ContainerKillException(String message, Throwable cause) {
super(message, cause);
}

public ContainerKillException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.jboss.eap.qe.ts.common.docker;

public class ContainerReadyConditionException extends RuntimeException {
/**
* An exception thrown when checking for container readiness fails
*/
public class ContainerReadyConditionException extends Exception {

public ContainerReadyConditionException(String message, Throwable cause) {
super(message, cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jboss.eap.qe.ts.common.docker;

/**
* An exception thrown when container removal fails
*/
public class ContainerRemoveException extends Exception {

public ContainerRemoveException() {
super();
}

public ContainerRemoveException(String message) {
super(message);
}

public ContainerRemoveException(String message, Throwable cause) {
super(message, cause);
}

public ContainerRemoveException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jboss.eap.qe.ts.common.docker;

/**
* An exception thrown when container start fails
*/
public class ContainerStartException extends Exception {

public ContainerStartException() {
super();
}

public ContainerStartException(String message) {
super(message);
}

public ContainerStartException(String message, Throwable cause) {
super(message, cause);
}

public ContainerStartException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jboss.eap.qe.ts.common.docker;

/**
* An exception thrown when container stop fails
*/
public class ContainerStopException extends Exception {

public ContainerStopException() {
super();
}

public ContainerStopException(String message) {
super(message);
}

public ContainerStopException(String message, Throwable cause) {
super(message, cause);
}

public ContainerStopException(Throwable cause) {
super(cause);
}
}
Loading