You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/03/16 12:59:39 UTC

[GitHub] [camel-quarkus] JiriOndrusek opened a new pull request #2339: Splunk native support #1698

JiriOndrusek opened a new pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339


   fixes https://github.com/apache/camel-quarkus/issues/1698
   
   Requires https://github.com/apache/camel/pull/5217 to be merged (currently approved)
   
   Tests use Splunk server with free licence started via docker- see `SplunkTestResource` .
   > new GenericContainer("splunk/splunk:8.1.2")
   > .withEnv("SPLUNK_LICENSE_URI", "Free")
   
   As is stated [here](https://docs.splunk.com/Documentation/Splunk/8.1.2/Admin/MoreaboutSplunkFree),
   
   > If you want to run Splunk Enterprise to practice searches, data ingestion, and other tasks without worrying about a license, Splunk Free is the tool for you.
   
   free version version could be used without any consequence. But I'd like to mention it here, for the case, that I'm wrong and we should not use it.
   
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596729084



##########
File path: tooling/scripts/test-categories.yaml
##########
@@ -126,6 +126,7 @@ messaging-networking1:
   - kafka
   - messaging
   - nats
+  - splunk

Review comment:
       Could we please all prefer adding new tests to the category that took shortest to run in some recent CI run? In that way we can keep the category execution times ballanced.  E.g. if you check here https://github.com/apache/camel-quarkus/actions/runs/663670257 , you see that messaging-networking1 took 1h3m which is not currently the fastest one. core-main-validation is at 44m.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596704917



##########
File path: extensions/splunk/deployment/src/main/java/org/apache/camel/quarkus/component/splunk/deployment/SplunkProcessor.java
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.deployment;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.IndexView;
+import org.joda.time.DateTimeZone;
+
+class SplunkProcessor {
+
+    private static final String FEATURE = "camel-splunk";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+        return new ExtensionSslNativeSupportBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem runtimeInitBcryptUtil() {
+        // this class uses a SecureRandom which needs to be initialised at run time

Review comment:
       I appreciate the comment!




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r595769376



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)

Review comment:
       This is a remnant of my older attempts, it should be removed, thanks.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596648134



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    private boolean initialized;
+
+    private void initialize() {
+        if (!initialized) {
+            SplunkComponent sc = camelContext.getComponent("splunk", SplunkComponent.class);

Review comment:
       done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596647942



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+class SplunkTest {
+
+    @Test
+    public void testWriteTcpAndReadNormal() {
+        write("_normal", SplunkTestResource.TEST_INDEX, "tcp");
+
+        List<Map<String, String>> result = RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/normal")
+                .then()
+                .statusCode(200)
+                .extract().as(List.class);
+
+        Assert.assertEquals(3, result.size());
+        Assert.assertEquals("Irma_normal", result.get(0).get("name"));
+        Assert.assertEquals("Earth\"", result.get(0).get("from"));
+        Assert.assertEquals("Leonard_normal", result.get(1).get("name"));
+        Assert.assertEquals("Earth 2.0\"", result.get(1).get("from"));
+        Assert.assertEquals("Sheldon_normal", result.get(2).get("name"));
+        Assert.assertEquals("Alpha Centauri\"", result.get(2).get("from"));
+    }
+
+    @Test
+    public void testWriteSubmitAndReadRealtime() throws InterruptedException, ExecutionException {
+
+        RestAssured.given()
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/startRealtimePolling");
+
+        //wait some time to start polling
+        TimeUnit.SECONDS.sleep(3);
+        write("_realtime1", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime2", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime3", SplunkTestResource.TEST_INDEX, "submit");
+        //wait some time to gather the pulls from splunk server
+        TimeUnit.SECONDS.sleep(3);
+        //there should be some data from realtime search in direct (concrete values depends on the speed of writing into index)
+        //test is asserting that there are some
+        RestAssured.get("/splunk/directRealtimePolling")
+                .then()
+                .statusCode(200)
+                .body(containsString("_realtime"));
+    }
+
+    @Test
+    public void testWriteStreamAndReadSaved() throws InterruptedException {
+        int defaultPort = RestAssured.port;
+        String defaultUri = RestAssured.baseURI;
+
+        try {
+            RestAssured.port = Integer.parseInt(System.getProperty(SplunkResource.PARAM_REMOTE_PORT));
+            RestAssured.baseURI = "http://localhost";

Review comment:
       done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596211206



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    private boolean initialized;
+
+    private void initialize() {
+        if (!initialized) {
+            SplunkComponent sc = camelContext.getComponent("splunk", SplunkComponent.class);

Review comment:
       Just to be sure. Would it work to initialize the component once in that way https://camel.apache.org/camel-quarkus/latest/user-guide/bootstrap.html#_cdi ? Or maybe the config factory is needed only for a specific set of tests ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596691995



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,150 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+class SplunkTest {
+
+    @Test
+    public void testWriteTcpAndReadNormal() {
+        write("_normal", SplunkTestResource.TEST_INDEX, "tcp");
+
+        List<Map<String, String>> result = RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/normal")
+                .then()
+                .statusCode(200)
+                .extract().as(List.class);
+
+        Assert.assertEquals(3, result.size());
+        Assert.assertEquals("Irma_normal", result.get(0).get("name"));
+        Assert.assertEquals("Earth\"", result.get(0).get("from"));
+        Assert.assertEquals("Leonard_normal", result.get(1).get("name"));
+        Assert.assertEquals("Earth 2.0\"", result.get(1).get("from"));
+        Assert.assertEquals("Sheldon_normal", result.get(2).get("name"));
+        Assert.assertEquals("Alpha Centauri\"", result.get(2).get("from"));
+    }
+
+    @Test
+    public void testWriteSubmitAndReadRealtime() throws InterruptedException, ExecutionException {
+
+        RestAssured.given()
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/startRealtimePolling");
+
+        //wait some time to start polling
+        TimeUnit.SECONDS.sleep(3);
+        write("_realtime1", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime2", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime3", SplunkTestResource.TEST_INDEX, "submit");
+        //wait some time to gather the pulls from splunk server
+        TimeUnit.SECONDS.sleep(3);
+        //there should be some data from realtime search in direct (concrete values depends on the speed of writing into index)
+        //test is asserting that there are some
+        RestAssured.get("/splunk/directRealtimePolling")
+                .then()
+                .statusCode(200)
+                .body(containsString("_realtime"));
+    }
+
+    @Test
+    public void testWriteStreamAndReadSaved() throws InterruptedException {
+        int defaultPort = RestAssured.port;
+        String defaultUri = RestAssured.baseURI;

Review comment:
       It looks cleaner indeed :+1 maybe those lines are not needed anymore ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596615002



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    private boolean initialized;
+
+    private void initialize() {
+        if (!initialized) {
+            SplunkComponent sc = camelContext.getComponent("splunk", SplunkComponent.class);

Review comment:
       Thanks for the link, I was looking for a better way of configuring component only once. I'll try to use it.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596203464



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTestResource.java
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.it;
+
+import java.time.Duration;
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class SplunkTestResource implements QuarkusTestResourceLifecycleManager {
+
+    public static String TEST_INDEX = "testindex";
+    public static String SAVED_SEARCH_NAME = "savedSearchForTest";
+    private static final int REMOTE_PORT = 8089;
+
+    private GenericContainer container;
+
+    @Override
+    public Map<String, String> start() {
+
+        try {
+            container = new GenericContainer("splunk/splunk:8.1.2")
+                    .withExposedPorts(REMOTE_PORT)
+                    .withExposedPorts(SplunkResource.LOCAL_TCP_PORT)
+                    .withEnv("SPLUNK_START_ARGS", "--accept-license")
+                    .withEnv("SPLUNK_PASSWORD", "changeit")
+                    .withEnv("SPLUNK_LICENSE_URI", "Free")
+                    .waitingFor(
+                            Wait.forLogMessage(".*Ansible playbook complete.*\\n", 1)
+                                    .withStartupTimeout(Duration.ofSeconds(120)));
+
+            container.start();
+
+            container.execInContainer("sudo", "sed", "-i", "s/allowRemoteLogin=requireSetPassword/allowRemoteLogin=always/",

Review comment:
       Hey nice trick :+1: 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#issuecomment-800896593


   @jamesnetherton  thanks, It's rebased now


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596729736



##########
File path: tooling/scripts/test-categories.yaml
##########
@@ -126,6 +126,7 @@ messaging-networking1:
   - kafka
   - messaging
   - nats
+  - splunk

Review comment:
       ^ that's not a blocker for this PR. It is rather something for the future.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga merged pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
ppalaga merged pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596201659



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+class SplunkTest {
+
+    @Test
+    public void testWriteTcpAndReadNormal() {
+        write("_normal", SplunkTestResource.TEST_INDEX, "tcp");
+
+        List<Map<String, String>> result = RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/normal")
+                .then()
+                .statusCode(200)
+                .extract().as(List.class);
+
+        Assert.assertEquals(3, result.size());
+        Assert.assertEquals("Irma_normal", result.get(0).get("name"));
+        Assert.assertEquals("Earth\"", result.get(0).get("from"));
+        Assert.assertEquals("Leonard_normal", result.get(1).get("name"));
+        Assert.assertEquals("Earth 2.0\"", result.get(1).get("from"));
+        Assert.assertEquals("Sheldon_normal", result.get(2).get("name"));
+        Assert.assertEquals("Alpha Centauri\"", result.get(2).get("from"));
+    }
+
+    @Test
+    public void testWriteSubmitAndReadRealtime() throws InterruptedException, ExecutionException {
+
+        RestAssured.given()
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/startRealtimePolling");
+
+        //wait some time to start polling
+        TimeUnit.SECONDS.sleep(3);
+        write("_realtime1", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime2", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime3", SplunkTestResource.TEST_INDEX, "submit");
+        //wait some time to gather the pulls from splunk server
+        TimeUnit.SECONDS.sleep(3);
+        //there should be some data from realtime search in direct (concrete values depends on the speed of writing into index)
+        //test is asserting that there are some
+        RestAssured.get("/splunk/directRealtimePolling")
+                .then()
+                .statusCode(200)
+                .body(containsString("_realtime"));
+    }
+
+    @Test
+    public void testWriteStreamAndReadSaved() throws InterruptedException {
+        int defaultPort = RestAssured.port;
+        String defaultUri = RestAssured.baseURI;
+
+        try {
+            RestAssured.port = Integer.parseInt(System.getProperty(SplunkResource.PARAM_REMOTE_PORT));
+            RestAssured.baseURI = "http://localhost";

Review comment:
       If I get the idea well. Maybe it's possible to use given().baseUri(), basePath() or basePort().




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r595460900



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,212 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    @Path("/normal")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public List normal(String search) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://normal?scheme=http&port=%d&delay=5000&initEarliestTime=-10s&search="
+                        + search,
+                port);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> m.getEventData().entrySet().stream()
+                        .filter(e -> !e.getKey().startsWith("_"))
+                        .collect(Collectors.toMap(
+                                Map.Entry::getKey,
+                                Map.Entry::getValue,
+                                (v1, v2) -> v1)))
+                .collect(Collectors.toList());
+
+        return result;
+    }
+
+    @Path("/savedSearch")
+    @POST
+    public String savedSearch(String name) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://savedsearch?scheme=http&port=%d&delay=500&initEarliestTime=-1m&savedsearch=%s",
+                port, name);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 5000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> {
+                    if (m == null) {
+                        return "null";
+                    }
+                    return m.getEventData().get("_raw");
+                })
+                .collect(Collectors.toList());
+
+        return result.toString();
+    }
+
+    @Path("/directRealtimePolling")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map directRealtimePolling() throws Exception {
+        before();
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody("direct:realtimePolling", 3000, SplunkEvent.class);
+
+        if (m1 == null) {
+            return Collections.emptyMap();
+        }
+
+        Map result = m1.getEventData().entrySet().stream()
+                .filter(e -> !e.getKey().startsWith("_"))
+                .collect(Collectors.toMap(
+                        Map.Entry::getKey,
+                        Map.Entry::getValue,
+                        (v1, v2) -> v1));
+
+        return result;
+    }
+
+    @Path("/startRealtimePolling")
+    @POST
+    public void startPolling(String search) {
+        before();
+        // use another thread for polling consumer to demonstrate that we can wait before
+        // the message is sent to the queue
+        Executors.newSingleThreadExecutor().execute(() -> {
+            String url = String.format(
+                    "splunk://realtime?scheme=http&port=%d&delay=3000&initEarliestTime=rt-10s&latestTime=RAW(rt+40s)&search="
+                            + search,
+                    port);
+            SplunkEvent body = consumerTemplate.receiveBody(url, SplunkEvent.class);
+            producerTemplate.sendBody("direct:realtimePolling", body);
+        });
+    }
+
+    @Path("/submit")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response submit(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "submit", index, null);
+    }
+
+    @Path("/stream")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response stream(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "stream", index, null);
+    }
+
+    @Path("/tcp")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response tcp(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "tcp", index, tcpPort);
+    }
+
+    private Response post(Map<String, String> message, String endpoint, String index, Integer tcpPort) throws Exception {
+        before();
+
+        SplunkEvent se = new SplunkEvent();
+        for (Map.Entry<String, String> e : message.entrySet()) {
+            se.addPair(e.getKey(), e.getValue());
+        }
+
+        String url = String.format(
+                "splunk:%s?scheme=http&port=%d&index=%s&sourceType=%s&source=%s",
+                endpoint, port, index, SOURCE_TYPE, SOURCE);
+        if (tcpPort != null) {
+            url = String.format(
+                    "splunk:%s?username=admin&password=changeit&scheme=http&port=%d&index=%s&sourceType=%s&source=%s&tcpReceiverLocalPort=%d&tcpReceiverPort=%d",
+                    endpoint, port, index, SOURCE_TYPE, SOURCE, LOCAL_TCP_PORT, tcpPort);
+        }
+        final String response = producerTemplate.requestBody(url, se, String.class);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    private void before() {

Review comment:
       Why do we need to set a configuration factory more than once ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r596615616



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+class SplunkTest {
+
+    @Test
+    public void testWriteTcpAndReadNormal() {
+        write("_normal", SplunkTestResource.TEST_INDEX, "tcp");
+
+        List<Map<String, String>> result = RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/normal")
+                .then()
+                .statusCode(200)
+                .extract().as(List.class);
+
+        Assert.assertEquals(3, result.size());
+        Assert.assertEquals("Irma_normal", result.get(0).get("name"));
+        Assert.assertEquals("Earth\"", result.get(0).get("from"));
+        Assert.assertEquals("Leonard_normal", result.get(1).get("name"));
+        Assert.assertEquals("Earth 2.0\"", result.get(1).get("from"));
+        Assert.assertEquals("Sheldon_normal", result.get(2).get("name"));
+        Assert.assertEquals("Alpha Centauri\"", result.get(2).get("from"));
+    }
+
+    @Test
+    public void testWriteSubmitAndReadRealtime() throws InterruptedException, ExecutionException {
+
+        RestAssured.given()
+                .body(String.format(
+                        "search index=%s sourcetype=%s | rex field=_raw \"Name: (?<name>.*) From: (?<from>.*)\"",
+                        SplunkTestResource.TEST_INDEX, SplunkResource.SOURCE_TYPE))
+                .post("/splunk/startRealtimePolling");
+
+        //wait some time to start polling
+        TimeUnit.SECONDS.sleep(3);
+        write("_realtime1", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime2", SplunkTestResource.TEST_INDEX, "submit");
+        TimeUnit.SECONDS.sleep(1);
+        write("_realtime3", SplunkTestResource.TEST_INDEX, "submit");
+        //wait some time to gather the pulls from splunk server
+        TimeUnit.SECONDS.sleep(3);
+        //there should be some data from realtime search in direct (concrete values depends on the speed of writing into index)
+        //test is asserting that there are some
+        RestAssured.get("/splunk/directRealtimePolling")
+                .then()
+                .statusCode(200)
+                .body(containsString("_realtime"));
+    }
+
+    @Test
+    public void testWriteStreamAndReadSaved() throws InterruptedException {
+        int defaultPort = RestAssured.port;
+        String defaultUri = RestAssured.baseURI;
+
+        try {
+            RestAssured.port = Integer.parseInt(System.getProperty(SplunkResource.PARAM_REMOTE_PORT));
+            RestAssured.baseURI = "http://localhost";

Review comment:
       ha, nicer way, I'll try it. (I wrote it  and at that moment I wasn't thinking about a better approach, because it worked)                  




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r595769689



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,212 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    @Path("/normal")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public List normal(String search) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://normal?scheme=http&port=%d&delay=5000&initEarliestTime=-10s&search="
+                        + search,
+                port);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> m.getEventData().entrySet().stream()
+                        .filter(e -> !e.getKey().startsWith("_"))
+                        .collect(Collectors.toMap(
+                                Map.Entry::getKey,
+                                Map.Entry::getValue,
+                                (v1, v2) -> v1)))
+                .collect(Collectors.toList());
+
+        return result;
+    }
+
+    @Path("/savedSearch")
+    @POST
+    public String savedSearch(String name) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://savedsearch?scheme=http&port=%d&delay=500&initEarliestTime=-1m&savedsearch=%s",
+                port, name);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 5000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> {
+                    if (m == null) {
+                        return "null";
+                    }
+                    return m.getEventData().get("_raw");
+                })
+                .collect(Collectors.toList());
+
+        return result.toString();
+    }
+
+    @Path("/directRealtimePolling")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map directRealtimePolling() throws Exception {
+        before();
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody("direct:realtimePolling", 3000, SplunkEvent.class);
+
+        if (m1 == null) {
+            return Collections.emptyMap();
+        }
+
+        Map result = m1.getEventData().entrySet().stream()
+                .filter(e -> !e.getKey().startsWith("_"))
+                .collect(Collectors.toMap(
+                        Map.Entry::getKey,
+                        Map.Entry::getValue,
+                        (v1, v2) -> v1));
+
+        return result;
+    }
+
+    @Path("/startRealtimePolling")
+    @POST
+    public void startPolling(String search) {
+        before();
+        // use another thread for polling consumer to demonstrate that we can wait before
+        // the message is sent to the queue
+        Executors.newSingleThreadExecutor().execute(() -> {
+            String url = String.format(
+                    "splunk://realtime?scheme=http&port=%d&delay=3000&initEarliestTime=rt-10s&latestTime=RAW(rt+40s)&search="
+                            + search,
+                    port);
+            SplunkEvent body = consumerTemplate.receiveBody(url, SplunkEvent.class);
+            producerTemplate.sendBody("direct:realtimePolling", body);
+        });
+    }
+
+    @Path("/submit")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response submit(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "submit", index, null);
+    }
+
+    @Path("/stream")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response stream(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "stream", index, null);
+    }
+
+    @Path("/tcp")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response tcp(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "tcp", index, tcpPort);
+    }
+
+    private Response post(Map<String, String> message, String endpoint, String index, Integer tcpPort) throws Exception {
+        before();
+
+        SplunkEvent se = new SplunkEvent();
+        for (Map.Entry<String, String> e : message.entrySet()) {
+            se.addPair(e.getKey(), e.getValue());
+        }
+
+        String url = String.format(
+                "splunk:%s?scheme=http&port=%d&index=%s&sourceType=%s&source=%s",
+                endpoint, port, index, SOURCE_TYPE, SOURCE);
+        if (tcpPort != null) {
+            url = String.format(
+                    "splunk:%s?username=admin&password=changeit&scheme=http&port=%d&index=%s&sourceType=%s&source=%s&tcpReceiverLocalPort=%d&tcpReceiverPort=%d",
+                    endpoint, port, index, SOURCE_TYPE, SOURCE, LOCAL_TCP_PORT, tcpPort);
+        }
+        final String response = producerTemplate.requestBody(url, se, String.class);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    private void before() {

Review comment:
       Yes, you are right, I'll refactor code to configure component once, thanks.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#issuecomment-800980497


   Test failure is caused by some problems with maven:
   >  Could not transfer artifact com.google.guava:guava:jar:14.0.1 from/to central (https://repo.maven.apache.org/maven2)


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#issuecomment-801736955


   @aldettinger Thanks for the hints. It helped a lot and now the code looks much better. All requested changes are fixed.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r595461582



##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)

Review comment:
       Without splunk knowledge, I read the tests as isolated. Why is the test order needed ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#issuecomment-800891400


   @JiriOndrusek you'll need to rebase on the latest camel-master. I had to force push the branch to fix some issues.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] JiriOndrusek commented on a change in pull request #2339: Splunk native support #1698

Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on a change in pull request #2339:
URL: https://github.com/apache/camel-quarkus/pull/2339#discussion_r595804660



##########
File path: integration-tests/splunk/src/main/java/org/apache/camel/quarkus/component/splunk/it/SplunkResource.java
##########
@@ -0,0 +1,212 @@
+/*
+ * 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.it;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.splunk.SplunkComponent;
+import org.apache.camel.component.splunk.SplunkConfiguration;
+import org.apache.camel.component.splunk.event.SplunkEvent;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/splunk")
+@ApplicationScoped
+public class SplunkResource {
+
+    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 String SOURCE_TYPE = "testSource";
+    public static final int LOCAL_TCP_PORT = 9998;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = PARAM_REMOTE_PORT)
+    Integer port;
+
+    @ConfigProperty(name = PARAM_TCP_PORT)
+    Integer tcpPort;
+
+    @Inject
+    CamelContext camelContext;
+
+    @Path("/normal")
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public List normal(String search) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://normal?scheme=http&port=%d&delay=5000&initEarliestTime=-10s&search="
+                        + search,
+                port);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> m.getEventData().entrySet().stream()
+                        .filter(e -> !e.getKey().startsWith("_"))
+                        .collect(Collectors.toMap(
+                                Map.Entry::getKey,
+                                Map.Entry::getValue,
+                                (v1, v2) -> v1)))
+                .collect(Collectors.toList());
+
+        return result;
+    }
+
+    @Path("/savedSearch")
+    @POST
+    public String savedSearch(String name) throws Exception {
+        before();
+
+        String url = String.format(
+                "splunk://savedsearch?scheme=http&port=%d&delay=500&initEarliestTime=-1m&savedsearch=%s",
+                port, name);
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody(url, 5000, SplunkEvent.class);
+        final SplunkEvent m2 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+        final SplunkEvent m3 = consumerTemplate.receiveBody(url, 1000, SplunkEvent.class);
+
+        List result = Arrays.stream(new SplunkEvent[] { m1, m2, m3 })
+                .map(m -> {
+                    if (m == null) {
+                        return "null";
+                    }
+                    return m.getEventData().get("_raw");
+                })
+                .collect(Collectors.toList());
+
+        return result.toString();
+    }
+
+    @Path("/directRealtimePolling")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map directRealtimePolling() throws Exception {
+        before();
+
+        final SplunkEvent m1 = consumerTemplate.receiveBody("direct:realtimePolling", 3000, SplunkEvent.class);
+
+        if (m1 == null) {
+            return Collections.emptyMap();
+        }
+
+        Map result = m1.getEventData().entrySet().stream()
+                .filter(e -> !e.getKey().startsWith("_"))
+                .collect(Collectors.toMap(
+                        Map.Entry::getKey,
+                        Map.Entry::getValue,
+                        (v1, v2) -> v1));
+
+        return result;
+    }
+
+    @Path("/startRealtimePolling")
+    @POST
+    public void startPolling(String search) {
+        before();
+        // use another thread for polling consumer to demonstrate that we can wait before
+        // the message is sent to the queue
+        Executors.newSingleThreadExecutor().execute(() -> {
+            String url = String.format(
+                    "splunk://realtime?scheme=http&port=%d&delay=3000&initEarliestTime=rt-10s&latestTime=RAW(rt+40s)&search="
+                            + search,
+                    port);
+            SplunkEvent body = consumerTemplate.receiveBody(url, SplunkEvent.class);
+            producerTemplate.sendBody("direct:realtimePolling", body);
+        });
+    }
+
+    @Path("/submit")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response submit(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "submit", index, null);
+    }
+
+    @Path("/stream")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response stream(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "stream", index, null);
+    }
+
+    @Path("/tcp")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response tcp(Map<String, String> message, @QueryParam("index") String index) throws Exception {
+        return post(message, "tcp", index, tcpPort);
+    }
+
+    private Response post(Map<String, String> message, String endpoint, String index, Integer tcpPort) throws Exception {
+        before();
+
+        SplunkEvent se = new SplunkEvent();
+        for (Map.Entry<String, String> e : message.entrySet()) {
+            se.addPair(e.getKey(), e.getValue());
+        }
+
+        String url = String.format(
+                "splunk:%s?scheme=http&port=%d&index=%s&sourceType=%s&source=%s",
+                endpoint, port, index, SOURCE_TYPE, SOURCE);
+        if (tcpPort != null) {
+            url = String.format(
+                    "splunk:%s?username=admin&password=changeit&scheme=http&port=%d&index=%s&sourceType=%s&source=%s&tcpReceiverLocalPort=%d&tcpReceiverPort=%d",
+                    endpoint, port, index, SOURCE_TYPE, SOURCE, LOCAL_TCP_PORT, tcpPort);
+        }
+        final String response = producerTemplate.requestBody(url, se, String.class);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    private void before() {

Review comment:
       done

##########
File path: integration-tests/splunk/src/test/java/org/apache/camel/quarkus/component/splunk/it/SplunkTest.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.util.CollectionHelper;
+import org.junit.Assert;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(SplunkTestResource.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)

Review comment:
       done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org