aldettinger commented on code in PR #6314:
URL: https://github.com/apache/camel-quarkus/pull/6314#discussion_r1732513141


##########
integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java:
##########
@@ -50,45 +86,141 @@ public Map<String, String> start() {
                     .withEnv("SPLUNK_HEC_TOKEN", HEC_TOKEN)
                     .withEnv("SPLUNK_LICENSE_URI", "Free")
                     .withEnv("TZ", TimeZone.getDefault().getID())
+                    //                    .withLogConsumer(new 
Slf4jLogConsumer(LOG))
                     .waitingFor(
                             Wait.forLogMessage(".*Ansible playbook 
complete.*\\n", 1)
                                     
.withStartupTimeout(Duration.ofMinutes(5)));
 
+            if (localhostCertPath != null && localhostKeystorePath != null && 
caCertPath != null && keystorePassword != null) {
+                //combine key + certificates into 1 pem - required for splunk
+                //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");
+            } else {
+                LOG.debug("Internal certificates are used for Splunk server.");
+            }
+
             container.start();
 
-            container.execInContainer("sudo", "sed", "-i", 
"s/allowRemoteLogin=requireSetPassword/allowRemoteLogin=always/",
-                    "/opt/splunk/etc/system/default/server.conf");
-            container.execInContainer("sudo", "sed", "-i", "s/enableSplunkdSSL 
= true/enableSplunkdSSL = false/",
-                    "/opt/splunk/etc/system/default/server.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.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/default/server.conf");
+                    "/opt/splunk/etc/system/local/server.conf");
+
+            //copy configuration for troubleshooting
+            
container.copyFileFromContainer("/opt/splunk/etc/system/local/server.conf",
+                    
Path.of(getClass().getResource("/").getPath()).resolve("local_server_from_container.conf").toFile()
+                            .getAbsolutePath());
 
-            container.execInContainer("sudo", "microdnf", "--nodocs", 
"update", "tzdata");//install tzdata package so we can specify tz other than UTC
+            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", "restart");
             container.execInContainer("sudo", "./bin/splunk", "add", "index", 
TEST_INDEX);
             container.execInContainer("sudo", "./bin/splunk", "add", "tcp", 
String.valueOf(SplunkConstants.TCP_PORT),
                     "-sourcetype", "TCP");
 
-            String splunkHost = container.getHost();
+            //copy from container conf and log files for better troubleshooting
+            
container.copyFileFromContainer("/opt/splunk/etc/system/local/server.conf",

Review Comment:
   Probably the first time we do this in camel-quarkus. On the top on my mind, 
it should work on platform test too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to