Dont share environment.  Slower but more deterministic
MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseAsyncClientTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseAsyncClientTest.groovy
@@ -2,6 +2,7 @@ import com.couchbase.client.java.AsyncCluster
import com.couchbase.client.java.CouchbaseAsyncCluster
import com.couchbase.client.java.document.JsonDocument
import com.couchbase.client.java.document.json.JsonObject
+import com.couchbase.client.java.env.CouchbaseEnvironment
import com.couchbase.client.java.query.N1qlQuery
import spock.util.concurrent.BlockingVariable
import util.AbstractCouchbaseTest
@@ -31,13 +32,13 @@ class CouchbaseAsyncClientTest extends AbstractCouchbaseTest {
}
cleanup:
- cluster?.disconnect()?.timeout(5, TimeUnit.SECONDS)?.toBlocking()?.single()
+ cluster?.disconnect()?.timeout(10, TimeUnit.SECONDS)?.toBlocking()?.single()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseAsyncCluster.create(environment, Arrays.asList("127.0.0.1"))
manager = cluster.clusterManager(USERNAME, PASSWORD).toBlocking().single()
type = bucketSettings.type().name()
@@ -71,13 +72,13 @@ class CouchbaseAsyncClientTest extends AbstractCouchbaseTest {
}
cleanup:
- cluster?.disconnect()?.timeout(5, TimeUnit.SECONDS)?.toBlocking()?.single()
+ cluster?.disconnect()?.timeout(10, TimeUnit.SECONDS)?.toBlocking()?.single()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseAsyncCluster.create(environment, Arrays.asList("127.0.0.1"))
type = bucketSettings.type().name()
}
@@ -119,13 +120,13 @@ class CouchbaseAsyncClientTest extends AbstractCouchbaseTest {
}
cleanup:
- cluster?.disconnect()?.timeout(5, TimeUnit.SECONDS)?.toBlocking()?.single()
+ cluster?.disconnect()?.timeout(10, TimeUnit.SECONDS)?.toBlocking()?.single()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseAsyncCluster.create(environment, Arrays.asList("127.0.0.1"))
type = bucketSettings.type().name()
}
@@ -133,7 +134,8 @@ class CouchbaseAsyncClientTest extends AbstractCouchbaseTest {
def "test query"() {
setup:
// Only couchbase buckets support queries.
- AsyncCluster cluster = CouchbaseAsyncCluster.create(couchbaseEnvironment, Arrays.asList("127.0.0.1"))
+ CouchbaseEnvironment environment = envBuilder(bucketCouchbase).build()
+ AsyncCluster cluster = CouchbaseAsyncCluster.create(environment, Arrays.asList("127.0.0.1"))
def queryResult = new BlockingVariable<JsonObject>()
when:
@@ -164,6 +166,7 @@ class CouchbaseAsyncClientTest extends AbstractCouchbaseTest {
}
cleanup:
- cluster?.disconnect()?.timeout(5, TimeUnit.SECONDS)?.toBlocking()?.single()
+ cluster?.disconnect()?.timeout(10, TimeUnit.SECONDS)?.toBlocking()?.single()
+ environment.shutdown()
}
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseClientTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/CouchbaseClientTest.groovy
@@ -3,6 +3,7 @@ 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.JsonObject
+import com.couchbase.client.java.env.CouchbaseEnvironment
import com.couchbase.client.java.query.N1qlQuery
import util.AbstractCouchbaseTest
@@ -24,12 +25,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
cleanup:
cluster?.disconnect()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseCluster.create(environment, Arrays.asList("127.0.0.1"))
manager = cluster.clusterManager(USERNAME, PASSWORD)
type = bucketSettings.type().name()
@@ -63,12 +64,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
cleanup:
cluster?.disconnect()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseCluster.create(environment, Arrays.asList("127.0.0.1"))
type = bucketSettings.type().name()
}
@@ -108,12 +109,12 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
cleanup:
cluster?.disconnect()
+ environment.shutdown()
where:
- environment | bucketSettings
- couchbaseEnvironment | bucketCouchbase
- memcacheEnvironment | bucketMemcache
+ bucketSettings << [bucketCouchbase, bucketMemcache]
+ environment = envBuilder(bucketSettings).build()
cluster = CouchbaseCluster.create(environment, Arrays.asList("127.0.0.1"))
type = bucketSettings.type().name()
}
@@ -121,7 +122,8 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
def "test query"() {
setup:
// Only couchbase buckets support queries.
- Cluster cluster = CouchbaseCluster.create(couchbaseEnvironment, Arrays.asList("127.0.0.1"))
+ CouchbaseEnvironment environment = envBuilder(bucketCouchbase).build()
+ Cluster cluster = CouchbaseCluster.create(environment, Arrays.asList("127.0.0.1"))
Bucket bkt = cluster.openBucket(bucketCouchbase.name(), bucketCouchbase.password())
when:
@@ -146,5 +148,6 @@ class CouchbaseClientTest extends AbstractCouchbaseTest {
cleanup:
cluster?.disconnect()
+ environment.shutdown()
}
}

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringRepositoryTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringRepositoryTest.groovy
@@ -2,6 +2,7 @@ package springdata
import com.couchbase.client.java.Cluster
import com.couchbase.client.java.CouchbaseCluster
+import com.couchbase.client.java.env.CouchbaseEnvironment
import com.couchbase.client.java.view.DefaultView
import com.couchbase.client.java.view.DesignDocument
import org.springframework.context.ConfigurableApplicationContext
@@ -31,7 +32,8 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
DocRepository repo
def setupSpec() {
- Cluster couchbaseCluster = CouchbaseCluster.create(memcacheEnvironment, Arrays.asList("127.0.0.1"))
+ CouchbaseEnvironment environment = envBuilder(bucketCouchbase).build()
+ Cluster couchbaseCluster = CouchbaseCluster.create(environment, Arrays.asList("127.0.0.1"))
// Create view for SpringRepository's findAll()
couchbaseCluster.openBucket(bucketCouchbase.name(), bucketCouchbase.password()).bucketManager()
@@ -46,7 +48,7 @@ class CouchbaseSpringRepositoryTest extends AbstractCouchbaseTest {
'''.stripIndent()
)))
)
- CouchbaseConfig.setEnvironment(couchbaseEnvironment)
+ CouchbaseConfig.setEnvironment(environment)
CouchbaseConfig.setBucketSettings(bucketCouchbase)
// Close all buckets and disconnect

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringTemplateTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/springdata/CouchbaseSpringTemplateTest.groovy
@@ -4,12 +4,11 @@ import com.couchbase.client.java.Bucket
import com.couchbase.client.java.Cluster
import com.couchbase.client.java.CouchbaseCluster
import com.couchbase.client.java.cluster.ClusterManager
+import com.couchbase.client.java.env.CouchbaseEnvironment
import org.springframework.data.couchbase.core.CouchbaseTemplate
import spock.lang.Shared
import util.AbstractCouchbaseTest
-import java.util.concurrent.TimeUnit
-
class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
@Shared
@@ -21,7 +20,15 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
@Shared
Cluster memcacheCluster
+ @Shared
+ protected CouchbaseEnvironment couchbaseEnvironment
+ @Shared
+ protected CouchbaseEnvironment memcacheEnvironment
+
def setupSpec() {
+ couchbaseEnvironment = envBuilder(bucketCouchbase).build()
+ memcacheEnvironment = envBuilder(bucketMemcache).build()
+
couchbaseCluster = CouchbaseCluster.create(couchbaseEnvironment, Arrays.asList("127.0.0.1"))
memcacheCluster = CouchbaseCluster.create(memcacheEnvironment, Arrays.asList("127.0.0.1"))
ClusterManager couchbaseManager = couchbaseCluster.clusterManager(USERNAME, PASSWORD)
@@ -35,8 +42,10 @@ class CouchbaseSpringTemplateTest extends AbstractCouchbaseTest {
}
def cleanupSpec() {
- couchbaseCluster?.disconnect(5, TimeUnit.SECONDS)
- memcacheCluster?.disconnect(5, TimeUnit.SECONDS)
+ couchbaseCluster?.disconnect()
+ memcacheCluster?.disconnect()
+ couchbaseEnvironment.shutdown()
+ memcacheEnvironment.shutdown()
}
def "test write #name"() {

MODIFY
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/util/AbstractCouchbaseTest.groovy
dd-java-agent/instrumentation/couchbase-2.0/src/test/groovy/util/AbstractCouchbaseTest.groovy
@@ -5,7 +5,6 @@ import com.couchbase.client.core.metrics.DefaultMetricsCollectorConfig
import com.couchbase.client.java.bucket.BucketType
import com.couchbase.client.java.cluster.BucketSettings
import com.couchbase.client.java.cluster.DefaultBucketSettings
-import com.couchbase.client.java.env.CouchbaseEnvironment
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment
import com.couchbase.mock.Bucket
import com.couchbase.mock.BucketConfiguration
@@ -57,11 +56,6 @@ abstract class AbstractCouchbaseTest extends AgentTestRunner {
@Shared
CouchbaseMock mock
- @Shared
- protected CouchbaseEnvironment couchbaseEnvironment
- @Shared
- protected CouchbaseEnvironment memcacheEnvironment
-
def setupSpec() {
mock = new CouchbaseMock("127.0.0.1", port, 1, 1)
mock.httpServer.register("/query", new QueryServer())
@@ -71,9 +65,6 @@ abstract class AbstractCouchbaseTest extends AgentTestRunner {
mock.createBucket(convert(bucketCouchbase))
mock.createBucket(convert(bucketMemcache))
- couchbaseEnvironment = envBuilder(bucketCouchbase).build()
- memcacheEnvironment = envBuilder(bucketMemcache).build()
-
// This setting should have no effect since decorator returns null for the instance.
System.setProperty(Config.PREFIX + Config.DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
}
@@ -94,7 +85,7 @@ abstract class AbstractCouchbaseTest extends AgentTestRunner {
System.clearProperty(Config.PREFIX + Config.DB_CLIENT_HOST_SPLIT_BY_INSTANCE)
}
- private DefaultCouchbaseEnvironment.Builder envBuilder(BucketSettings bucketSettings) {
+ protected DefaultCouchbaseEnvironment.Builder envBuilder(BucketSettings bucketSettings) {
// Couchbase seems to be really slow to start sometimes
def timeout = TimeUnit.SECONDS.toMillis(20)
return DefaultCouchbaseEnvironment.builder()

Dont share environment.  Slower but more deterministic