arquillian / arquillian-cube

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

Setting TO property as existing file in copy action makes cube throws exception #126

Closed mgreau closed 9 years ago

mgreau commented 9 years ago

The same arquillian.xml configuration works for Ubuntu but fails with boot2docker. The arquillian.xml configuration is below :

<property name="dockerContainers">
            wildfly82:
              image: asciidoctor/asciidoctorj-wildfly:latest
              await:
                strategy: polling
                sleepPollingTime: 50000
                iterations: 5
              beforeStop:
                - copy:
                    from: /tmp/documents
                    to: /tmp
              portBindings: [8081->8080/tcp, 9991->9990/tcp]
        </property>

In order to reproduce the problem :

The error log :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project docker-asciidoctorj: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: java.lang.RuntimeException: Could not run @AfterSuite
[ERROR] at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:213)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:133)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] Caused by: java.lang.RuntimeException: Could not run @AfterSuite
[ERROR] at org.jboss.arquillian.junit.Arquillian$1.shutdown(Arquillian.java:158)
[ERROR] at org.jboss.arquillian.junit.Arquillian$1.testRunFinished(Arquillian.java:132)
[ERROR] at org.junit.runner.notification.RunNotifier$2.notifyListener(RunNotifier.java:95)
[ERROR] at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:61)
[ERROR] at org.junit.runner.notification.RunNotifier.fireTestRunFinished(RunNotifier.java:92)
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:131)
[ERROR] ... 3 more
[ERROR] Caused by: org.arquillian.cube.spi.CubeControlException: Could not stop wildfly82
[ERROR] at org.arquillian.cube.spi.CubeControlException.failedStop(CubeControlException.java:27)
[ERROR] at org.arquillian.cube.impl.model.DockerCube.stop(DockerCube.java:104)
[ERROR] at org.arquillian.cube.impl.client.CubeLifecycleController.stop(CubeLifecycleController.java:23)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[ERROR] at org.arquillian.cube.impl.client.container.CubeContainerLifecycleController.stopCubeMappedContainer(CubeContainerLifecycleController.java:77)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[ERROR] at org.jboss.arquillian.container.impl.ContainerImpl.stop(ContainerImpl.java:226)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$9.perform(ContainerLifecycleController.java:178)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$9.perform(ContainerLifecycleController.java:172)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:255)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.stopContainer(ContainerLifecycleController.java:171)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$4.perform(ContainerLifecycleController.java:107)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$4.perform(ContainerLifecycleController.java:100)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forEachSuiteContainer(ContainerLifecycleController.java:221)
[ERROR] at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.stopSuiteContainers(ContainerLifecycleController.java:99)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[ERROR] at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:91)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
[ERROR] at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.afterSuite(EventTestRunnerAdaptor.java:80)
[ERROR] at org.jboss.arquillian.junit.Arquillian$1.shutdown(Arquillian.java:145)
[ERROR] ... 8 more
[ERROR] Caused by: java.nio.file.FileAlreadyExistsException: /tmp
[ERROR] at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88)
[ERROR] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
[ERROR] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
[ERROR] at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:383)
[ERROR] at java.nio.file.Files.createDirectory(Files.java:674)
[ERROR] at java.nio.file.Files.createAndCheckIsDirectory(Files.java:778)
[ERROR] at java.nio.file.Files.createDirectories(Files.java:727)
[ERROR] at org.arquillian.cube.impl.docker.DockerClientExecutor.copyFromContainer(DockerClientExecutor.java:546)
[ERROR] at org.arquillian.cube.impl.client.BeforeStopContainerObserver.processCommands(BeforeStopContainerObserver.java:33)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:483)
[ERROR] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[ERROR] at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
[ERROR] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
[ERROR] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[ERROR] at org.arquillian.cube.impl.model.DockerCube.stop(DockerCube.java:98)
[ERROR] ... 84 more
[ERROR] -> [Help 1]
[ERROR] 
lordofthejars commented 9 years ago

I don't know what is your opinion but I think this is a bug of maybe JVM or in your system. Look that javadoc of java.nio.file.Files.createDirectories:

Creates a directory by creating all nonexistent parent directories first. Unlike the createDirectory method, an exception is not thrown if the directory could not be created because it already exists.

Throws:
FileAlreadyExistsException - if dir exists but is not a directory (optional specific exception)

So in my mind comes next possibilities: the first one a bug on JVM and the second one that in your computer there is a file called tmp in root that it is not a directory.

Don't know if you have any other idea.

aslakknutsen commented 9 years ago

@mgreau You running boot2docker on Ubuntu? or Mac/Windows?

mgreau commented 9 years ago

boot2docker on Mac

lordofthejars commented 9 years ago

I will try it as well but watching the javadoc of the method it doesn't seems that it is something related with boot2docker

mgreau commented 9 years ago

Ok I think that I found the problem. It seems that boot2docker creates a symbolic link named tmp :

ls -al /
 lrwxr-xr-x@  1 root  wheel     11 16 nov 13:44 tmp -> private/tmp
drwxr-xr-x@ 11 root  wheel    374 16 nov 13:54 usr
lrwxr-xr-x@  1 root  wheel     11 16 nov 13:45 var -> private/var

If I rename tmp to tmp2, boot2docker doesn't start so my /tmp example is not a good idea :)

aslakknutsen commented 9 years ago

We could make a more controlled check there;

if file.exists() && file.isFile() throw IllegalArgumentException("some detailed reason why")

We should probably verify this up front and fail before everything runs.. (tho the state might have changed since we checked it in Before so we should check again to fail controlled right before we try to do it :))

lordofthejars commented 9 years ago

hehe right then let's do what Aslak mention for avoiding this problem I only thought about alraedy existing directories but not that a directory could be a file. Ok I am going to fix it :)

Thank you both of you.

lordofthejars commented 9 years ago

The same applies to copy from log