You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2020/12/17 09:29:48 UTC
[camel-kafka-connector] branch master updated: Align ElasticSearch
tests with test infra from Camel 3.7
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git
The following commit(s) were added to refs/heads/master by this push:
new 47cf546 Align ElasticSearch tests with test infra from Camel 3.7
47cf546 is described below
commit 47cf54685a6928b4c736a12cfc4af02bd01bcaa5
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Thu Dec 17 09:28:10 2020 +0100
Align ElasticSearch tests with test infra from Camel 3.7
---
tests/itests-elasticsearch/pom.xml | 25 ++++----
.../ElasticSearchLocalContainerService.java | 67 ----------------------
.../services/ElasticSearchService.java | 53 -----------------
.../services/ElasticSearchServiceFactory.java | 44 --------------
.../services/RemoteElasticSearchService.java | 48 ----------------
.../sink/CamelSinkElasticSearchITCase.java | 6 +-
6 files changed, 14 insertions(+), 229 deletions(-)
diff --git a/tests/itests-elasticsearch/pom.xml b/tests/itests-elasticsearch/pom.xml
index 07e0b9b..02d4e13 100644
--- a/tests/itests-elasticsearch/pom.xml
+++ b/tests/itests-elasticsearch/pom.xml
@@ -37,27 +37,26 @@
<scope>test</scope>
</dependency>
+ <!-- test infra -->
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-elasticsearch-rest</artifactId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
</dependency>
- <!--
- This one is (temporarily) needed for providing supporting classes for the
- ConnectRecordValueToMapTransformer - which is needed to properly convert record formats from
- ElasticSearch to Kafka
- -->
<dependency>
- <groupId>org.apache.camel.kafkaconnector</groupId>
- <artifactId>camel-kafka-connector</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-elasticsearch</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>elasticsearch</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-elasticsearch-rest</artifactId>
</dependency>
</dependencies>
diff --git a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchLocalContainerService.java b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchLocalContainerService.java
deleted file mode 100644
index f8aeb44..0000000
--- a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchLocalContainerService.java
+++ /dev/null
@@ -1,67 +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.kafkaconnector.elasticsearch.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-
-public class ElasticSearchLocalContainerService implements ElasticSearchService {
- private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchLocalContainerService.class);
- private static final String DEFAULT_ELASTIC_SEARCH_CONTAINER = "docker.elastic.co/elasticsearch/elasticsearch-oss:7.3.2";
- private static final int ELASTIC_SEARCH_PORT = 9200;
-
- public ElasticsearchContainer container;
-
- public ElasticSearchLocalContainerService() {
- String containerName = System.getProperty("elasticsearch.container");
-
- if (containerName == null || containerName.isEmpty()) {
- containerName = DEFAULT_ELASTIC_SEARCH_CONTAINER;
- }
-
- container = new ElasticsearchContainer(containerName);
- container.start();
- }
-
- @Override
- public int getPort() {
- return container.getMappedPort(ELASTIC_SEARCH_PORT);
- }
-
- @Override
- public String getElasticSearchHost() {
- return container.getHost();
- }
-
- @Override
- public String getHttpHostAddress() {
- return container.getHttpHostAddress();
- }
-
- @Override
- public void initialize() {
- LOG.info("ElasticSearch instance running at {}", getHttpHostAddress());
- }
-
- @Override
- public void shutdown() {
- LOG.info("Stopping the ElasticSearch container");
- container.stop();
- }
-}
diff --git a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchService.java b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchService.java
deleted file mode 100644
index 8d673d7..0000000
--- a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchService.java
+++ /dev/null
@@ -1,53 +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.kafkaconnector.elasticsearch.services;
-
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-public interface ElasticSearchService extends BeforeAllCallback, AfterAllCallback {
-
- int getPort();
-
- String getElasticSearchHost();
-
- default String getHttpHostAddress() {
- return String.format("%s:%d", getElasticSearchHost(), getPort());
- }
-
- /**
- * Perform any initialization necessary
- */
- void initialize();
-
- /**
- * Shuts down the service after the test has completed
- */
- void shutdown();
-
- @Override
- default void beforeAll(ExtensionContext extensionContext) throws Exception {
- initialize();
- }
-
- @Override
- default void afterAll(ExtensionContext extensionContext) throws Exception {
- shutdown();
- }
-}
diff --git a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchServiceFactory.java b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchServiceFactory.java
deleted file mode 100644
index 8fbd704..0000000
--- a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/ElasticSearchServiceFactory.java
+++ /dev/null
@@ -1,44 +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.kafkaconnector.elasticsearch.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class ElasticSearchServiceFactory {
- private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchServiceFactory.class);
-
- private ElasticSearchServiceFactory() {
-
- }
-
- public static ElasticSearchService createService() {
- String instanceType = System.getProperty("elasticsearch.instance.type");
-
- if (instanceType == null || instanceType.equals("local-elasticsearch-container")) {
- return new ElasticSearchLocalContainerService();
- }
-
- if (instanceType.equals("remote")) {
- return new RemoteElasticSearchService();
- }
-
- LOG.error("Cassandra instance must be one of 'local-elasticsearch-container' or 'remote");
- throw new UnsupportedOperationException("Invalid ElasticSearch instance type");
- }
-}
diff --git a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/RemoteElasticSearchService.java b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/RemoteElasticSearchService.java
deleted file mode 100644
index d0ffde8..0000000
--- a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/services/RemoteElasticSearchService.java
+++ /dev/null
@@ -1,48 +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.kafkaconnector.elasticsearch.services;
-
-public class RemoteElasticSearchService implements ElasticSearchService {
- private static final int ELASTIC_SEARCH_PORT = 9200;
-
- @Override
- public int getPort() {
- String strPort = System.getProperty("elasticsearch.port");
-
- if (strPort != null) {
- return Integer.parseInt(strPort);
- }
-
- return ELASTIC_SEARCH_PORT;
- }
-
- @Override
- public String getElasticSearchHost() {
- return System.getProperty("elasticsearch.host");
- }
-
- @Override
- public void initialize() {
- // NO-OP
- }
-
- @Override
- public void shutdown() {
- // NO-OP
- }
-}
diff --git a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/sink/CamelSinkElasticSearchITCase.java b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/sink/CamelSinkElasticSearchITCase.java
index 5fd095a..e1af957 100644
--- a/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/sink/CamelSinkElasticSearchITCase.java
+++ b/tests/itests-elasticsearch/src/test/java/org/apache/camel/kafkaconnector/elasticsearch/sink/CamelSinkElasticSearchITCase.java
@@ -29,8 +29,8 @@ import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.kafkaconnector.elasticsearch.clients.ElasticSearchClient;
import org.apache.camel.kafkaconnector.elasticsearch.common.ElasticSearchCommon;
-import org.apache.camel.kafkaconnector.elasticsearch.services.ElasticSearchService;
-import org.apache.camel.kafkaconnector.elasticsearch.services.ElasticSearchServiceFactory;
+import org.apache.camel.test.infra.elasticsearch.services.ElasticSearchService;
+import org.apache.camel.test.infra.elasticsearch.services.ElasticSearchServiceFactory;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.jupiter.api.BeforeEach;
@@ -39,7 +39,6 @@ import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.junit.jupiter.Testcontainers;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -47,7 +46,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
-@Testcontainers
public class CamelSinkElasticSearchITCase extends AbstractKafkaTest {
@RegisterExtension
public static ElasticSearchService elasticSearch = ElasticSearchServiceFactory.createService();