You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2024/02/08 15:32:07 UTC
(camel-quarkus) branch main updated: Splunk-hex native support
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 2b42c6384a Splunk-hex native support
2b42c6384a is described below
commit 2b42c6384ad80aa59e2260e280ed3263f705c691
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Tue Feb 6 14:30:25 2024 +0100
Splunk-hex native support
---
.../ROOT/examples/components/splunk-hec.yml | 6 +-
.../pages/reference/extensions/splunk-hec.adoc | 21 +++-
extensions-jvm/pom.xml | 1 -
extensions/pom.xml | 1 +
.../splunk-hec/deployment/pom.xml | 4 +
.../splunk/hec/deployment/SplunkHecProcessor.java | 16 +--
{extensions-jvm => extensions}/splunk-hec/pom.xml | 2 +-
.../splunk-hec/runtime/pom.xml | 6 +
.../main/resources/META-INF/quarkus-extension.yaml | 5 +-
integration-tests-jvm/pom.xml | 1 -
integration-tests-support/pom.xml | 1 +
.../splunk}/pom.xml | 42 ++++---
.../test/support/splunk/SplunkConstants.java | 33 ++++++
.../test/support/splunk}/SplunkTestResource.java | 24 ++--
integration-tests/pom.xml | 1 +
.../splunk-hec/pom.xml | 55 +++++++++
.../component/splunk/hec/it/SplunkHecResource.java | 41 ++++---
.../component/splunk/hec/it/SplunkHecIT.java | 17 +--
.../component/splunk/hec/it/SplunkHecTest.java | 127 +++++++++++++++++++++
integration-tests/splunk/pom.xml | 20 ++--
.../component/splunk/it/SplunkResource.java | 13 +--
.../quarkus/component/splunk/it/SplunkTest.java | 6 +-
poms/bom-test/pom.xml | 11 ++
tooling/scripts/test-categories.yaml | 1 +
24 files changed, 348 insertions(+), 107 deletions(-)
diff --git a/docs/modules/ROOT/examples/components/splunk-hec.yml b/docs/modules/ROOT/examples/components/splunk-hec.yml
index c6b6b9157a..b0ef480575 100644
--- a/docs/modules/ROOT/examples/components/splunk-hec.yml
+++ b/docs/modules/ROOT/examples/components/splunk-hec.yml
@@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-splunk-hec
cqArtifactIdBase: splunk-hec
-cqNativeSupported: false
-cqStatus: Preview
+cqNativeSupported: true
+cqStatus: Stable
cqDeprecated: false
cqJvmSince: 1.1.0
-cqNativeSince: n/a
+cqNativeSince: 3.8.0
cqCamelPartName: splunk-hec
cqCamelPartTitle: Splunk HEC
cqCamelPartDescription: The splunk component allows to publish events in Splunk using the HTTP Event Collector.
diff --git a/docs/modules/ROOT/pages/reference/extensions/splunk-hec.adoc b/docs/modules/ROOT/pages/reference/extensions/splunk-hec.adoc
index 5b15269168..3e36617ec0 100644
--- a/docs/modules/ROOT/pages/reference/extensions/splunk-hec.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/splunk-hec.adoc
@@ -4,17 +4,17 @@
= Splunk HEC
:linkattrs:
:cq-artifact-id: camel-quarkus-splunk-hec
-:cq-native-supported: false
-:cq-status: Preview
-:cq-status-deprecation: Preview
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
:cq-description: The splunk component allows to publish events in Splunk using the HTTP Event Collector.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 3.8.0
ifeval::[{doc-show-badges} == true]
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##3.8.0##
endif::[]
The splunk component allows to publish events in Splunk using the HTTP Event Collector.
@@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-splunk-hec-maven-coordinates"]
== Maven coordinates
+https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-splunk-hec[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]
+
+Or add the coordinates to your existing project:
+
[source,xml]
----
<dependency>
@@ -39,3 +43,10 @@ Please refer to the above link for usage and configuration details.
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]
+
+[id="extensions-splunk-hec-ssl-in-native-mode"]
+== SSL in native mode
+
+This extension auto-enables SSL support in native mode. Hence you do not need to add
+`quarkus.ssl.native=true` to your `application.properties` yourself. See also
+https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 4a0cf8deee..17883fe0de 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -88,7 +88,6 @@
<module>schematron</module>
<module>smpp</module>
<module>snmp</module>
- <module>splunk-hec</module>
<module>spring-redis</module>
<module>stitch</module>
<module>stomp</module>
diff --git a/extensions/pom.xml b/extensions/pom.xml
index a676ca6f25..a8f14bfc82 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -225,6 +225,7 @@
<module>snakeyaml</module>
<module>soap</module>
<module>splunk</module>
+ <module>splunk-hec</module>
<module>spring-rabbitmq</module>
<module>sql</module>
<module>ssh</module>
diff --git a/extensions-jvm/splunk-hec/deployment/pom.xml b/extensions/splunk-hec/deployment/pom.xml
similarity index 93%
copy from extensions-jvm/splunk-hec/deployment/pom.xml
copy to extensions/splunk-hec/deployment/pom.xml
index 6dd0a54046..c79d43c1bd 100644
--- a/extensions-jvm/splunk-hec/deployment/pom.xml
+++ b/extensions/splunk-hec/deployment/pom.xml
@@ -38,6 +38,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-splunk-hec</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient-deployment</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions-jvm/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java b/extensions/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java
similarity index 67%
rename from extensions-jvm/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java
rename to extensions/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java
index e0a44035d5..da7b0d57cc 100644
--- a/extensions-jvm/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java
+++ b/extensions/splunk-hec/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/hec/deployment/SplunkHecProcessor.java
@@ -17,11 +17,8 @@
package org.apache.camel.quarkus.component.splunk.hec.deployment;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;
class SplunkHecProcessor {
@@ -34,13 +31,8 @@ class SplunkHecProcessor {
return new FeatureBuildItem(FEATURE);
}
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
+ @BuildStep
+ ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+ return new ExtensionSslNativeSupportBuildItem(FEATURE);
}
}
diff --git a/extensions-jvm/splunk-hec/pom.xml b/extensions/splunk-hec/pom.xml
similarity index 96%
rename from extensions-jvm/splunk-hec/pom.xml
rename to extensions/splunk-hec/pom.xml
index 22f10ecf71..2f67b8752f 100644
--- a/extensions-jvm/splunk-hec/pom.xml
+++ b/extensions/splunk-hec/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-extensions-jvm</artifactId>
+ <artifactId>camel-quarkus-extensions</artifactId>
<version>3.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/extensions-jvm/splunk-hec/runtime/pom.xml b/extensions/splunk-hec/runtime/pom.xml
similarity index 94%
rename from extensions-jvm/splunk-hec/runtime/pom.xml
rename to extensions/splunk-hec/runtime/pom.xml
index 512694384b..79138f3ac8 100644
--- a/extensions-jvm/splunk-hec/runtime/pom.xml
+++ b/extensions/splunk-hec/runtime/pom.xml
@@ -32,6 +32,7 @@
<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>3.8.0</camel.quarkus.nativeSince>
</properties>
<dependencies>
@@ -43,10 +44,15 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-splunk-hec</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient</artifactId>
+ </dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>commons-logging-jboss-logging</artifactId>
</dependency>
+
</dependencies>
<build>
diff --git a/extensions-jvm/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 96%
rename from extensions-jvm/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 5290d72af5..5d40019c5a 100644
--- a/extensions-jvm/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/splunk-hec/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -25,9 +25,8 @@ name: "Camel Splunk HEC"
description: "The splunk component allows to publish events in Splunk using the HTTP Event Collector"
metadata:
icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/splunk-hec.html"
categories:
- - "integration"
+ - "integration"
status:
- - "preview"
+ - "stable"
diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml
index 716a51919b..50887d480c 100644
--- a/integration-tests-jvm/pom.xml
+++ b/integration-tests-jvm/pom.xml
@@ -87,7 +87,6 @@
<module>schematron</module>
<module>smpp</module>
<module>snmp</module>
- <module>splunk-hec</module>
<module>spring-redis</module>
<module>stitch</module>
<module>stomp</module>
diff --git a/integration-tests-support/pom.xml b/integration-tests-support/pom.xml
index c1da2aac96..b000d93204 100644
--- a/integration-tests-support/pom.xml
+++ b/integration-tests-support/pom.xml
@@ -51,6 +51,7 @@
<module>kafka</module>
<module>mongodb</module>
<module>process-executor-support</module>
+ <module>splunk</module>
<module>test-support</module>
<module>mock-backend</module>
<module>wiremock</module>
diff --git a/extensions-jvm/splunk-hec/deployment/pom.xml b/integration-tests-support/splunk/pom.xml
similarity index 60%
rename from extensions-jvm/splunk-hec/deployment/pom.xml
rename to integration-tests-support/splunk/pom.xml
index 6dd0a54046..af911c6ab2 100644
--- a/extensions-jvm/splunk-hec/deployment/pom.xml
+++ b/integration-tests-support/splunk/pom.xml
@@ -18,25 +18,35 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-splunk-hec-parent</artifactId>
+ <artifactId>camel-quarkus-integration-tests-support</artifactId>
<version>3.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>camel-quarkus-splunk-hec-deployment</artifactId>
- <name>Camel Quarkus :: Splunk HEC :: Deployment</name>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Support :: Splunk</name>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-core-deployment</artifactId>
+ <artifactId>camel-quarkus-integration-test-support</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-splunk-hec</artifactId>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit4-mock</artifactId>
</dependency>
</dependencies>
@@ -44,16 +54,14 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <annotationProcessorPaths>
- <path>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-extension-processor</artifactId>
- <version>${quarkus.version}</version>
- </path>
- </annotationProcessorPaths>
- </configuration>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
diff --git a/integration-tests-support/splunk/src/main/java/org/apache/camel/quarkus/test/support/splunk/SplunkConstants.java b/integration-tests-support/splunk/src/main/java/org/apache/camel/quarkus/test/support/splunk/SplunkConstants.java
new file mode 100644
index 0000000000..fa634e1127
--- /dev/null
+++ b/integration-tests-support/splunk/src/main/java/org/apache/camel/quarkus/test/support/splunk/SplunkConstants.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+package org.apache.camel.quarkus.test.support.splunk;
+
+public final class SplunkConstants {
+
+ public static final String PARAM_TEST_INDEX = "org.apache.camel.quarkus.component.splunk.hec.it.SplunkHecResource_testIndex";
+ public static final String PARAM_REMOTE_HOST = "org.apache.camel.quarkus.component.splunk.hec.it.SplunkHecResource_host";
+ public static final String PARAM_HEC_PORT = "org.apache.camel.quarkus.component.splunk.hec.it.SplunkHecResource_hecPort";
+ public static final String PARAM_HEC_TOKEN = "org.apache.camel.quarkus.component.splunk.hec.it.SplunkHecResource_hecToken";
+ public static final String PARAM_REMOTE_PORT = "org.apache.camel.quarkus.component.splunk.hec.it.SplunkHecResource_remotePort";
+ public static final String PARAM_TCP_PORT = "org.apache.camel.quarkus.component.splunk.it.SplunkResource_tcpPort";
+
+ public static final int TCP_PORT = 9998;
+
+ private SplunkConstants() {
+ // Utility class
+ }
+}
diff --git a/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTestResource.java b/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
similarity index 80%
rename from integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTestResource.java
rename to integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
index 5b740ec2cd..e34ca450de 100644
--- a/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTestResource.java
+++ b/integration-tests-support/splunk/src/test/java/org/apache/camel/quarkus/test/support/splunk/SplunkTestResource.java
@@ -14,14 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.splunk.it;
+package org.apache.camel.quarkus.test.support.splunk;
import java.time.Duration;
import java.util.Map;
import java.util.TimeZone;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import org.apache.camel.component.splunk.ProducerType;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
@@ -31,21 +30,24 @@ import org.testcontainers.containers.wait.strategy.Wait;
public class SplunkTestResource implements QuarkusTestResourceLifecycleManager {
public static String TEST_INDEX = "testindex";
+ public static final String HEC_TOKEN = "TESTTEST-TEST-TEST-TEST-TESTTESTTEST";
+
private static final String SPLUNK_IMAGE_NAME = ConfigProvider.getConfig().getValue("splunk.container.image", String.class);
private static final int REMOTE_PORT = 8089;
private static final int WEB_PORT = 8000;
+ private static final int HEC_PORT = 8088;
private static final Logger LOG = Logger.getLogger(SplunkTestResource.class);
private GenericContainer<?> container;
@Override
public Map<String, String> start() {
-
try {
container = new GenericContainer<>(SPLUNK_IMAGE_NAME)
- .withExposedPorts(REMOTE_PORT, SplunkResource.LOCAL_TCP_PORT, WEB_PORT)
+ .withExposedPorts(REMOTE_PORT, SplunkConstants.TCP_PORT, WEB_PORT, HEC_PORT)
.withEnv("SPLUNK_START_ARGS", "--accept-license")
.withEnv("SPLUNK_PASSWORD", "changeit")
+ .withEnv("SPLUNK_HEC_TOKEN", HEC_TOKEN)
.withEnv("SPLUNK_LICENSE_URI", "Free")
.withEnv("TZ", TimeZone.getDefault().getID())
.waitingFor(
@@ -65,9 +67,8 @@ public class SplunkTestResource implements QuarkusTestResourceLifecycleManager {
container.execInContainer("sudo", "./bin/splunk", "restart");
container.execInContainer("sudo", "./bin/splunk", "add", "index", TEST_INDEX);
- container.execInContainer("sudo", "./bin/splunk", "add", "tcp", String.valueOf(SplunkResource.LOCAL_TCP_PORT),
- "-sourcetype",
- ProducerType.TCP.name());
+ container.execInContainer("sudo", "./bin/splunk", "add", "tcp", String.valueOf(SplunkConstants.TCP_PORT),
+ "-sourcetype", "TCP");
String splunkHost = container.getHost();
@@ -77,9 +78,12 @@ public class SplunkTestResource implements QuarkusTestResourceLifecycleManager {
LOG.info(banner);
return Map.of(
- SplunkResource.PARAM_REMOTE_HOST, splunkHost,
- SplunkResource.PARAM_REMOTE_PORT, container.getMappedPort(REMOTE_PORT).toString(),
- SplunkResource.PARAM_TCP_PORT, container.getMappedPort(SplunkResource.LOCAL_TCP_PORT).toString());
+ SplunkConstants.PARAM_REMOTE_HOST, splunkHost,
+ SplunkConstants.PARAM_TCP_PORT, container.getMappedPort(SplunkConstants.TCP_PORT).toString(),
+ SplunkConstants.PARAM_HEC_TOKEN, HEC_TOKEN,
+ SplunkConstants.PARAM_TEST_INDEX, TEST_INDEX,
+ SplunkConstants.PARAM_REMOTE_PORT, container.getMappedPort(REMOTE_PORT).toString(),
+ SplunkConstants.PARAM_HEC_PORT, container.getMappedPort(HEC_PORT).toString());
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index d3995a168f..bb0c6b6365 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -213,6 +213,7 @@
<module>smb</module>
<module>soap</module>
<module>splunk</module>
+ <module>splunk-hec</module>
<module>spring-rabbitmq</module>
<module>sql</module>
<module>ssh</module>
diff --git a/integration-tests-jvm/splunk-hec/pom.xml b/integration-tests/splunk-hec/pom.xml
similarity index 63%
rename from integration-tests-jvm/splunk-hec/pom.xml
rename to integration-tests/splunk-hec/pom.xml
index e75dd2e51f..0b9838942b 100644
--- a/integration-tests-jvm/splunk-hec/pom.xml
+++ b/integration-tests/splunk-hec/pom.xml
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -51,9 +55,49 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>virtualDependencies</id>
<activation>
@@ -78,6 +122,17 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/integration-tests-jvm/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java b/integration-tests/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java
similarity index 54%
rename from integration-tests-jvm/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java
rename to integration-tests/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java
index e4a41fed56..b6d45f3626 100644
--- a/integration-tests-jvm/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java
+++ b/integration-tests/splunk-hec/src/main/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecResource.java
@@ -18,33 +18,40 @@ package org.apache.camel.quarkus.component.splunk.hec.it;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
-import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunkhec.SplunkHECConstants;
+import org.apache.camel.quarkus.test.support.splunk.SplunkConstants;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
@Path("/splunk-hec")
@ApplicationScoped
public class SplunkHecResource {
- private static final Logger LOG = Logger.getLogger(SplunkHecResource.class);
-
- private static final String COMPONENT_SPLUNK_HEC = "splunk-hec";
@Inject
- CamelContext context;
+ ProducerTemplate producer;
+
+ @ConfigProperty(name = SplunkConstants.PARAM_HEC_PORT)
+ Integer hecPort;
+
+ @ConfigProperty(name = SplunkConstants.PARAM_REMOTE_HOST)
+ String host;
+
+ @ConfigProperty(name = SplunkConstants.PARAM_TEST_INDEX)
+ String index;
+
+ @ConfigProperty(name = SplunkConstants.PARAM_HEC_TOKEN)
+ String token;
- @Path("/load/component/splunk-hec")
- @GET
+ @Path("/send")
+ @POST
@Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentSplunkHec() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_SPLUNK_HEC) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_SPLUNK_HEC);
- return Response.status(500, COMPONENT_SPLUNK_HEC + " could not be loaded from the Camel context").build();
+ public String send(String data, @QueryParam("indexTime") Long indexTime) {
+ String url = String.format("splunk-hec:%s:%s/%s?skipTlsVerify=true&index=%s", host, hecPort, token, index);
+ return producer.requestBodyAndHeader(url, data, SplunkHECConstants.INDEX_TIME, indexTime, String.class);
}
}
diff --git a/integration-tests-jvm/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java b/integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecIT.java
similarity index 69%
rename from integration-tests-jvm/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java
rename to integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecIT.java
index d7226a2534..617ea49fb5 100644
--- a/integration-tests-jvm/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java
+++ b/integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecIT.java
@@ -16,19 +16,8 @@
*/
package org.apache.camel.quarkus.component.splunk.hec.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class SplunkHecTest {
-
- @Test
- public void loadComponentSplunkHec() {
- /* A simple autogenerated test */
- RestAssured.get("/splunk-hec/load/component/splunk-hec")
- .then()
- .statusCode(200);
- }
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+@QuarkusIntegrationTest
+class SplunkHecIT extends SplunkHecTest {
}
diff --git a/integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java b/integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java
new file mode 100644
index 0000000000..701b9cb153
--- /dev/null
+++ b/integration-tests/splunk-hec/src/test/java/org/apache/camel/quarkus/component/splunk/hec/it/SplunkHecTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+package org.apache.camel.quarkus.component.splunk.hec.it;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.test.support.splunk.SplunkConstants;
+import org.apache.camel.quarkus.test.support.splunk.SplunkTestResource;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.Test;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
+import org.testcontainers.shaded.org.hamcrest.core.StringContains;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+class SplunkHecTest {
+
+ @Test
+ public void produce() {
+
+ String url = String.format("http://%s:%d",
+ getConfigValue(SplunkConstants.PARAM_REMOTE_HOST, String.class),
+ getConfigValue(SplunkConstants.PARAM_REMOTE_PORT, Integer.class));
+
+ RestAssured.given()
+ .body("Hello Sheldon")
+ .post("/splunk-hec/send")
+ .then()
+ .statusCode(200);
+
+ //there might a delay between the data written and received by the search, therefore await()
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> RestAssured.given()
+ .request()
+ .formParam("search", "search index=\"testindex\"")
+ .formParam("exec_mode", "oneshot")
+ .relaxedHTTPSValidation()
+ .auth().basic("admin", "password")
+ .post(url + "/services/search/jobs")
+ .then().statusCode(200)
+ .extract().asString(),
+ StringContains.containsString("Hello Sheldon"));
+
+ }
+
+ @Test
+ public void testIndexTime() {
+ String url = String.format("http://%s:%d",
+ getConfigValue(SplunkConstants.PARAM_REMOTE_HOST, String.class),
+ getConfigValue(SplunkConstants.PARAM_REMOTE_PORT, Integer.class));
+
+ //get time one day ago
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+
+ //send an event with text 'Hello Time 01'
+ RestAssured.given()
+ .body("Hello time 01")
+ .post("/splunk-hec/send")
+ .then()
+ .statusCode(200);
+
+ //send an event with text 'Hello Time 02', with overriden time
+ RestAssured.given()
+ .body("Hello time 02")
+ .queryParam("indexTime", calendar.getTimeInMillis())
+ .post("/splunk-hec/send")
+ .then()
+ .statusCode(200);
+
+ //there might a delay between the data written and received by the search, therefore await()
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(
+ () -> {
+ //get time from HelloTime01
+ List<String> times01 = RestAssured.given()
+ .request()
+ .formParam("search", "search body=\"hello time 01\" index=\"testindex\"")
+ .formParam("exec_mode", "oneshot")
+ .formParam("output_mode", "json")
+ .relaxedHTTPSValidation()
+ .auth().basic("admin", "password")
+ .post(url + "/services/search/jobs")
+ .then().statusCode(200)
+ .contentType(ContentType.JSON)
+ .extract().path("results._time"); //get time from HelloTime01
+ List<String> times02 = RestAssured.given()
+ .request()
+ .formParam("search", "search body=\"hello time 02\" index=\"testindex\"")
+ .formParam("exec_mode", "oneshot")
+ .formParam("output_mode", "json")
+ .relaxedHTTPSValidation()
+ .auth().basic("admin", "password")
+ .post(url + "/services/search/jobs")
+ .then().statusCode(200)
+ .contentType(ContentType.JSON)
+ .extract().path("results._time");
+
+ //time 2 has to be before time 1, event if was created later
+ return times01.size() == 1 && times02.size() == 1 && times02.get(0).compareTo(times01.get(0)) < 1;
+ });
+
+ }
+
+ private <T> T getConfigValue(String key, Class<T> type) {
+ return ConfigProvider.getConfig().getValue(key, type);
+ }
+}
diff --git a/integration-tests/splunk/pom.xml b/integration-tests/splunk/pom.xml
index e94bfc867f..12cee7eec9 100644
--- a/integration-tests/splunk/pom.xml
+++ b/integration-tests/splunk/pom.xml
@@ -47,6 +47,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -60,19 +64,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit4-mock</artifactId>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java b/integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
index f00eea9e16..18fd9b8db2 100644
--- a/integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
+++ b/integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
@@ -40,6 +40,7 @@ import org.apache.camel.component.splunk.ProducerType;
import org.apache.camel.component.splunk.SplunkComponent;
import org.apache.camel.component.splunk.SplunkConfiguration;
import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.apache.camel.quarkus.test.support.splunk.SplunkConstants;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@Path("/splunk")
@@ -47,11 +48,7 @@ import org.eclipse.microprofile.config.inject.ConfigProperty;
public class SplunkResource {
public static final String SAVED_SEARCH_NAME = "savedSearchForTest";
- public static final String PARAM_REMOTE_HOST = "org.apache.camel.quarkus.component.splunk.it.SplunkResource_host";
- public static final String PARAM_REMOTE_PORT = "org.apache.camel.quarkus.component.splunk.it.SplunkResource_remotePort";
- public static final String PARAM_TCP_PORT = "org.apache.camel.quarkus.component.splunk.it.SplunkResource_tcpPort";
public static final String SOURCE = "test";
- public static final int LOCAL_TCP_PORT = 9998;
@Inject
ProducerTemplate producerTemplate;
@@ -59,13 +56,13 @@ public class SplunkResource {
@Inject
ConsumerTemplate consumerTemplate;
- @ConfigProperty(name = PARAM_REMOTE_HOST)
+ @ConfigProperty(name = SplunkConstants.PARAM_REMOTE_HOST)
String host;
- @ConfigProperty(name = PARAM_REMOTE_PORT)
+ @ConfigProperty(name = SplunkConstants.PARAM_REMOTE_PORT)
Integer port;
- @ConfigProperty(name = PARAM_TCP_PORT)
+ @ConfigProperty(name = SplunkConstants.PARAM_TCP_PORT)
Integer tcpPort;
@Named
@@ -143,7 +140,7 @@ public class SplunkResource {
url = String.format(
"splunk:%s?raw=%b&username=admin&password=changeit&scheme=http&host=%s&port=%d&index=%s&sourceType=%s&source=%s&tcpReceiverLocalPort=%d&tcpReceiverPort=%d",
producerType.toLowerCase(), !(message instanceof SplunkEvent), host, port, index, producerType, SOURCE,
- LOCAL_TCP_PORT, tcpPort);
+ SplunkConstants.TCP_PORT, tcpPort);
} else {
url = String.format(
diff --git a/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java b/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
index 33f992361f..565b0e488b 100644
--- a/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
+++ b/integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
@@ -30,6 +30,8 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.component.splunk.ProducerType;
+import org.apache.camel.quarkus.test.support.splunk.SplunkConstants;
+import org.apache.camel.quarkus.test.support.splunk.SplunkTestResource;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.hamcrest.Matchers;
@@ -72,8 +74,8 @@ class SplunkTest {
//create saved search
Config config = ConfigProvider.getConfig();
RestAssured.given()
- .baseUri("http://" + config.getValue(SplunkResource.PARAM_REMOTE_HOST, String.class))
- .port(config.getValue(SplunkResource.PARAM_REMOTE_PORT, Integer.class))
+ .baseUri("http://" + config.getValue(SplunkConstants.PARAM_REMOTE_HOST, String.class))
+ .port(config.getValue(SplunkConstants.PARAM_REMOTE_PORT, Integer.class))
.contentType(ContentType.JSON)
.param("name", SplunkResource.SAVED_SEARCH_NAME)
.param("disabled", "0")
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 4eefc7d480..385218d695 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -178,6 +178,17 @@
<artifactId>camel-quarkus-integration-tests-support-custom-type-converter</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-support-splunk</artifactId>
+ <version>${camel-quarkus.version}</version>
+ <type>test-jar</type>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-process-executor-support</artifactId>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index ed63d22c23..1b8a852519 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -150,6 +150,7 @@ group-09:
- management
- nats
- splunk
+ - splunk-hec
- spring-rabbitmq
- xpath
group-10: