Repository: quarkusio/quarkus
Issue: [native] kafka-snappy integration-test fails with org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY]

## Describe the bug
When running `integration-tests/kafka-snappy` in native mode with `-Dtest-containers` and latest Graal VM 21.1-dev it fails to run the IT tests on the native image with an error failing to load a native library.

### Expected behavior
IT tests run fine on the native image

### Actual behavior
```
[INFO] Running io.quarkus.it.kafka.KafkaSnappyProducerITCase
2021-03-26 10:39:25,374 WARN  [io.qua.deployment] (main) Producing values from constructors and fields is no longer supported and will be removed in a future release: io.quarkus.deployment.annotations.BuildProducer io.quarkus.it.classtransformer.ClassTransformerProcessor.transformers
Executing [/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/target/quarkus-integration-test-kafka-snappy-999-SNAPSHOT-runner, -Dquarkus.http.port=8081, -Dquarkus.http.ssl-port=8444, -Dtest.url=http://localhost:8081, -Dquarkus.log.file.path=/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/target/quarkus.log, -Dquarkus.log.file.enable=true, -Dquarkus.kubernetes-service-binding.root=/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/src/test/resources/k8s-sb]
Mar 26, 2021 10:39:29 AM io.quarkus.runtime.ApplicationLifecycleManager run
ERROR: Failed to start application (with profile prod)
org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=x86_64
	at io.quarkus.kafka.client.runtime.KafkaRecorder.loadSnappy(KafkaRecorder.java:39)
	at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy_0(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:67)
	at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:378)
	at io.quarkus.runtime.Application.start(Application.java:90)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)

[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 2, Time elapsed: 17.952 s <<< FAILURE! - in io.quarkus.it.kafka.KafkaSnappyProducerITCase
[ERROR] io.quarkus.it.kafka.KafkaSnappyProducerITCase.health  Time elapsed: 0.01 s  <<< ERROR!
java.lang.RuntimeException: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details
	at io.quarkus.test.junit.NativeTestExtension.throwBootFailureException(NativeTestExtension.java:158)
	at io.quarkus.test.junit.NativeTestExtension.beforeEach(NativeTestExtension.java:56)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:159)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:158)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:125)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details
	at io.quarkus.test.common.LauncherUtil.waitForCapturedListeningData(LauncherUtil.java:73)
	at io.quarkus.test.common.NativeImageLauncher.start(NativeImageLauncher.java:116)
	at io.quarkus.test.junit.IntegrationTestUtil.startLauncher(IntegrationTestUtil.java:124)
	at io.quarkus.test.junit.NativeTestExtension.doNativeStart(NativeTestExtension.java:126)
	at io.quarkus.test.junit.NativeTestExtension.ensureStarted(NativeTestExtension.java:92)
	at io.quarkus.test.junit.NativeTestExtension.beforeAll(NativeTestExtension.java:65)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$8(ClassBasedTestDescriptor.java:368)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:368)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:192)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136)
	... 34 more

```

## To Reproduce
1. Set up Graal VM or Mandrel so as to being able to build with `-Dnative`
2. `$  ./mvnw clean verify -Dnative -Dtest-containers -pl integration-tests/kafka-snappy/`

## Environment (please complete the following information):
Linux, Java 11, x86_64

### GraalVM version (if different from Java)
21.1-dev

### Quarkus version or git rev
main, revision 320a6322df01ffe6b981a002cd8ca77c0cdab560

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)
$ ./mvnw --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/sgehwolf/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.10, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-1.fc33.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.8-200.fc33.x86_64", arch: "amd64", family: "unix"

## Additional context
It also fails the native integration tests of quarkus main with graal vm main. For example here:
https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/687103625 (native tests: Messaging)


Changed files:
extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java

diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java
index 128cc21e640..6b90114830e 100644
--- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java
+++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java
@@ -46,6 +46,7 @@
 import org.jboss.jandex.DotName;
 import org.jboss.jandex.Type;
 import org.jboss.jandex.Type.Kind;
+import org.xerial.snappy.OSInfo;
 
 import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
 import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
@@ -199,7 +200,7 @@ private void handleSnappy(BuildProducer<ReflectiveClassBuildItem> reflectiveClas
             String path = root + dir + "/" + snappyNativeLibraryName;
             nativeLibs.produce(new NativeImageResourceBuildItem(path));
         } else { // otherwise the native lib of the platform this build runs on
-            String dir = getOs() + "/" + getArch();
+            String dir = OSInfo.getNativeLibFolderPathForCurrentOS();
             String snappyNativeLibraryName = System.mapLibraryName("snappyjava");
             if (snappyNativeLibraryName.toLowerCase().endsWith(".dylib")) {
                 snappyNativeLibraryName = snappyNativeLibraryName.replace(".dylib", ".jnilib");
@@ -414,23 +415,4 @@ void registerServiceBinding(Capabilities capabilities,
                             KafkaBindingConverter.class.getName()));
         }
     }
-
-    public static String getArch() {
-        String osArch = System.getProperty("os.arch");
-        return osArch.replaceAll("\\\\W", "");
-    }
-
-    static String getOs() {
-        String osName = System.getProperty("os.name");
-
-        if (osName.contains("Windows")) {
-            return "Windows";
-        } else if (osName.contains("Mac")) {
-            return "Mac";
-        } else if (osName.contains("Linux")) {
-            return "Linux";
-        } else {
-            return osName.replaceAll("\\\\W", "");
-        }
-    }
 }