datastax / cassandra-quarkus

An Apache Cassandra(R) extension for Quarkus
Apache License 2.0
39 stars 28 forks source link

CassandraHealthCheckIT fails when run on M1 Macs #225

Closed absurdfarce closed 1 year ago

absurdfarce commented 1 year ago

Test is unable to run the underlying Docker image:

[INFO] -------------------------------------------------------                                                                                                                                                        
[INFO]  T E S T S                                                                                                                                                                                                     
[INFO] -------------------------------------------------------                                                                                                                                                        
[INFO] Running com.datastax.oss.quarkus.tests.CassandraHealthCheckIT                                                                                                                                                  
2023-03-24 15:56:08,974 WARN  [io.qua.res.mut.dep.ResteasyMutinyProcessor] (build-93) The quarkus-resteasy-mutiny extension is deprecated. Switch to RESTEasy Reactive instead.                                       
This extension adds support for Uni and Multi to RESTEasy Classic, without using the reactive execution model, as RESTEasy Classic does not use it. To properly integrate Mutiny and RESTEasy, use RESTEasy Reactive. 
See https://quarkus.io/guides/getting-started-reactive for detailed instructions                                                                                                                                      
2023-03-24 15:56:10,612 INFO  [🐳 .3.4]] (pool-3-thread-1) Creating container for image: testcontainers/ryuk:0.3.4                                                                                                    
2023-03-24 15:56:10,739 INFO  [🐳 .3.4]] (pool-3-thread-1) Container testcontainers/ryuk:0.3.4 is starting: 7161b3a855b969f97f658e8241d8f08ecbe62e2eb421df2484b2d57a1ede46a2                                          
2023-03-24 15:56:11,181 INFO  [🐳 .3.4]] (pool-3-thread-1) Container testcontainers/ryuk:0.3.4 started in PT0.584676S                                                                                                 
2023-03-24 15:56:11,188 INFO  [com.dat.oss.qua.tes.CassandraTestResource] (pool-3-thread-1) Container datastax/dse-server:6.8.25 starting...  
...
2023-03-24 15:56:16,690 ERROR [🐳 .8.25]] (pool-3-thread-1) Log output from the failed container:                                                                                                                     
exec /entrypoint.sh: exec format error                                                                                                                                                                                

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.345 s <<< FAILURE! - in com.datastax.oss.quarkus.tests.CassandraHealthCheckIT                                                               
[ERROR] com.datastax.oss.quarkus.tests.CassandraHealthCheckIT.should_report_status_up_by_the_health_check  Time elapsed: 0.008 s  <<< ERROR!                                                                          
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException  
...
Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: Unable to start Quarkus test resource class com.datastax.oss.quarkus.test.CassandraTestResource
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
... 

Problem here appears to be the lack of AMD64 support for the DSE image:

$ docker run datastax/dse-server:6.8.25
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
exec /entrypoint.sh: exec format error

Available tags for dse-server image can be found here.

┆Issue is synchronized with this Jira Task by Unito

msmygit commented 1 year ago

Curious if we should be doing it like docker pull datastax/dse-server:6.8.33-ubi7-1? 🤔

absurdfarce commented 1 year ago

This isn't my area of expertise but my understanding is that the UBI images are still tied to a specific platform just like any other Docker image. Dockerhub reports all of the currently published images target amd64 anyway. My guess would be that the larger issue is that we don't have DSE images for ARM64 and I'm unaware of any plan to add them.

adutra commented 1 year ago

I had some luck fiddling with DSE images and startup options, but not enough to propose a fix unfortunately.

In CassandraTestResource:

    boolean dse = image.contains("dse");
    boolean macSilicon =
        System.getProperty("os.name").toLowerCase().contains("mac")
            && System.getProperty("os.arch").toLowerCase().contains("aarch64");
    if (dse && macSilicon) {
      // DSE has no image for Mac amd64, so we need to use the linux/amd64 image
      LOGGER.warn(
          "Using linux/amd64 image for DSE on Mac Silicon, make sure you have installed Rosetta");
      cassandraContainer.withCreateContainerCmdModifier(cmd -> cmd.withPlatform("linux/amd64"));
    }

Then in DseTestBase:

@QuarkusTestResource(
    value = CassandraTestResource.class,
    initArgs = {
      @ResourceArg(
          name = "quarkus.cassandra.test.container.image",
          value = "datastax/dse-server:6.8.25"),
      // activate DSE Graph with the -g switch; the resulting command will be: dse cassandra -f -g
      @ResourceArg(name = "quarkus.cassandra.test.container.cmd", value = "-g"),
      @ResourceArg(name = "quarkus.cassandra.test.container.startup-timeout", value = "PT5M"),
      @ResourceArg(
          name = "quarkus.cassandra.test.container.jvm-opts",
          value =
              "-Dcassandra.skip_wait_for_gossip_to_settle=0 "
                  + "-Dcassandra.num_tokens=1 "
                  + "-Dcassandra.initial_token=0 "
                  + "-Dinsights.default_mode=disabled "
                  + "-Ddse.io.aio.enable=false")
    })
public abstract class DseTestBase {}

However if I was able to get the container to start, 95% of the time it would stop mid-course with a JVM crash.

I believe the only safe option is to disable these tests on Apple Silicon, until arm64 images are available (if they are one day).

absurdfarce commented 1 year ago

Resolved by https://github.com/datastax/cassandra-quarkus/pull/226