This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 54517aea5f Refactor Splunk test container
54517aea5f is described below

commit 54517aea5f1c93603bf651b8110a4460e92bd7a5
Author: Lukas Lowinger <[email protected]>
AuthorDate: Fri Oct 17 16:57:18 2025 +0200

    Refactor Splunk test container
---
 .../test/support/splunk/SplunkTestResource.java    | 88 ++++++----------------
 .../splunk-hec/src/test/resources/default.yml      | 75 ++++++++++++++++++
 .../src/test/resources/local_inputs.conf           |  6 --
 .../src/test/resources/local_server.conf           | 33 --------
 .../splunk/src/test/resources/default.yml          | 75 ++++++++++++++++++
 .../splunk/src/test/resources/local_inputs.conf    |  6 --
 .../splunk/src/test/resources/local_server.conf    | 33 --------
 7 files changed, 172 insertions(+), 144 deletions(-)

diff --git 
a/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
 
b/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
index a40d45d7ee..769e203cc0 100644
--- 
a/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
+++ 
b/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
@@ -17,6 +17,7 @@
 package org.apache.camel.quarkus.test.support.splunk;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -32,11 +33,9 @@ import org.eclipse.microprofile.config.ConfigProvider;
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.Container;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.images.builder.Transferable;
-import org.testcontainers.utility.MountableFile;
 
 public class SplunkTestResource implements QuarkusTestResourceLifecycleManager 
{
 
@@ -90,69 +89,24 @@ public class SplunkTestResource implements 
QuarkusTestResourceLifecycleManager {
                 //extraction of private key can not be done by keytool (only 
openssl), but it can be done programmatically
                 byte[] concatenate = concatenateKeyAndCertificates(banner);
 
-                container.withCopyToContainer(Transferable.of(concatenate), 
"/opt/splunk/etc/auth/mycerts/myServerCert.pem")
-                        
.withCopyToContainer(Transferable.of(Files.readAllBytes(Paths.get(caCertPath))),
-                                "/opt/splunk/etc/auth/mycerts/cacert.pem");
+                container.withCopyToContainer(Transferable.of(concatenate),
+                        "/opt/splunk/etc/auth/servercerts/myServerCert.pem");
+                // note we are using different root path "/etc/..." because on 
Podman 5.4.0 it is unable to copy two files from the same root path for unknown 
reason
+                
container.withCopyToContainer(Transferable.of(Files.readAllBytes(Paths.get(caCertPath))),
+                        "/etc/cacert.pem");
             } else {
                 LOG.debug("Internal certificates are used for Splunk server.");
             }
 
+            // based on 
https://splunk.github.io/docker-splunk/ADVANCED.html#runtime-configuration
+            
container.withCopyToContainer(Transferable.of(readResourceToBytes("default.yml")),
 "/tmp/defaults/default.yml");
             container.start();
 
-            
container.copyFileToContainer(MountableFile.forClasspathResource("local_server.conf"),
-                    "/opt/splunk/etc/system/local/server.conf");
-            
container.copyFileToContainer(MountableFile.forClasspathResource("local_inputs.conf"),
-                    "/opt/splunk/etc/system/local/inputs.conf");
-
-            
container.copyFileToContainer(MountableFile.forClasspathResource("local_server.conf"),
-                    "/opt/splunk/etc/system/local/server.conf");
-            
container.copyFileToContainer(MountableFile.forClasspathResource("local_inputs.conf"),
-                    "/opt/splunk/etc/system/local/inputs.conf");
-
-            container.execInContainer("sudo", "sed", "-i", "s/minFreeSpace = 
5000/minFreeSpace = 100/",
-                    "/opt/splunk/etc/system/local/server.conf");
-
             /* uncomment for troubleshooting purposes - copy configuration 
from container
             
container.copyFileFromContainer("/opt/splunk/etc/system/local/server.conf",
                     
Path.of(getClass().getResource("/").getPath()).resolve("local_server_from_container.conf").toFile()
                             .getAbsolutePath());*/
 
-            assertExecResult(container.execInContainer("sudo", "microdnf", 
"--nodocs", "update", "tzdata"), "tzdata install");//install tzdata package so 
we can specify tz other than UTC
-
-            LOG.debug(banner);
-            LOG.debug("Restarting splunk server.");
-            LOG.debug(banner);
-
-            assertExecResult(container.execInContainer("sudo", "./bin/splunk", 
"restart"), "splunk restart");
-
-            container.execInContainer("sudo", "./bin/splunk", "add", "index", 
TEST_INDEX);
-            container.execInContainer("sudo", "./bin/splunk", "add", "tcp", 
String.valueOf(SplunkConstants.TCP_PORT),
-                    "-sourcetype", "TCP");
-
-            /*uncomment for troubleshooting purposes - copy from container 
conf and log files
-            
container.copyFileFromContainer("/opt/splunk/etc/system/local/server.conf",
-                    
Path.of(getClass().getResource("/").getPath()).resolve("local-server-from-container.conf").toFile()
-                            .getAbsolutePath());
-            
container.copyFileFromContainer("/opt/splunk/etc/system/default/server.conf",
-                    
Path.of(getClass().getResource("/").getPath()).resolve("default-server-from-container.log").toFile()
-                            .getAbsolutePath());
-            if (localhostCertPath != null && localhostKeystorePath != null && 
caCertPath != null && keystorePassword != null) {
-                
container.copyFileFromContainer("/opt/splunk/etc/auth/mycerts/myServerCert.pem",
-                        
Path.of(getClass().getResource("/").getPath()).resolve("myServerCert-from-container.pem").toFile()
-                                .getAbsolutePath());
-                
container.copyFileFromContainer("/opt/splunk/etc/auth/mycerts/cacert.pem",
-                        
Path.of(getClass().getResource("/").getPath()).resolve("cacert-from-container.pem").toFile()
-                                .getAbsolutePath());
-            } else {
-                
container.copyFileFromContainer("/opt/splunk/etc/auth/server.pem",
-                        
Path.of(getClass().getResource("/").getPath()).resolve("myServerCert-from-container.pem").toFile()
-                                .getAbsolutePath());
-                
container.copyFileFromContainer("/opt/splunk/etc/auth/cacert.pem",
-                        
Path.of(getClass().getResource("/").getPath()).resolve("cacert-from-container.pem").toFile()
-                                .getAbsolutePath());
-            }
-            */
-
             String splunkHost = container.getHost();
 
             Map<String, String> m = Map.of(
@@ -171,7 +125,6 @@ public class SplunkTestResource implements 
QuarkusTestResourceLifecycleManager {
             LOG.debug(banner);
 
             return m;
-
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -193,17 +146,6 @@ public class SplunkTestResource implements 
QuarkusTestResourceLifecycleManager {
         return (severCert + ca + pemKey).getBytes(StandardCharsets.UTF_8);
     }
 
-    private static void assertExecResult(Container.ExecResult res, String cmd) 
{
-        if (res.getExitCode() != 0) {
-            LOG.error("Command: " + cmd);
-            LOG.error("Stdout: " + res.getStdout());
-            LOG.error("Stderr: " + res.getStderr());
-            throw new RuntimeException("Command " + cmd + ") failed. " + 
res.getStdout());
-        } else {
-            LOG.debug("Command: " + cmd + " succeeded!");
-        }
-    }
-
     @Override
     public void stop() {
         try {
@@ -214,4 +156,18 @@ public class SplunkTestResource implements 
QuarkusTestResourceLifecycleManager {
             // Ignored
         }
     }
+
+    public byte[] readResourceToBytes(String resourcePath) throws IOException {
+        ClassLoader classLoader = getClass().getClassLoader();
+        try (InputStream inputStream = 
classLoader.getResourceAsStream(resourcePath)) {
+            if (inputStream == null) {
+                throw new IOException("Resource not found on classpath: " + 
resourcePath);
+            }
+
+            return inputStream.readAllBytes();
+
+        } catch (IOException e) {
+            throw new IOException("Failed to read resource '" + resourcePath + 
"' into byte array.", e);
+        }
+    }
 }
diff --git a/integration-tests/splunk-hec/src/test/resources/default.yml 
b/integration-tests/splunk-hec/src/test/resources/default.yml
new file mode 100644
index 0000000000..8f2244f5e6
--- /dev/null
+++ b/integration-tests/splunk-hec/src/test/resources/default.yml
@@ -0,0 +1,75 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+splunk:
+  conf:
+    - key: indexes
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          testindex:
+            homePath: "$SPLUNK_DB/testindex/db"
+            coldPath: "$SPLUNK_DB/testindex/colddb"
+            thawedPath: "$SPLUNK_DB/testindex/thaweddb"
+    - key: inputs
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          default:
+            host: "localhost"
+          tcp://9998:
+            connection_host: "ip"
+            sourcetype: "TCP"
+            index: "testindex"
+            disabled: "false"
+          splunktcp-ssl:9997:
+            disabled: "0"
+    - key: server
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          general:
+            serverName: "b66b768099db"
+            pass4SymmKey: 
"$7$oeVDSaCZOSOMIVB0Yv2lBqldGvLt0pXWuQdDV7YvZ0d6Kwf/f0RwhQ=="
+            allowRemoteLogin: "always"
+          sslConfig:
+            caTrustStore: "splunk"
+            serverCert: "/opt/splunk/etc/auth/servercerts/myServerCert.pem"
+            sslPassword: "password"
+            requireClientCert: "false"
+            cipherSuite: "ECDHE-RSA-AES256-GCM-SHA384"
+            sslRootCAPath: "/etc/cacert.pem"
+          lmpool:auto_generated_pool_download-trial:
+            description: "auto_generated_pool_download-trial"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "download-trial"
+          lmpool:auto_generated_pool_forwarder:
+            description: "auto_generated_pool_forwarder"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "forwarder"
+          lmpool:auto_generated_pool_free:
+            description: "auto_generated_pool_free"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "free"
+          license:
+            active_group: "Free"
+          diskUsage:
+            minFreeSpace: 100
\ No newline at end of file
diff --git a/integration-tests/splunk-hec/src/test/resources/local_inputs.conf 
b/integration-tests/splunk-hec/src/test/resources/local_inputs.conf
deleted file mode 100644
index 03ce3b62fe..0000000000
--- a/integration-tests/splunk-hec/src/test/resources/local_inputs.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-[default]
-host = localhost
-
-[splunktcp-ssl:9997]
-
-disabled=0
\ No newline at end of file
diff --git a/integration-tests/splunk-hec/src/test/resources/local_server.conf 
b/integration-tests/splunk-hec/src/test/resources/local_server.conf
deleted file mode 100644
index 93a12d0e87..0000000000
--- a/integration-tests/splunk-hec/src/test/resources/local_server.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-[general]
-serverName = b66b768099db
-pass4SymmKey = $7$oeVDSaCZOSOMIVB0Yv2lBqldGvLt0pXWuQdDV7YvZ0d6Kwf/f0RwhQ==
-allowRemoteLogin = always
-
-[sslConfig]
-caTrustStore = splunk
-serverCert = /opt/splunk/etc/auth/mycerts/myServerCert.pem
-sslPassword = password
-requireClientCert = false
-cipherSuite = ECDHE-RSA-AES256-GCM-SHA384
-sslRootCAPath = /opt/splunk/etc/auth/mycerts/cacert.pem
-
-[lmpool:auto_generated_pool_download-trial]
-description = auto_generated_pool_download-trial
-peers = *
-quota = MAX
-stack_id = download-trial
-
-[lmpool:auto_generated_pool_forwarder]
-description = auto_generated_pool_forwarder
-peers = *
-quota = MAX
-stack_id = forwarder
-
-[lmpool:auto_generated_pool_free]
-description = auto_generated_pool_free
-peers = *
-quota = MAX
-stack_id = free
-
-[license]
-active_group = Free
diff --git a/integration-tests/splunk/src/test/resources/default.yml 
b/integration-tests/splunk/src/test/resources/default.yml
new file mode 100644
index 0000000000..8f2244f5e6
--- /dev/null
+++ b/integration-tests/splunk/src/test/resources/default.yml
@@ -0,0 +1,75 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+splunk:
+  conf:
+    - key: indexes
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          testindex:
+            homePath: "$SPLUNK_DB/testindex/db"
+            coldPath: "$SPLUNK_DB/testindex/colddb"
+            thawedPath: "$SPLUNK_DB/testindex/thaweddb"
+    - key: inputs
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          default:
+            host: "localhost"
+          tcp://9998:
+            connection_host: "ip"
+            sourcetype: "TCP"
+            index: "testindex"
+            disabled: "false"
+          splunktcp-ssl:9997:
+            disabled: "0"
+    - key: server
+      value:
+        directory: /opt/splunk/etc/system/local
+        content:
+          general:
+            serverName: "b66b768099db"
+            pass4SymmKey: 
"$7$oeVDSaCZOSOMIVB0Yv2lBqldGvLt0pXWuQdDV7YvZ0d6Kwf/f0RwhQ=="
+            allowRemoteLogin: "always"
+          sslConfig:
+            caTrustStore: "splunk"
+            serverCert: "/opt/splunk/etc/auth/servercerts/myServerCert.pem"
+            sslPassword: "password"
+            requireClientCert: "false"
+            cipherSuite: "ECDHE-RSA-AES256-GCM-SHA384"
+            sslRootCAPath: "/etc/cacert.pem"
+          lmpool:auto_generated_pool_download-trial:
+            description: "auto_generated_pool_download-trial"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "download-trial"
+          lmpool:auto_generated_pool_forwarder:
+            description: "auto_generated_pool_forwarder"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "forwarder"
+          lmpool:auto_generated_pool_free:
+            description: "auto_generated_pool_free"
+            peers: "*"
+            quota: "MAX"
+            stack_id: "free"
+          license:
+            active_group: "Free"
+          diskUsage:
+            minFreeSpace: 100
\ No newline at end of file
diff --git a/integration-tests/splunk/src/test/resources/local_inputs.conf 
b/integration-tests/splunk/src/test/resources/local_inputs.conf
deleted file mode 100644
index 03ce3b62fe..0000000000
--- a/integration-tests/splunk/src/test/resources/local_inputs.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-[default]
-host = localhost
-
-[splunktcp-ssl:9997]
-
-disabled=0
\ No newline at end of file
diff --git a/integration-tests/splunk/src/test/resources/local_server.conf 
b/integration-tests/splunk/src/test/resources/local_server.conf
deleted file mode 100644
index 93a12d0e87..0000000000
--- a/integration-tests/splunk/src/test/resources/local_server.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-[general]
-serverName = b66b768099db
-pass4SymmKey = $7$oeVDSaCZOSOMIVB0Yv2lBqldGvLt0pXWuQdDV7YvZ0d6Kwf/f0RwhQ==
-allowRemoteLogin = always
-
-[sslConfig]
-caTrustStore = splunk
-serverCert = /opt/splunk/etc/auth/mycerts/myServerCert.pem
-sslPassword = password
-requireClientCert = false
-cipherSuite = ECDHE-RSA-AES256-GCM-SHA384
-sslRootCAPath = /opt/splunk/etc/auth/mycerts/cacert.pem
-
-[lmpool:auto_generated_pool_download-trial]
-description = auto_generated_pool_download-trial
-peers = *
-quota = MAX
-stack_id = download-trial
-
-[lmpool:auto_generated_pool_forwarder]
-description = auto_generated_pool_forwarder
-peers = *
-quota = MAX
-stack_id = forwarder
-
-[lmpool:auto_generated_pool_free]
-description = auto_generated_pool_free
-peers = *
-quota = MAX
-stack_id = free
-
-[license]
-active_group = Free

Reply via email to