This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 7da7ce7 InfluxDB native support #1036
7da7ce7 is described below
commit 7da7ce71cfb6edd143820ef0324c80beac88013c
Author: JiriOndrusek <[email protected]>
AuthorDate: Wed Apr 8 16:52:29 2020 +0200
InfluxDB native support #1036
---
.github/workflows/pr-build.yaml | 1 +
.../pages/list-of-camel-quarkus-extensions.adoc | 4 +-
.../influxdb/deployment/InfluxdbProcessor.java | 47 --------
.../component/influxdb/it/InfluxdbResource.java | 51 --------
extensions-jvm/pom.xml | 1 -
.../influxdb/deployment/pom.xml | 4 +
.../influxdb/deployment/InfluxdbProcessor.java | 71 +++++++++++
{extensions-jvm => extensions}/influxdb/pom.xml | 1 -
.../influxdb/runtime/pom.xml | 4 +
.../main/resources/META-INF/quarkus-extension.yaml | 6 +-
extensions/pom.xml | 1 +
.../influxdb}/pom.xml | 64 +++++++++-
.../component/influxdb/it/InfluxdbResource.java | 134 +++++++++++++++++++++
.../camel/quarkus/component/influxdb/it/Point.java | 65 ++++++++++
.../quarkus/component/influxdb/it/Points.java | 49 ++++++--
.../quarkus/component/influxdb/it/InfluxdbIT.java | 17 +--
.../component/influxdb/it/InfluxdbTest.java | 131 ++++++++++++++++++++
.../influxdb/it/InfluxdbTestResource.java | 67 +++++++++++
integration-tests/pom.xml | 1 +
19 files changed, 583 insertions(+), 136 deletions(-)
diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml
index f7eda72..2472e4f 100644
--- a/.github/workflows/pr-build.yaml
+++ b/.github/workflows/pr-build.yaml
@@ -208,6 +208,7 @@ jobs:
- category: SQL
test-modules: >
couchdb
+ influxdb
jdbc
mongodb
sql
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 5f801af..3a85d4c 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -330,8 +330,8 @@ Level | Since | Description
Stable | 0.2.0 | For reading/writing from/to Infinispan distributed key/value
store and data grid.
|
link:https://camel.apache.org/components/latest/influxdb-component.html[InfluxDB]
(camel-quarkus-influxdb) +
-`influxdb:connectionBean` | JVM +
- Preview | 1.0.0-M6 | The influxdb component allows you to interact with
InfluxDB, a time series database.
+`influxdb:connectionBean` | Native +
+ Stable | 1.0.0-M6 | The influxdb component allows you to interact with
InfluxDB, a time series database.
| xref:extensions/websocket-jsr356.adoc[Javax Websocket]
(camel-quarkus-websocket-jsr356) +
`websocket-jsr356:uri` | Native +
diff --git
a/extensions-jvm/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
b/extensions-jvm/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
deleted file mode 100644
index 6af0084..0000000
---
a/extensions-jvm/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.influxdb.deployment;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
-
-class InfluxdbProcessor {
- private static final Logger LOG =
Logger.getLogger(InfluxdbProcessor.class);
-
- private static final String FEATURE = "camel-influxdb";
-
- @BuildStep
- FeatureBuildItem feature() {
- return new FeatureBuildItem(FEATURE);
- }
-
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
- }
-
-}
diff --git
a/extensions-jvm/influxdb/integration-test/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
b/extensions-jvm/influxdb/integration-test/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
deleted file mode 100644
index 23d07fa..0000000
---
a/extensions-jvm/influxdb/integration-test/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.influxdb.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/influxdb")
-@ApplicationScoped
-public class InfluxdbResource {
-
- private static final Logger LOG = Logger.getLogger(InfluxdbResource.class);
-
- private static final String COMPONENT_INFLUXDB = "influxdb";
- @Inject
- CamelContext context;
-
- @Path("/load/component/influxdb")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentInfluxdb() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_INFLUXDB) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context",
COMPONENT_INFLUXDB);
- return Response.status(500, COMPONENT_INFLUXDB + " could not be loaded
from the Camel context").build();
- }
-}
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 0dc9b5f..baf3a27 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -59,7 +59,6 @@
<module>google-pubsub</module>
<module>groovy</module>
<module>grpc</module>
- <module>influxdb</module>
<module>kubernetes</module>
<module>kudu</module>
<module>mongodb-gridfs</module>
diff --git a/extensions-jvm/influxdb/deployment/pom.xml
b/extensions/influxdb/deployment/pom.xml
similarity index 94%
rename from extensions-jvm/influxdb/deployment/pom.xml
rename to extensions/influxdb/deployment/pom.xml
index 2d8fcd0..2559e0f 100644
--- a/extensions-jvm/influxdb/deployment/pom.xml
+++ b/extensions/influxdb/deployment/pom.xml
@@ -50,6 +50,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-influxdb</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-retrofit-deployment</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git
a/extensions/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
b/extensions/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
new file mode 100644
index 0000000..8df98a7
--- /dev/null
+++
b/extensions/influxdb/deployment/src/main/java/org/apache/camel/quarkus/component/influxdb/deployment/InfluxdbProcessor.java
@@ -0,0 +1,71 @@
+/*
+ * 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.influxdb.deployment;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+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.NativeImageProxyDefinitionBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.jboss.jandex.IndexView;
+
+class InfluxdbProcessor {
+
+ private static String INFLUXDB_DTO_PACKAGE = "org.influxdb.dto";
+
+ private static final String FEATURE = "camel-influxdb";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void sslSupport(BuildProducer<ExtensionSslNativeSupportBuildItem>
extensionSslNativeSupport) {
+
+ // Indicates that this extension would like the SSL support to be
enabled
+ extensionSslNativeSupport.produce(new
ExtensionSslNativeSupportBuildItem(FEATURE));
+ }
+
+ @BuildStep
+ void clientProxies(BuildProducer<NativeImageProxyDefinitionBuildItem>
proxies) {
+ proxies.produce(new
NativeImageProxyDefinitionBuildItem("org.influxdb.impl.InfluxDBService"));
+ }
+
+ @BuildStep
+ ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem
combinedIndex) {
+ IndexView index = combinedIndex.getIndex();
+
+ String[] dtos = index.getKnownClasses().stream()
+ .map(ci -> ci.name().toString())
+ .filter(n -> n.startsWith(INFLUXDB_DTO_PACKAGE))
+ .sorted()
+ .toArray(String[]::new);
+
+ return new ReflectiveClassBuildItem(false, true, dtos);
+ }
+
+ @BuildStep
+ IndexDependencyBuildItem registerDependencyForIndex() {
+ return new IndexDependencyBuildItem("org.influxdb", "influxdb-java");
+ }
+
+}
diff --git a/extensions-jvm/influxdb/pom.xml b/extensions/influxdb/pom.xml
similarity index 97%
rename from extensions-jvm/influxdb/pom.xml
rename to extensions/influxdb/pom.xml
index 0582139..0bdfad8 100644
--- a/extensions-jvm/influxdb/pom.xml
+++ b/extensions/influxdb/pom.xml
@@ -33,6 +33,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/influxdb/runtime/pom.xml
b/extensions/influxdb/runtime/pom.xml
similarity index 95%
rename from extensions-jvm/influxdb/runtime/pom.xml
rename to extensions/influxdb/runtime/pom.xml
index cd6c7d0..fa98fce 100644
--- a/extensions-jvm/influxdb/runtime/pom.xml
+++ b/extensions/influxdb/runtime/pom.xml
@@ -55,6 +55,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-influxdb</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-retrofit</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git
a/extensions-jvm/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
b/extensions/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 89%
rename from
extensions-jvm/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to
extensions/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index d198b0d..157b167 100644
---
a/extensions-jvm/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++
b/extensions/influxdb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -19,10 +19,10 @@
name: "InfluxDB"
description: "The influxdb component allows you to interact with InfluxDB, a
time series database."
metadata:
- unlisted: true
keywords:
+ - "camel"
- "database"
- guide: "https://camel.apache.org/components/latest/influxdb-component.html"
+ guide: "https://quarkus.io/guides/camel"
categories:
- "integration"
- status: "preview"
+ status: "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 5e7598e..031bd6d 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -85,6 +85,7 @@
<module>hystrix</module>
<module>ical</module>
<module>infinispan</module>
+ <module>influxdb</module>
<module>jackson</module>
<module>jacksonxml</module>
<module>jaxb</module>
diff --git a/extensions-jvm/influxdb/integration-test/pom.xml
b/integration-tests/influxdb/pom.xml
similarity index 57%
rename from extensions-jvm/influxdb/integration-test/pom.xml
rename to integration-tests/influxdb/pom.xml
index 7e4990e..debf42f 100644
--- a/extensions-jvm/influxdb/integration-test/pom.xml
+++ b/integration-tests/influxdb/pom.xml
@@ -17,16 +17,18 @@
limitations under the License.
-->
-<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">
+<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-influxdb-parent</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
- <artifactId>camel-quarkus-influxdb-integration-test</artifactId>
- <name>Camel Quarkus :: InfluxDB :: Integration Test</name>
+ <artifactId>camel-quarkus-integration-test-influxdb</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: InfluxDB</name>
<description>Integration tests for Camel Quarkus InfluxDB
extension</description>
<properties>
@@ -39,6 +41,18 @@
<mvnd.builder.rule>camel-quarkus-influxdb-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
</properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-test</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -48,6 +62,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -60,6 +78,13 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- test dependencies - camel-quarkus -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -77,4 +102,35 @@
</plugin>
</plugins>
</build>
+
+ <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>
+ </profiles>
+
</project>
diff --git
a/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
new file mode 100644
index 0000000..ad53101
--- /dev/null
+++
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbResource.java
@@ -0,0 +1,134 @@
+/*
+ * 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.influxdb.it;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+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.core.MediaType;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.influxdb.InfluxDbConstants;
+import org.influxdb.InfluxDB;
+import org.influxdb.InfluxDBFactory;
+import org.influxdb.dto.BatchPoints;
+import org.influxdb.dto.Pong;
+import org.influxdb.dto.Query;
+import org.influxdb.dto.QueryResult;
+import org.jboss.logging.Logger;
+
+@Path("/influxdb")
+@ApplicationScoped
+public class InfluxdbResource {
+
+ private static final Logger LOG = Logger.getLogger(InfluxdbResource.class);
+
+ public static final String DB_NAME = "myTestTimeSeries";
+
+ public static final String INFLUXDB_CONNECTION_PROPERTY =
"quarkus.influxdb.connection.url";
+ public static final String INFLUXDB_VERSION = "1.7.10";
+
+ private static final String INFLUXDB_CONNECTION = "http://{{" +
INFLUXDB_CONNECTION_PROPERTY + "}}/";
+ private static final String INFLUXDB_CONNECTION_NAME =
"influxDb_connection";
+ private static final String INFLUXDB_ENDPOINT_URL = "influxdb:" +
INFLUXDB_CONNECTION_NAME;
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Inject
+ CamelContext context;
+
+ private InfluxDB influxDB;
+
+ void onStart(@Observes
org.apache.camel.quarkus.core.CamelMainEvents.BeforeConfigure ev) {
+ influxDB =
InfluxDBFactory.connect(context.getPropertiesComponent().parseUri(INFLUXDB_CONNECTION));
+
+ influxDB.query(new Query("CREATE DATABASE " + DB_NAME));
+
+ context.getRegistry().bind(INFLUXDB_CONNECTION_NAME, influxDB);
+ }
+
+ void beforeStop(@Observes
org.apache.camel.quarkus.core.CamelMainEvents.BeforeStop ev) {
+ if (influxDB != null) {
+ influxDB.query(new Query("DROP DATABASE " + DB_NAME, ""));
+ influxDB.close();
+ }
+ }
+
+ @Path("/ping")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String ping() {
+ Pong pong = producerTemplate.requestBody(INFLUXDB_ENDPOINT_URL +
"?operation=ping", null, Pong.class);
+
+ return pong.getVersion();
+ }
+
+ @Path("/insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.TEXT_PLAIN)
+ public boolean insert(Point point) {
+ org.influxdb.dto.Point p = point.toPoint();
+
+ org.influxdb.dto.Point result = producerTemplate.requestBody(
+ INFLUXDB_ENDPOINT_URL + "?databaseName=" + DB_NAME +
"&operation=insert&retentionPolicy=autogen", p,
+ org.influxdb.dto.Point.class);
+
+ return result != null;
+ }
+
+ @Path("/batch")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String batch(Points points) {
+ BatchPoints p = points.toBatchPoints();
+
+ BatchPoints result =
producerTemplate.requestBody(INFLUXDB_ENDPOINT_URL + "?batch=true", p,
+ BatchPoints.class);
+
+ return String.valueOf(result.getPoints().size());
+ }
+
+ @Path("/query")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String query(String query) throws Exception {
+ Exchange exchange = producerTemplate.request(
+ INFLUXDB_ENDPOINT_URL + "?databaseName=" + DB_NAME +
"&operation=query&retentionPolicy=autogen",
+ e -> e.getIn().setHeader(InfluxDbConstants.INFLUXDB_QUERY,
query));
+ List<QueryResult.Result> results =
exchange.getMessage().getBody(QueryResult.class).getResults();
+ return results.stream()
+ .flatMap(r -> r.getSeries() != null ? r.getSeries().stream() :
null)
+ .map(s -> s.getName())
+ .collect(Collectors.joining(", "));
+
+ }
+
+}
diff --git
a/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Point.java
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Point.java
new file mode 100644
index 0000000..87b343d
--- /dev/null
+++
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Point.java
@@ -0,0 +1,65 @@
+/*
+ * 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.influxdb.it;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class Point {
+
+ private String measurement;
+ private Long time;
+ private Map<String, Long> fields = new HashMap<>();
+
+ public String getMeasurement() {
+ return measurement;
+ }
+
+ public void setMeasurement(String measurement) {
+ this.measurement = measurement;
+ }
+
+ public Long getTime() {
+ return time;
+ }
+
+ public void setTime(Long time) {
+ this.time = time;
+ }
+
+ public Map<String, Long> getFields() {
+ return fields;
+ }
+
+ public void addField(String key, Long value) {
+ this.fields.put(key, value);
+ }
+
+ public void setFields(Map<String, Long> fields) {
+ this.fields = fields;
+ }
+
+ public org.influxdb.dto.Point toPoint() {
+ org.influxdb.dto.Point.Builder pointBuilder =
org.influxdb.dto.Point.measurement(this.measurement)
+ .time(this.time, TimeUnit.MILLISECONDS);
+
+ this.fields.entrySet().stream().forEach(e ->
pointBuilder.addField(e.getKey(), e.getValue()));
+
+ return pointBuilder.build();
+ }
+}
diff --git
a/extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Points.java
similarity index 52%
copy from
extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
copy to
integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Points.java
index d5b458c..821e11d 100644
---
a/extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
+++
b/integration-tests/influxdb/src/main/java/org/apache/camel/quarkus/component/influxdb/it/Points.java
@@ -16,19 +16,42 @@
*/
package org.apache.camel.quarkus.component.influxdb.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class InfluxdbTest {
-
- @Test
- public void loadComponentInfluxdb() {
- /* A simple autogenerated test */
- RestAssured.get("/influxdb/load/component/influxdb")
- .then()
- .statusCode(200);
+import java.util.ArrayList;
+import java.util.List;
+
+import org.influxdb.dto.BatchPoints;
+
+public class Points {
+
+ private String database;
+
+ private List<Point> points = new ArrayList<>();
+
+ public String getDatabase() {
+ return database;
+ }
+
+ public void setDatabase(String database) {
+ this.database = database;
+ }
+
+ public void addPoint(Point point) {
+ this.points.add(point);
+ }
+
+ public List<Point> getPoints() {
+ return points;
+ }
+
+ public void setPoints(List<Point> points) {
+ this.points = points;
}
+ public BatchPoints toBatchPoints() {
+ BatchPoints.Builder batchPoints = BatchPoints.database(this.database);
+
+ points.forEach(p -> batchPoints.point(p.toPoint()));
+
+ return batchPoints.build();
+ }
}
diff --git
a/extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbIT.java
similarity index 70%
rename from
extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
rename to
integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbIT.java
index d5b458c..a7a1e21 100644
---
a/extensions-jvm/influxdb/integration-test/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
+++
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbIT.java
@@ -16,19 +16,8 @@
*/
package org.apache.camel.quarkus.component.influxdb.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class InfluxdbTest {
-
- @Test
- public void loadComponentInfluxdb() {
- /* A simple autogenerated test */
- RestAssured.get("/influxdb/load/component/influxdb")
- .then()
- .statusCode(200);
- }
+import io.quarkus.test.junit.NativeImageTest;
+@NativeImageTest
+class InfluxdbIT extends InfluxdbTest {
}
diff --git
a/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
new file mode 100644
index 0000000..86190f7
--- /dev/null
+++
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.influxdb.it;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.component.influxdb.InfluxDbConstants;
+import org.apache.camel.component.influxdb.converters.CamelInfluxDbConverters;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@QuarkusTest
+@QuarkusTestResource(InfluxdbTestResource.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class InfluxdbTest {
+
+ @Test
+ @Order(1)
+ public void pingTest() {
+
RestAssured.given().get("/influxdb/ping").then().body(is(InfluxdbResource.INFLUXDB_VERSION));
+ }
+
+ @Test
+ @Order(2)
+ public void insertTest() {
+
+ Point point = createBatchPoints().getPoints().get(0);
+ RestAssured.given() //
+ .contentType(ContentType.JSON)
+ .body(point)
+ .post("/influxdb/insert")
+ .then()
+ .statusCode(200)
+ .body(is("true"));
+
+ }
+
+ @Test
+ @Order(3)
+ public void batchInsertTest() {
+
+ Points points = createBatchPoints();
+ RestAssured.given() //
+ .contentType(ContentType.JSON)
+ .body(points)
+ .post("/influxdb/batch")
+ .then()
+ .statusCode(200)
+ .body(is("2"));
+ }
+
+ @Test
+ @Order(4)
+ public void queryTest() {
+ // result should contain only 1 result with name 'cpu', because 'cpu'
is only part of batchInsert, which was executed before
+ RestAssured.given() //
+ .contentType(ContentType.TEXT)
+ .body("select * from cpu")
+ .post("/influxdb/query")
+ .then()
+ .statusCode(200)
+ .body(is("cpu"));
+ }
+
+ @Test
+ @Order(5)
+ public void doesNotAddCamelHeaders() {
+ Map<String, Object> pointInMapFormat = new HashMap<>();
+ pointInMapFormat.put(InfluxDbConstants.MEASUREMENT_NAME, "testCPU");
+ double value = 99.999999d;
+ pointInMapFormat.put("busy", value);
+
+ org.influxdb.dto.Point p =
CamelInfluxDbConverters.fromMapToPoint(pointInMapFormat);
+ assertNotNull(p);
+
+ String line = p.lineProtocol();
+
+ assertNotNull(line);
+
+ assertTrue(!line.contains(InfluxDbConstants.MEASUREMENT_NAME));
+
+ }
+
+ private Points createBatchPoints() {
+ Points points = new Points();
+ points.setDatabase(InfluxdbResource.DB_NAME);
+
+ Point point1 = new Point();
+ point1.setMeasurement("disk");
+ point1.setTime(System.currentTimeMillis());
+ point1.addField("idle", 90L);
+ point1.addField("user", 9L);
+ point1.addField("system", 1L);
+
+ Point point2 = new Point();
+ point2.setMeasurement("cpu");
+ point2.setTime(System.currentTimeMillis());
+ point2.addField("used", 8L);
+ point2.addField("free", 1L);
+
+ points.addPoint(point1);
+ points.addPoint(point2);
+
+ return points;
+ }
+}
diff --git
a/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTestResource.java
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTestResource.java
new file mode 100644
index 0000000..710de83
--- /dev/null
+++
b/integration-tests/influxdb/src/test/java/org/apache/camel/quarkus/component/influxdb/it/InfluxdbTestResource.java
@@ -0,0 +1,67 @@
+/*
+ * 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.influxdb.it;
+
+import java.util.Map;
+
+import
org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.utility.TestcontainersConfiguration;
+
+public class InfluxdbTestResource implements ContainerResourceLifecycleManager
{
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(InfluxdbTestResource.class);
+ private static final int INFLUXDB_PORT = 8086;
+ private static final String INFLUXDB_IMAGE = "influxdb:" +
InfluxdbResource.INFLUXDB_VERSION;
+
+ private GenericContainer container;
+
+ @Override
+ public Map<String, String> start() {
+ LOGGER.info(TestcontainersConfiguration.getInstance().toString());
+
+ try {
+ container = new GenericContainer(INFLUXDB_IMAGE)
+ .withExposedPorts(INFLUXDB_PORT)
+ .waitingFor(Wait.forListeningPort());
+
+ container.start();
+
+ return CollectionHelper.mapOf(
+ InfluxdbResource.INFLUXDB_CONNECTION_PROPERTY,
+ container.getContainerIpAddress() + ":" +
container.getMappedPort(INFLUXDB_PORT));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void stop() {
+ try {
+ if (container != null) {
+ container.stop();
+ }
+ } catch (Exception e) {
+ // ignored
+ }
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index f520f90..b116deb 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -84,6 +84,7 @@
<module>http</module>
<module>hystrix</module>
<module>infinispan</module>
+ <module>influxdb</module>
<module>jaxb</module>
<module>jdbc</module>
<module>jira</module>