microcks / microcks-quarkus

Quarkus extension that enables embedding Microcks as a DevService managing mocks for dependencies and contract-testing your API endpoints
https://microcks.io
Apache License 2.0
15 stars 3 forks source link

Can't start quarkus 3.4.3 #10

Closed edeandrea closed 12 months ago

edeandrea commented 12 months ago

Describe the bug

I'm trying to use this extension as described but Quarkus dev mode does not start up.

Expected behavior

No response

Actual behavior

When I add this extension (version 0.1.1) to a Quarkus 3.4.3 project, dev mode fails to start with the following message:

2023-10-23 14:32:32,576 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor#startMicrocksContainers threw an exception: java.lang.RuntimeException: java.lang.IllegalArgumentException
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalArgumentException
        at org.testcontainers.shaded.com.trilead.ssh2.Connection.requestRemotePortForwarding(Connection.java:1317)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:72)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:66)
        at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:14)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:228)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:336)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:253)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:113)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:438)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor#startMicrocksContainers threw an exception: java.lang.RuntimeException: java.lang.IllegalArgumentException
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalArgumentException
        at org.testcontainers.shaded.com.trilead.ssh2.Connection.requestRemotePortForwarding(Connection.java:1317)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:72)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:66)
        at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:14)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:228)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more

        at io.quarkus.builder.Execution.run(Execution.java:123)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:332)
        ... 9 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalArgumentException
        at org.testcontainers.shaded.com.trilead.ssh2.Connection.requestRemotePortForwarding(Connection.java:1317)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:72)
        at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:66)
        at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:14)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:228)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more

How to Reproduce?

I added the extension to my pom.xml and then started dev mode and saw the error.

I also tried to configure it to use a postman collection, but that didn't change anything.

Microcks version or git rev

0.1.1

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

No response

Additional information

No response

lbroudoux commented 12 months ago

Thanks Eric for opening this one.

Looks like this is related to the way we retrieve/set the Quarkus test port as being accessible from the testcontainers. I'll have a look at it on tomorrow.

edeandrea commented 12 months ago

Thanks @lbroudoux!

For context - I'm working on a new microservice in the Quarkus superheroes sample and integrating that service into the rest of the mix. This new service is gRPC-based, so I'm trying to follow this guide so that the consuming service can use Microcks in dev mode/tests to serve example responses correctly.

I have the gRPC service written and defined already (https://github.com/edeandrea/quarkus-super-heroes/tree/location-service/grpc-locations).

edeandrea commented 12 months ago

Happy to push code up to my feature branch if you need/want to look at it.

lbroudoux commented 12 months ago

Yes, please. So that I'll have context and starting point for diving in tomorrow.

edeandrea commented 12 months ago

Ok I've pushed everything up to my feature branch. Everything requires Java 17 as a minimum.

If you start grpc-locations in dev mode, then start rest-fights in dev mode, you should be able to make a request to http://localhost:8082/api/fights/hello/locations to get a round-trip response (http client -> rest-fights -> grpc-locations).

I'm trying to get Microcks to simulate grpc-locations so that you don't need grpc-locations running, either when running rest-fights in dev mode or when running tests.

github-actions[bot] commented 12 months ago

๐Ÿ‘‹ @edeandrea

Welcome to the Microcks community! ๐Ÿ’–

Thanks and congrats ๐ŸŽ‰ for opening your first issue here! Be sure to follow the issue template or please update it accordingly.

๐Ÿ“ข If you're using Microcks in your organization, please add your company name to this list. ๐Ÿ™ It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community ๐Ÿ™Œ"

Hope you have a great time there!

๐ŸŒŸ ~~~~~ ๐ŸŒŸ

๐Ÿ“ข If you like Microcks, please โญ star โญ our repo to support it!

๐Ÿ™ It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

edeandrea commented 12 months ago

If I comment out quarkus.http.test-port=0 in the application.properties file I can get a little bit futher (but it still fails). We use quarkus.http.test-port=0 to assign random ports when running tests.

But when removing that I see this:

Microcks Dev Services Starting: 15:36:22 ERROR [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Could not start container: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1      at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)       at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)   at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)   at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)      at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:242)    at java.base/java.util.Optional.orElseGet(Optional.java:364)        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)     at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568)   at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)    at io.quarkus.builder.BuildContext.run(BuildContext.java:282)   at o
--
Microcks Dev Services Starting: 15:36:22 ERROR [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Log output from the failed container:exec java -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnO15:35:12 INFO  [tc.te.5.1] (build-28) Creating container for image: testcontainers/ryuk:0.5.1ential-osxkeychain) does not have credentials for https://index.docker.io/v1/
15:35:12 INFO  [tc.te.5.1] (build-28) Container testcontainers/ryuk:0.5.1 is starting: 1bd4053e11adbfd33dcd7caf360cb5fb3e5823b2b01648a6cf5f2eb4872f0c56
15:35:12 INFO  [tc.te.5.1] (build-28) Container testcontainers/ryuk:0.5.1 started in PT0.225646S
15:35:12 INFO  [tc.te.1.0] (build-28) Container testcontainers/sshd:1.1.0 is starting: 5ef8c1d3d690e2e79a10ceed1601d7e77fe1b4afb7f3fecd76e2e9ae6125eedd
15:35:12 INFO  [tc.te.1.0] (build-28) Container testcontainers/sshd:1.1.0 started in PT1.160514S
15:35:12 INFO  [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Pulling docker image: quay.io/microcks/microcks-uber:nightly. Please be patient; this may take some time but only needs to be done once.
15:35:21 INFO  [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Creating container for image: quay.io/microcks/microcks-uber:nightly
15:35:21 INFO  [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Container quay.io/microcks/microcks-uber:nightly is starting: 7a6ed84163240b6ab1237ce33f2708cf7e9ea2c628a00b93f6671c7077b86af9
15:36:22 ERROR [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Could not start container: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:242)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*Started MicrocksApplication.*'
        at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
        at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
        at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
15:36:22 ERROR [tc.qu.io/microcks/microcks-uber:nightly] (build-28) Log output from the failed container:
exec java -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.1)

19:35:22.735  INFO 1 --- [      main] i.g.microcks.MicrocksApplication         : Starting MicrocksApplication using Java 17.0.9 with PID 1 (/deployments/app.jar started by ? in /deployments)
19:35:22.737 DEBUG 1 --- [      main] i.g.microcks.MicrocksApplication         : Running with Spring Boot v3.1.1, Spring v6.0.10
19:35:22.738  INFO 1 --- [      main] i.g.microcks.MicrocksApplication         : The following 1 profile is active: "uber"
19:35:23.935  WARN 1 --- [      main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server
19:35:23.959 ERROR 1 --- [      main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
        at io.github.microcks.MicrocksApplication.main(MicrocksApplication.java:38)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to /tmp
        at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:232)
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:195)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161)
        ... 16 common frames omitted
Caused by: java.nio.file.FileSystemException: /tmp/tomcat.8080.12988783133663200020: No space left on device
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:397)
        at java.base/java.nio.file.Files.createDirectory(Files.java:700)
        at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:134)
        at java.base/java.nio.file.TempFileHelper.createTempDirectory(TempFileHelper.java:171)
        at java.base/java.nio.file.Files.createTempDirectory(Files.java:1017)
        at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:226)
        ... 19 common frames omitted

2023-10-23 15:36:22,565 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2023-10-23 15:36:22,717 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor#startMicrocksContainers threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:242)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more
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:334)
        ... 16 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        ... 17 more
Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)
        ... 19 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*Started MicrocksApplication.*'
        at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
        at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
        at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
        ... 19 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:336)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:253)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:113)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:438)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor#startMicrocksContainers threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:242)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more
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:334)
        ... 16 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        ... 17 more
Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)
        ... 19 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*Started MicrocksApplication.*'
        at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
        at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
        at org.testcontainers.containers.GenericContainer.waitUntilerStarted(GenericContainer.java:964)
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
        ... 19 more

        at io.quarkus.builder.Execution.run(Execution.java:123)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:332)
        ... 9 more
Caused by: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:153)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/microcks/microcks-uber:nightly
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.lambda$startContainer$1(DevServicesMicrocksProcessor.java:242)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startContainer(DevServicesMicrocksProcessor.java:282)
        at io.github.microcks.quarkus.deployment.DevServicesMicrocksProcessor.startMicrocksContainers(DevServicesMicrocksProcessor.java:139)
        ... 11 more
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:334)
        ... 16 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        ... 17 more
Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)
        ... 19 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*Started MicrocksApplication.*'
        at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
        at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
        at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
        ... 19 more
edeandrea commented 12 months ago

Aha and I think I found the cause of that error. I had docker compose up'ed the microcks system in another terminal while I was playing with it :)

So now I have everything up!

So I think the problem that needs to be solved is with being able to set quarkus.http.test-port=0 so that I can use a random port.

image

edeandrea commented 12 months ago

I also think another issue is how to then configure the gRPC client to use the dev service.

For example, then the dev service starts it outputs

quarkus.microcks.default.grpc=http://127.0.0.1:60577
quarkus.microcks.default.http=http://127.0.0.1:60576

The issue with gRPC is that the client has separate configuration elements for the host and port (see https://github.com/edeandrea/quarkus-super-heroes/blob/location-service/rest-fights/src/main/resources/application.properties#L27-L28)

quarkus.grpc.clients.locations.host=127.0.0.1
quarkus.grpc.clients.locations.port=60577

So I'm not sure how my app will get configured properly with the correct host/port so that the dev service actually serves proper responses.

lbroudoux commented 12 months ago

Thanks for your tests and for sharing your findings Eric!

It would make sense to publish 2 additional properties from the DevServices so that you could use quarkus.microcks.default.grpc.host and quarkus.microcks.default.grpc.port. TBH, I was not sure how the grpc property was supposed to be consumed as I never wrote a grpc client in Quakus ๐Ÿ˜‰

I'm gonna search if and how we could retrieve that randomly assigned test port.

edeandrea commented 12 months ago

Thanks! To be honest this is my first time with gRPC as well, so I'm learning too!

What do you need the randomly assigned port for?

I did notice a couple other things too.

1) in the dev ui I can see the tile for Microcks, but when I click the link it opens a blank page. To find the Microcks dashboard I have to go back through the app's console output and find the URL.

2) How do I interact with the mock service? I have an example that shows up in the dashboard, but even using something like postman I can't seem to hit the exposed service on Microcks.

lbroudoux commented 12 months ago

For the randomly generated test port, I need to know if it is stored within a specific property. For the moment, we use

int testPort = globalConfig.getValue("quarkus.http.test-port", OptionalInt.class).orElse(8081);

but it looks that this property has still the 0 value once random port assigned. Maybe I have to look for something like: quarkus.http.test-port.resolved ;-)

  1. Hum ... looks like it is working on my side but on a Quarkus 3.2.3 app. I mean directly accessing the Microcks dashboard from the Quakus Dev UI tile.
  2. Just reusing the quarkus.microcks.default.http from my client, or browser, or curl command... I have configured my Rest client to use this url here: https://github.com/microcks/api-lifecycle/blob/master/shift-left-demo/quarkus-order-service/src/main/resources/application.properties#L10

Just starting working on this, I had some other duties this morning...

edeandrea commented 12 months ago

Your help is much appreciated!

For the dev ui thing, here are a few screenshots...

I see this when I open the dev ui:

image

But when I click "Microcks UI" I don't see anything

image

I have to go back to my dev mode console to find the url:

Screenshot 2023-10-24 at 8 52 42โ€ฏAM

I grabbed quarkus.microcks.default.grpc (in my case http://localhost:59397) and tried to use grpcurl:

โ•ฐโ”€ grpcurl -plaintext -proto src/main/proto/locationservice-v1.proto localhost:59397 io.quarkus.sample.superheroes.location.v1.Locations/Hello
Failed to dial target host "localhost:59397": context deadline exceeded

This is what I see when I go into the Microcks UI:

image

image

I notice that it has a completely different Mock URL, but that still doesn't work when I try to grpcurl it. In fact, the port has a -grpc, which isn't valid at all.

lbroudoux commented 12 months ago

Ok thanks for the screenshots.

I have created #11 to track the stuff regarding gRPC configuration. Does it look ok for you? I could push this in a few minutes.

edeandrea commented 12 months ago

Looks good to me!

Why does the microcks Testcontainer care what port the application is running on? Why is the test port even needed? Its not used/needed in any of the other dev services i'm using (Kafka, mongo, apicurio, etc). At least not that I'm aware of :)

lbroudoux commented 12 months ago

We need this port only for the contract-testing part (it is not used for mocking). When launching a contract test, Microcks is using the HTTP endpoint your Quarkus application is launched on ; what's why we need to open a route to this localhost port from within the Microcks container.

lbroudoux commented 12 months ago

Sorry for the troubles, digging further...

edeandrea commented 12 months ago

gRPC stuff does not seem to work either.

Happy to work with you on this using my new app as a test bed to get it to work!

lbroudoux commented 12 months ago

I found that the gRPC problem is bigger than what I was expecting. See https://github.com/microcks/microcks/issues/950 A patch is on its way though.

lbroudoux commented 12 months ago

๐ŸŽ‰ The new quay.io/microcks/microcks-uber:nightly now contains the fix for gRPC server startup. I succeed making a gRPC call from Postman to the Microcks container launched by the DevService in version 0.1.1!

I'm now having a look at the Dev UI integration but I suspect it to be a browser issue as I can see a blocked request to the quarkus.microcks.default.http URL in the developer tools... Trying it with different browsers... but maybe latest security updates have restricted some usages of iframes ...

In fact, the port has a -grpc, which isn't valid at all.

That is just a UI glitch. I think it has to be adapted to this situation where gRPC port is randomly assigned.

edeandrea commented 12 months ago

How did you get it to work? I set quarkus.microcks.devservices.image-name=quay.io/microcks/microcks-uber:nightly so it picked up the nightly image. I'm also using the 0.1.2-SNAPSHOT of the dev service.

I see this in the dev ui

image

But I can't seem to make a call with Postman. I'm getting CANCELLED

image

lbroudoux commented 12 months ago

Hey Eric! I found the issue regarding the embedding of Microcks UI in Quarkus Dev UI. I've opened an issue here to track it: https://github.com/microcks/microcks/issues/952

edeandrea commented 12 months ago

Awesome! Thank you!

I still can't seem to get the Microcks dev service to be able to serve gRPC requests though (as per my comment above).

lbroudoux commented 12 months ago

Hey! Good morning Eric!

So quay.io/microcks/microcks-uber:nightly new revision contains both the fix for gRPC and the fix for having the Microcks UI embedded into Quarkus Dev UI.

I have also committed here: https://github.com/microcks/api-lifecycle/commit/7348e4c2da80e51ead748e131aafce53dac7edbb additional files for checking gRPC calls on mocks provided by the dev service. Once the additional proto, postman collection and metadata files are referenced in application.properties, I'm then able to do a successful gRPC call on the port provided by Microcks.

See my Postman client below:

Capture dโ€™eฬcran 2023-10-25 aฬ€ 14 05 51

If you can check this and let me know if you're still stuck. Maybe it could be efficient to setup a GMeet or Zoom to finalize this.

edeandrea commented 12 months ago

It must be user error then, because I've done all those things and it still doesn't work. I'd love to spend a few minutes on Zoom/Gchat if you have time. If you want to ping me over on Zulip so the whole world isn't joining us too :)

lbroudoux commented 12 months ago

Hi Eric!

I've done a few stuff this morning:

So you can now move your app to use the official 0.1.2 release but still have to specify quarkus.microcks.devservices.image-name=quay.io/microcks/microcks-uber:nightly in your conf to get the nightly with simpler gRPC dispatch.

I propose to close this issue/thread here, pursuing our discussion on Zulip (of course ๐Ÿ˜‰ ) and to open some other issues for next enhancements. Let me know if it's ok for you.

edeandrea commented 12 months ago

That works. Thank you so much for the quick turnaround!

I'll play with this a bit more today.