Testcontianer using image couchbase/server:latest is not starting

Hi,

When we use couchbase/server:6.6.0 to launch couchbase container using testcontainer library the couchbase is getting started with out any issues . but with couchbase/server:7.1.3 or couchbase/server:latest the couchbase container is not starting and fails for error could not perform request against couchbase HTTP endpoint . Any idea? with couchbase/server:6.6.0 we are not able to use collections as we are getting error collections are not enabled or supported on the cluster.

with couchbase/server:7.1.3 or couchbase/server:latest the couchbase container is not starting

Are there any error messages?

with couchbase/server:6.6.0 we are not able to use collections as we are getting error collections are not enabled or supported on the cluster.

That’s correct. Official support for collections comes in 7.0. However, in 6.6 you can use collections by enabling “Developer Preview”.

https://docs.couchbase.com/server/6.6/developer-preview/collections/manage-collections-with-rest.html

the error is
RuntimeException :could not perform request against couchbase HTTP endpoint

Understandably it’s not possible to perform http requests against the container if it did not start.
I meant were there any messages as to why it does not start.

This works:
(btw - the sample code is missing the start() call - which will result in the container not being started)

package somepackage;

import com.couchbase.client.java.json.JsonObject;
import org.junit.jupiter.api.Test;
import org.testcontainers.couchbase.BucketDefinition;
import org.testcontainers.couchbase.CouchbaseContainer;

import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;

public class MyTest {

	@Test
	public void hello() {
		BucketDefinition bucketDefinition = new BucketDefinition("mybucket");
		String image = "couchbase/server:latest";
		CouchbaseContainer container = new CouchbaseContainer(image).withBucket(bucketDefinition);
		container.start();
		Cluster cluster = Cluster.connect(container.getConnectionString(), container.getUsername(),
				container.getPassword());
		Bucket bucket = cluster.bucket("mybucket");
		bucket.defaultCollection().insert("123", JsonObject.create().put("hello","world"));
        System.out.println(bucket.defaultCollection().get("123").contentAsObject());
		System.out.println("query: "+cluster.query("SELECT * from mybucket"));
	}
}

Hi mreiche,

We have similar code .

on further analyzing the logs seeing socket timeout .

Thanks,
Mahendravarman

We have similar code

It would help to see the exact code. And the message and the stack trace.
You can also try running my code - which does work. From my pom.xml, testcontainers version 1.17.6

 <properties>
       <couchbase>3.4.1</couchbase>
     </properties

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>${testcontainers}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

<dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>couchbase</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.couchbase.client</groupId>
            <artifactId>java-client</artifactId>
            <version>${couchbase}</version>
        </dependency>
</dependencies>
  • Mike