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

Allow DockerCube to create() a container when DESTROYED #988

Closed
haster opened this issue Feb 16, 2018 · 3 comments
Closed

Allow DockerCube to create() a container when DESTROYED #988

haster opened this issue Feb 16, 2018 · 3 comments
Assignees
Milestone

Comments

@haster
Copy link

haster commented Feb 16, 2018

Issue Overview

Due to our testsetup (arquillian, junit, multi-threaded surefire) we create one (subclass of) DockerCube, representing our testcontainer, which handles a number of testclasses by repeatedly creating, starting, stopping, destroying that testcontainer. However, since #957 / #958 calling create on a destroyed DockerCube does nothing due to the state check on
https://github.com/arquillian/arquillian-cube/pull/958/files#diff-68554bf6fbadc1793c97b89f358bc69fR101

I can't think of a good reason why a destroyed container can't be recreated. Is it possible to modify the state-check so it also accepts DESTROYED when calling create() ?

If I overwrite the state value in our DockerCube subclass to set it to BEFORE_CREATE if it is DESTROYED our tests run as expected.

In essence, something like this happens:
DockerCube cube = new DockerCube();

cube.create(); // testclass 1
cube.start();
...
cube.stop();
cube.destroy();

cube.create(); // testclass 2
cube.start();
...

Expected Behaviour

Calling create() on a DESTROYED DockerCube recreates the container so that we can start() it once again.

Current Behaviour

Calling create() on a DESTROYED DockerCube does nothing, causing the subsequent start() to result in a "container not found".

Steps To Reproduce

I have no easily reproducible steps because the setup is complicated, meaning it would take time, and I think the problem is easily describable.

Additional Information

As this is more of an enhancement request I don't think any additional information is necessary, but if you would like more information please ask me 😃

@dcdh
Copy link
Contributor

dcdh commented Feb 19, 2018

I am facing the same issue.
Before #957 I was able to have multiple @RunWith(Arquillian.class) tests on the same project. It is no more the case because after the first case is done, the swarm container is DESTROYED and the property state is defined as DESTROYED in DockerCube instance.

At the next Test, when cube want to create a new swarm container the condition at the beginning of the method create() is unmet (because state is defined to DESTROYED by the previous test) and the container is no more created :(

public void create() throws CubeControlException {
        if (state != State.BEFORE_CREATE) {
            return;
        }

state is defined to State.BEFORE_CREATE only when creating a new DockerCube.

So I guess DockerCube must be recreated between each test.

Currently I keep stuck on 1.13.0

@dipak-pawar
Copy link
Contributor

@haster , @dcdh , Can you try with latest master of cube, if this issue is still reproducible?

@haster
Copy link
Author

haster commented Feb 23, 2018

I can confirm this fixes our issue 🎉

Thanks for the quick fix! 👍

@dipak-pawar dipak-pawar added this to the 1.15.3 milestone Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants