cloudstateio / kotlin-support

Cloudstate Kotlin Support
https://cloudstate.io/docs/user/lang/kotlin/index.html
Apache License 2.0
8 stars 5 forks source link

io.cloudstate.kotlinsupport.tests.IntegrationTest fails #20

Closed vkorenev closed 4 years ago

vkorenev commented 4 years ago

Right now this test is skipped by maven-surefire-plugin because the class is named IntegrationTests while the plugin looks for classes ending with Test. However if the test class is renamed to IntegrationTest, the test fails:

Running io.cloudstate.kotlinsupport.tests.IntegrationTest
[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy from ~/.testcontainers.properties, will try it first
[main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=unix:///var/run/docker.sock
[main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
[main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 19.03.8
  API Version: 1.40
  Operating System: Ubuntu 20.04 LTS
  Total Memory: 32110 MB
[main] INFO org.testcontainers.DockerClientFactory - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[main] INFO org.testcontainers.DockerClientFactory - Checking the system...
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker environment should have more than 2GB free disk space
[main] INFO 🐳 [sleipnir/shopping-cart:latest] - Creating container for image: sleipnir/shopping-cart:latest
[main] INFO 🐳 [sleipnir/shopping-cart:latest] - Starting container with ID: 8c8b6589dfc5c8bf6d6fda748fc265899841f417771091583f0cf5fa1ab46353
[main] INFO 🐳 [sleipnir/shopping-cart:latest] - Container sleipnir/shopping-cart:latest is starting: 8c8b6589dfc5c8bf6d6fda748fc265899841f417771091583f0cf5fa1ab46353
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: SLF4J: Class path contains multiple SLF4J bindings.
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: SLF4J: Found binding in [jar:file:/app/libs/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: SLF4J: Found binding in [jar:file:/app/libs/slf4j-simple-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDOUT: 01:09:39.614 [main] DEBUG io.cloudstate.kotlinsupport.initializers.CloudStateInitializer - Initializing ByteBuddy Agent....
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: Exception in thread "main" java.lang.NoClassDefFoundError: net/bytebuddy/agent/ByteBuddyAgent
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at io.cloudstate.kotlinsupport.initializers.CloudStateInitializer.<init>(CloudStateInitializer.kt:18)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at io.cloudstate.kotlinsupport.CloudstateKt.cloudstate(Cloudstate.kt:8)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at com.example.shoppingcart.MainKt.main(Main.kt:10)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at com.example.shoppingcart.MainKt.main(Main.kt)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR: Caused by: java.lang.ClassNotFoundException: net.bytebuddy.agent.ByteBuddyAgent
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
[tc-okhttp-stream-774362927] INFO io.cloudstate.kotlinsupport.tests.IntegrationTest - STDERR:   ... 4 more
[main] ERROR 🐳 [sleipnir/shopping-cart:latest] - Could not start container
java.lang.IllegalStateException: Container exited with code 1
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:457)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:317)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:315)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:302)
    at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:1008)
    at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
[main] ERROR 🐳 [sleipnir/shopping-cart:latest] - Log output from the failed container:
SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/app/libs/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/app/libs/slf4j-simple-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

01:09:39.614 [main] DEBUG io.cloudstate.kotlinsupport.initializers.CloudStateInitializer - Initializing ByteBuddy Agent....

Exception in thread "main" java.lang.NoClassDefFoundError: net/bytebuddy/agent/ByteBuddyAgent

    at io.cloudstate.kotlinsupport.initializers.CloudStateInitializer.<init>(CloudStateInitializer.kt:18)

    at io.cloudstate.kotlinsupport.CloudstateKt.cloudstate(Cloudstate.kt:8)

    at com.example.shoppingcart.MainKt.main(Main.kt:10)

    at com.example.shoppingcart.MainKt.main(Main.kt)

Caused by: java.lang.ClassNotFoundException: net.bytebuddy.agent.ByteBuddyAgent

    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)

    ... 4 more

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 62.909 sec <<< FAILURE!
Validate User Function Contract(io.cloudstate.kotlinsupport.tests.IntegrationTest)  Time elapsed: 62.1 sec  <<< ERROR!
org.testcontainers.containers.ContainerLaunchException: Container startup failed
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:322)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:302)
    at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:1008)
    at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:315)
    ... 25 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:485)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:317)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    ... 26 more
Caused by: java.lang.IllegalStateException: Container exited with code 1
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:457)
    ... 28 more

Results :

Tests in error: 
  Validate User Function Contract(io.cloudstate.kotlinsupport.tests.IntegrationTest): Container startup failed
sleipnir commented 4 years ago

Hi @vkorenev It seems to me that you have the image cached locally, try to delete that image and run the tests again. I just now uploaded the correct image to the Docker Hub to fix a problem in running the Cloudstate repository TCK

vkorenev commented 4 years ago

The image in my cache is definitely very old :-D

sleipnir/shopping-cart           latest       5441905b00e3        50 years ago    558MB
sleipnir commented 4 years ago

The log should present messages similar to those here if it is downloading from the repository:

[main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
[main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 19.03.6
  API Version: 1.40
  Operating System: CentOS Linux 7 (Core)
  Total Memory: 15568 MB
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Starting to pull image
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  0 pending,  0 downloaded,  0 extracted, (0 bytes/0 bytes)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  2 pending,  1 downloaded,  0 extracted, (2 MB/? MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  1 pending,  2 downloaded,  0 extracted, (2 MB/? MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  0 pending,  3 downloaded,  0 extracted, (2 MB/4 MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  0 pending,  3 downloaded,  1 extracted, (4 MB/4 MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  0 pending,  3 downloaded,  2 extracted, (4 MB/4 MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pulling image layers:  0 pending,  3 downloaded,  3 extracted, (4 MB/4 MB)
[tc-okhttp-stream-1249337777] INFO org.testcontainers.DockerClientFactory - Pull complete. 3 layers, pulled in 1s (downloaded 4 MB at 4 MB/s)
[main] INFO org.testcontainers.DockerClientFactory - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[main] INFO org.testcontainers.DockerClientFactory - Checking the system...
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
vkorenev commented 4 years ago

It would be nice if this test built the image from the current sources instead of relying on a pre-uploaded image.

sleipnir commented 4 years ago

in this case we would only have to run the proxy via "test containers" and the user's function would run in the test itself. I think it's cool that we deal with this in a new issue