Skip to content

Commit

Permalink
Merge pull request #349 from malafeev/couchbase-client-it
Browse files Browse the repository at this point in the history
Add couchbase-client integration tests
  • Loading branch information
safris committed Jan 16, 2020
2 parents 7c1bbd5 + 0cd6f1f commit 502af73
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ jobs:
# jdk: openjdk11
# install: true
# script: mvn -B -Dtest -P cassandra install
- name: "Couchbase Client [openjdk8]"
stage: test
jdk: openjdk8
install: true
script: mvn -B -Dtest -P couchbase-client install
- name: "Couchbase Client [openjdk11]"
stage: test
jdk: openjdk11
install: true
script: mvn -B -Dtest -P couchbase-client install
- name: "ElasticSearch [openjdk8]"
stage: test
jdk: openjdk8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public static void checkSpan(final String component, final int spanCount, final
System.out.println("Spans: " + spans);
for (final MockSpan span : spans) {
printSpan(span);
if (component.equals(span.tags().get(Tags.COMPONENT.getKey()))) {
final String spanComponent = (String) span.tags().get(Tags.COMPONENT.getKey());
if (spanComponent != null && spanComponent.matches(component)) {
found = true;
System.out.println("Found \"" + component + "\" span");
}
Expand Down
41 changes: 41 additions & 0 deletions test/couchbase-client-2.7.11/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
Copyright 2020 The OpenTracing Authors
Licensed 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.
-->
<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>io.opentracing.contrib.specialagent.test</groupId>
<artifactId>test</artifactId>
<version>1.5.6-SNAPSHOT</version>
</parent>
<artifactId>couchbase-client-2.7.11</artifactId>
<name>SpecialAgent Test for Couchbase Client 2.7.11</name>
<dependencies>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.7.11</version>
</dependency>
<dependency>
<groupId>io.opentracing.contrib.specialagent.test</groupId>
<artifactId>couchbase-client-2.7.3</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
</project>
40 changes: 40 additions & 0 deletions test/couchbase-client-2.7.3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
Copyright 2019 The OpenTracing Authors
Licensed 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.
-->
<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>io.opentracing.contrib.specialagent.test</groupId>
<artifactId>test</artifactId>
<version>1.5.6-SNAPSHOT</version>
</parent>
<artifactId>couchbase-client-2.7.3</artifactId>
<name>SpecialAgent Test for Couchbase Client 2.7.3</name>
<dependencies>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.couchbase.mock</groupId>
<artifactId>CouchbaseMock</artifactId>
<version>1.5.23</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Copyright 2020 The OpenTracing Authors
*
* Licensed 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 io.opentracing.contrib.specialagent.test.couchbase;

import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.JsonDocument;
import com.couchbase.client.java.document.json.JsonArray;
import com.couchbase.client.java.document.json.JsonObject;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.couchbase.mock.BucketConfiguration;
import com.couchbase.mock.CouchbaseMock;
import io.opentracing.contrib.specialagent.TestUtil;
import java.util.concurrent.TimeUnit;

public class CouchbaseClientITest {
public static void main(final String[] args) throws Exception {
final String bucketName = "test";

final CouchbaseMock couchbaseMock = new CouchbaseMock("localhost", 8091, 2, 1);
BucketConfiguration bucketConfiguration = new BucketConfiguration();
bucketConfiguration.name = bucketName;
bucketConfiguration.numNodes = 1;
bucketConfiguration.numReplicas = 1;
bucketConfiguration.password="";
couchbaseMock.start();
couchbaseMock.waitForStartup();
couchbaseMock.createBucket(bucketConfiguration);

final Cluster cluster = CouchbaseCluster.create(DefaultCouchbaseEnvironment.builder()
.connectTimeout(TimeUnit.SECONDS.toMillis(60)).build());

final Bucket bucket = cluster.openBucket(bucketName);

final JsonObject arthur = JsonObject.create()
.put("name", "Arthur")
.put("email", "kingarthur@couchbase.com")
.put("interests", JsonArray.from("Holy Grail", "African Swallows"));

bucket.upsert(JsonDocument.create("u:king_arthur", arthur));

System.out.println(bucket.get("u:king_arthur"));

cluster.disconnect(60, TimeUnit.SECONDS);
couchbaseMock.stop();

TestUtil.checkSpan("couchbase-java-client.*", 6);
}

}
12 changes: 12 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@
<module>concurrent</module>
</modules>
</profile>
<profile>
<id>couchbase-client</id>
<activation>
<property>
<name>all</name>
</property>
</activation>
<modules>
<module>couchbase-client-2.7.3</module>
<module>couchbase-client-2.7.11</module>
</modules>
</profile>
<profile>
<id>elasticsearch</id>
<activation>
Expand Down

0 comments on commit 502af73

Please sign in to comment.