This is an automated email from the ASF dual-hosted git repository. madhawa pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/gora.git
The following commit(s) were added to refs/heads/master by this push: new 5dd382a GORA-661 Upgrade CouchDB module to the latest driver new 7f19ab9 Merge pull request #216 from rumesh-perera/GORA-661 5dd382a is described below commit 5dd382a1340aea246f50452170377d9c5d808b86 Author: rumesh-perera <nrumeshper...@gmail.com> AuthorDate: Mon Jun 1 01:17:47 2020 +0530 GORA-661 Upgrade CouchDB module to the latest driver --- gora-couchdb/pom.xml | 23 --------- .../couchdb/CouchDBStartupLogWaitStrategy.java | 60 ++++++++++++++++++++++ .../gora/couchdb/store/TestCouchDBStore.java | 12 +++-- pom.xml | 2 +- 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/gora-couchdb/pom.xml b/gora-couchdb/pom.xml index df464b7..24f5355 100644 --- a/gora-couchdb/pom.xml +++ b/gora-couchdb/pom.xml @@ -54,24 +54,6 @@ <osgi.export>org.apache.gora.couchdb*;version="${project.version}";-noimport:=true</osgi.export> </properties> - <profiles> - <profile> - <id>couchdb-with-test</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.4.2</version> - <configuration> - <skipTests>false</skipTests> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - <build> <directory>target</directory> <outputDirectory>target/classes</outputDirectory> @@ -92,9 +74,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.2</version> - <configuration> - <skipTests>true</skipTests> - </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> @@ -151,10 +130,8 @@ <dependency> <groupId>org.ektorp</groupId> <artifactId>org.ektorp</artifactId> - <version>1.4.2</version> </dependency> - <dependency> <groupId>org.apache.avro</groupId> <artifactId>avro</artifactId> diff --git a/gora-couchdb/src/test/java/org/apache/gora/couchdb/CouchDBStartupLogWaitStrategy.java b/gora-couchdb/src/test/java/org/apache/gora/couchdb/CouchDBStartupLogWaitStrategy.java new file mode 100644 index 0000000..7cd06cf --- /dev/null +++ b/gora-couchdb/src/test/java/org/apache/gora/couchdb/CouchDBStartupLogWaitStrategy.java @@ -0,0 +1,60 @@ +/* + * 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.gora.couchdb; + +import org.testcontainers.containers.ContainerLaunchException; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.containers.output.WaitingConsumer; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.function.Predicate; + +/** + * Log based CouchDB server startup wait strategy to sync server + * startup to test suit startup. + */ +public class CouchDBStartupLogWaitStrategy extends GenericContainer.AbstractWaitStrategy { + + private static final String regEx = ".*Apache CouchDB has started. Time to relax..*"; + + private int times = 1; + + protected void waitUntilReady() { + WaitingConsumer waitingConsumer = new WaitingConsumer(); + this.container.followOutput(waitingConsumer); + Predicate waitPredicate = (outputFrame) -> { + String trimmedFrameText = ((OutputFrame) outputFrame) + .getUtf8String() + .replaceFirst("\n$", ""); + return trimmedFrameText.matches(regEx); + }; + + try { + waitingConsumer.waitUntil(waitPredicate, this.startupTimeout.getSeconds(), TimeUnit.SECONDS, + this.times); + } catch (TimeoutException var4) { + throw new ContainerLaunchException( + "Timed out waiting for log output matching CouchDB server startup Log \'" + regEx + + "\'"); + } + } + +} \ No newline at end of file diff --git a/gora-couchdb/src/test/java/org/apache/gora/couchdb/store/TestCouchDBStore.java b/gora-couchdb/src/test/java/org/apache/gora/couchdb/store/TestCouchDBStore.java index ffcd0dd..da6996f 100644 --- a/gora-couchdb/src/test/java/org/apache/gora/couchdb/store/TestCouchDBStore.java +++ b/gora-couchdb/src/test/java/org/apache/gora/couchdb/store/TestCouchDBStore.java @@ -17,13 +17,12 @@ package org.apache.gora.couchdb.store; import org.apache.avro.util.Utf8; +import org.apache.gora.couchdb.CouchDBStartupLogWaitStrategy; import org.apache.gora.couchdb.GoraCouchDBTestDriver; import org.apache.gora.couchdb.query.CouchDBResult; import org.apache.gora.examples.WebPageDataCreator; -import org.apache.gora.examples.generated.Employee; import org.apache.gora.examples.generated.WebPage; import org.apache.gora.query.Query; -import org.apache.gora.store.DataStore; import org.apache.gora.store.DataStoreTestBase; import org.apache.gora.util.GoraException; import org.junit.ClassRule; @@ -34,6 +33,7 @@ import org.testcontainers.containers.GenericContainer; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.time.Duration; import static org.junit.Assert.*; @@ -43,12 +43,16 @@ import static org.junit.Assert.*; */ public class TestCouchDBStore extends DataStoreTestBase { - private static final String DOCKER_CONTAINER_NAME = "klaemo/couchdb:1.6.1"; + private static final String DOCKER_CONTAINER_NAME = "couchdb:1.6.1"; + /** * JUnit integration testing with Docker and Testcontainers */ @ClassRule - public static GenericContainer CouchDB_CONTAINER = new GenericContainer(DOCKER_CONTAINER_NAME); + public static GenericContainer CouchDB_CONTAINER = new GenericContainer(DOCKER_CONTAINER_NAME) + .withExposedPorts(5984) + .waitingFor(new CouchDBStartupLogWaitStrategy()) + .withStartupTimeout(Duration.ofSeconds(240)); static { try { diff --git a/pom.xml b/pom.xml index 87f8043..9dca595 100755 --- a/pom.xml +++ b/pom.xml @@ -866,7 +866,7 @@ <!-- CouchDB Dependencies --> - <couchdb.version>1.4.2</couchdb.version> + <couchdb.version>1.5.0</couchdb.version> <!-- MongoDB Dependencies --> <mongo.driver.version>3.12.2</mongo.driver.version>