arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

Arquillian cube repeats each unit test multiple times #1105

Closed tommyb82 closed 5 years ago

tommyb82 commented 5 years ago
Issue Overview

This reflects my question on SO to which I've had zero response, so thought I'd try here.

We are using Arquillian cube with JUnit to test containerised SpringBoot microservices. This works fine, but for some reason the test harness is executing each individual test multiple times - 2, 3, sometimes 4 times each. I can see no reason for this or find anything to explain it in the docs, and it's a nuisance rather than a major problem (at the moment).

Expected Behaviour

Each arquillian-cube driven unit test executes once, not multiple times.

Current Behaviour

Each test executes multiple times on each test run

Steps To Reproduce
  1. Create a test class e.g.
@RunWith(Arquillian.class)
@RunAsClient
public class MyTests {

  @CubeIp(containerName = "test")
  private String cubeIp;

  @Test
  @InSequence(2)
  public void test1() {
    System.out.println("executing test1");
  }

  @Test
  @InSequence(2)
  public void test2() {
    System.out.println("executing test2");
  }
}
  1. With arquillian config:
    
    test:
    image: my-image:1.0
    await:
        strategy: sleeping
        sleepTime: 30 s
    portBindings: [1080->1080/tcp]
    restartPolicy:
        name: failure
        maximumRetryCount: 1
    links:
        - other-container:other-container

other-container: image: other-container:1.0 portBindings: [8080->8080/tcp] restartPolicy: name: failure maximumRetryCount: 1

The console output with this example would show repeated debug for each test. 

##### Additional Information

As can be seen, there is a second container other-container which mimics the behaviour of an upstream service. Both are started and stopped correctly. I have tried upgrading all relevant Arquillian dependencies to the latest versions, but the problem persists.

Advice on why this is happening, whether it is expected behaviour (and why) or what we might be doing wrong in our config would be appreciated.  Latest versions of arquillian-cube etc in use:
```xml
<arquillian-universe.version>1.2.0.1</arquillian-universe.version>
<arquillian-container-test-api.version>1.4.1.Final</arquillian-container-test-api.version>
<arquillian.extension.version>1.1.0.Alpha1</arquillian.extension.version>
<arquillian-cube-docker.version>1.18.2</arquillian-cube-docker.version>
dipak-pawar commented 5 years ago

Can you try removing @RunAsClient annotation? Also you can look at https://github.com/arquillian/arquillian-cube/tree/master/docker/ftest-docker-compose-v2 for reference example.

If it didn't work, Can please provide sample reproducer project, so that it will be easy for debugging?

tommyb82 commented 5 years ago

Thanks for the quick reply. I removed @RunAsClient but the test is still repeated 4 times. This is definitely not just duplicate log entries as I have added a static atomic counter to the test class and incremented and printed each time (in a single test), with the count going up to 4. Will check those docs, although we're not yet using compose config.

Without @RunAsClient we also see a warning:

WARNING: The test method "com.example.testStuff" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
tommyb82 commented 5 years ago

Will try to assemble a test sample project but it won't be for a few hours.

dipak-pawar commented 5 years ago

sure take your time. I will look into it my morning.

yomikogbe commented 5 years ago

@dipak-pawar

I have the same issue at described by @tommyb82. The defect seem to originate from
arquillian-junit-standalone executing the test cases multiple times. Are you able to look into this?

AndyGee commented 5 years ago

Is there maybe a suite defined somewhere, something like @RunWith(Suite.class)? Or is there some surefire or failsafe configuration (Maven)?

lordofthejars commented 5 years ago

I am thinking that maybe the problem is in pom.xml defining both incontainer and standalone dependencies.

Missatge de Andy Gumbrecht notifications@github.com del dia dv., 21 de des. 2018 a les 8:44:

Is there maybe a suite defined somewhere, something like @RunWith https://github.com/RunWith(Suite.class)? Or is there some surefire or failsafe configuration (Maven)?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/1105#issuecomment-449293878, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYcLSFghb50McLqcJQVxz9iKdwA9Oks5u7JFkgaJpZM4ZA2KM .

-- +----------------------------------------------------------+ Alex Soto Bueno - Computer Engineer www.lordofthejars.com +----------------------------------------------------------+

tommyb82 commented 5 years ago

Thanks @lordofthejars for the tip about the pom dependencies. We had inadvertently included <artifactId>arquillian-protocol-servlet</artifactId> which was transiently pulling in another arquillian dependency with resources that we do actually need. Now that this has been removed I am seeing tests running once, each, rather than 4 times. I shall therefore close this issue - many thanks again.