Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CouchbaseContainer does not actually wait until the query service is available #2993

Closed
aaronjwhiteside opened this issue Jul 14, 2020 · 14 comments · Fixed by #3003
Closed
Assignees

Comments

@aaronjwhiteside
Copy link
Contributor

It seems that even though the CouchbaseContainer checks the health of the /admin/ping endpoint for the query service, the query service is not actually available to handle queries yet.

If I withReuse(true) this container, and run the test a second time, it succeeds because it now seems the query service has had enough time to initialize and become available to handle queries.

2020-07-14 13:26:20.936  INFO 80842 --- [           main] 🐳 [couchbase:enterprise-6.5.1]          : Creating container for image: couchbase:enterprise-6.5.1
2020-07-14 13:26:21.051  INFO 80842 --- [           main] 🐳 [couchbase:enterprise-6.5.1]          : Starting container with ID: 1ece82baa13e1965812f1371320d97b75e92fb2aab727246dd5e3ccba984a3d4
2020-07-14 13:26:21.629  INFO 80842 --- [           main] 🐳 [couchbase:enterprise-6.5.1]          : Container couchbase:enterprise-6.5.1 is starting: 1ece82baa13e1965812f1371320d97b75e92fb2aab727246dd5e3ccba984a3d4
2020-07-14 13:26:21.640  INFO 80842 --- [           main] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 60 seconds for URL: http://localhost:33429/pools
2020-07-14 13:26:21.661  INFO 80842 --- [tream-142261320] docker.couchbase                         : STDOUT: Starting Couchbase Server -- Web UI available at http://<ip>:8091
2020-07-14 13:26:21.661  INFO 80842 --- [tream-142261320] docker.couchbase                         : STDOUT: and logs available in /opt/couchbase/var/lib/couchbase/logs
2020-07-14 13:26:31.307  INFO 80842 --- [     ducttape-0] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 30 seconds for URL: http://localhost:33429/pools/default
2020-07-14 13:26:31.959  INFO 80842 --- [     ducttape-0] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 30 seconds for URL: http://localhost:33427/admin/ping
2020-07-14 13:26:32.970  INFO 80842 --- [           main] 🐳 [couchbase:enterprise-6.5.1]          : Container couchbase:enterprise-6.5.1 started in PT14.344S
2020-07-14 13:26:32.977  INFO 80842 --- [           main] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 60 seconds for URL: http://localhost:33429/pools/default/buckets/YS_Apps
2020-07-14 13:26:34.124  INFO 80842 --- [           main] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 60 seconds for URL: http://localhost:33429/pools/default/buckets/YS_Secure
2020-07-14 13:26:35.105  INFO 80842 --- [           main] o.t.c.wait.strategy.HttpWaitStrategy     : /youthful_dirac: Waiting for 60 seconds for URL: http://localhost:33429/pools/default/buckets/YS_Ephemeral
2020-07-14 13:26:36.145  INFO 80842 --- [           main] 🐳 [couchbase:enterprise-6.5.1]          : Couchbase container is ready! UI available at http://localhost:33429
2020-07-14 13:26:38.041  INFO 80842 --- [           main] com.couchbase.client.core.CouchbaseCore  : CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslTruststoreFile='null', sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, sslHostnameVerificationEnabled=false, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=33429, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=33422, bootstrapCarrierSslPort=11207, ioPoolSize=12, computationPoolSize=12, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, networkResolution=NetworkResolution{name='auto'}, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, analyticsIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.7.11 (git: 2.7.11, core: 1.7.11), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=1000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$4@4f654cee, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, compressionMinRatio=0.83, compressionMinSize=32, compressionEnabled=true, operationTracingEnabled=true, operationTracingServerDurationEnabled=true, tracer=ThresholdLogTracer, orphanResponseReportingEnabled=true, orphanResponseReporter=DefaultOrphanResponseReporter, keyValueServiceConfig=KeyValueServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=true, idleTime=0}, queryServiceConfig=QueryServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, searchServiceConfig=SearchServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, viewServiceConfig=ViewServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, analyticsServiceConfig=AnalyticsServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, queryTimeout=7500, viewTimeout=7500, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=2500, connectTimeout=5000, dnsSrvEnabled=false, propagateParentSpan=true}
2020-07-14 13:26:38.686  INFO 80842 --- [      cb-io-1-1] com.couchbase.client.core.node.Node      : Connected to Node localhost
2020-07-14 13:26:38.737  INFO 80842 --- [-computations-8] c.c.c.core.config.ConfigurationProvider  : Selected network configuration: external
2020-07-14 13:26:38.746  INFO 80842 --- [-computations-8] c.c.c.core.config.ConfigurationProvider  : Opened bucket YS_Apps
2020-07-14 13:26:38.752  INFO 80842 --- [      cb-io-1-1] com.couchbase.client.core.node.Node      : Disconnected from Node localhost
2020-07-14 13:26:38.771  INFO 80842 --- [      cb-io-1-2] com.couchbase.client.core.node.Node      : Connected to Node 172.18.0.2 (localhost)
org.springframework.dao.DataAccessResourceFailureException: The Query service is not enabled or no node in the cluster supports it.; nested exception is com.couchbase.client.core.ServiceNotAvailableException: The Query service is not enabled or no node in the cluster supports it.

	at org.springframework.data.couchbase.core.CouchbaseExceptionTranslator.translateExceptionIfPossible(CouchbaseExceptionTranslator.java:87)
	at org.springframework.data.couchbase.core.CouchbaseTemplate.execute(CouchbaseTemplate.java:551)
	at org.springframework.data.couchbase.core.CouchbaseTemplate.queryN1QL(CouchbaseTemplate.java:505)
@aaronjwhiteside
Copy link
Contributor Author

aaronjwhiteside commented Jul 14, 2020

I have a feeling this might be a CB Java SDK issue now, I added extra checks (running some n1ql queries) to the CouchbaseContainer right after startup, the same checks I added to our integration tests pre test start.

They pass from CouchbaseContainer but fail for about 1-4 seconds from the integrationt tests.

I'll dig deeper into this, perhaps turn on client side debug in the CB Java SDK and try and see what is going on

@aaronjwhiteside
Copy link
Contributor Author

Yeah this appears to be an issue with the CB Java SDK.

But out of the box this prevents the use of the CouchbaseContainer for N1QL queries...

2020-07-15 10:14:07.879 DEBUG 60242 --- [           main] c.couchbase.client.core.RequestHandler   : Got instructed to add Node localhost
2020-07-15 10:14:07.879 DEBUG 60242 --- [           main] c.couchbase.client.core.RequestHandler   : Connecting Node localhost
2020-07-15 10:14:07.881 DEBUG 60242 --- [           main] c.couchbase.client.core.RequestHandler   : Connect finished, registering for use.
2020-07-15 10:14:07.884 DEBUG 60242 --- [-computations-5] c.couchbase.client.core.RequestHandler   : Got instructed to add Service BINARY, to Node localhost
2020-07-15 10:14:08.308  INFO 60242 --- [      cb-io-1-1] com.couchbase.client.core.node.Node      : Connected to Node localhost
2020-07-15 10:14:08.355  INFO 60242 --- [-computations-8] c.c.c.core.config.ConfigurationProvider  : Selected network configuration: external
2020-07-15 10:14:08.355 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got notified of a new configuration arriving.
2020-07-15 10:14:08.355 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Starting reconfiguration.
2020-07-15 10:14:08.356 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Starting reconfiguration for bucket YS_Apps
2020-07-15 10:14:08.356 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Node 172.22.0.2
2020-07-15 10:14:08.356 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Connecting Node 172.22.0.2
2020-07-15 10:14:08.357 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Connect finished, registering for use.
2020-07-15 10:14:08.357 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service BINARY, to Node 172.22.0.2
2020-07-15 10:14:08.358 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service VIEW, to Node 172.22.0.2
2020-07-15 10:14:08.360 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service CONFIG, to Node 172.22.0.2
2020-07-15 10:14:08.363  INFO 60242 --- [-computations-8] c.c.c.core.config.ConfigurationProvider  : Opened bucket YS_Apps
2020-07-15 10:14:08.364 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Starting reconfiguration.
2020-07-15 10:14:08.364 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Starting reconfiguration for bucket YS_Apps
2020-07-15 10:14:08.364 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Node 172.22.0.2 already registered, skipping.
2020-07-15 10:14:08.364 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service BINARY, to Node 172.22.0.2
2020-07-15 10:14:08.365 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service VIEW, to Node 172.22.0.2
2020-07-15 10:14:08.365 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to add Service CONFIG, to Node 172.22.0.2
2020-07-15 10:14:08.365 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Removing and disconnecting node localhost.
2020-07-15 10:14:08.365 DEBUG 60242 --- [-computations-8] c.couchbase.client.core.RequestHandler   : Got instructed to remove Node localhost
2020-07-15 10:14:08.370  INFO 60242 --- [      cb-io-1-1] com.couchbase.client.core.node.Node      : Disconnected from Node localhost
2020-07-15 10:14:08.389  INFO 60242 --- [      cb-io-1-2] com.couchbase.client.core.node.Node      : Connected to Node 172.22.0.2 (localhost)
2020-07-15 10:14:10.091  INFO 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : Started AbstractScopedEntityDAOIT in 28.218 seconds (JVM running for 29.13)
2020-07-15 10:14:10.106 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.209 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.315 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.416 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.520 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.621 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.727 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.832 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:10.934 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.038 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.140 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.243 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.347 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.451 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.556 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.658 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.761 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.866 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:11.967 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.071 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.177 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.280 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.383 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.484 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.585 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.686 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.793 ERROR 60242 --- [           main] c.y.r.u.d.d.i.AbstractScopedEntityDAOIT  : The Query service is not enabled or no node in the cluster supports it.
2020-07-15 10:14:12.831 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got notified of a new configuration arriving.
2020-07-15 10:14:12.831 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Starting reconfiguration.
2020-07-15 10:14:12.831 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Starting reconfiguration for bucket YS_Apps
2020-07-15 10:14:12.831 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Node 172.22.0.2 already registered, skipping.
2020-07-15 10:14:12.831 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got instructed to add Service QUERY, to Node 172.22.0.2
2020-07-15 10:14:12.832 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got instructed to add Service BINARY, to Node 172.22.0.2
2020-07-15 10:14:12.832 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got instructed to add Service VIEW, to Node 172.22.0.2
2020-07-15 10:14:12.833 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got instructed to add Service CONFIG, to Node 172.22.0.2
2020-07-15 10:14:12.833 DEBUG 60242 --- [-computations-9] c.couchbase.client.core.RequestHandler   : Got instructed to add Service SEARCH, to Node 172.22.0.2

@aaronjwhiteside
Copy link
Contributor Author

Created a CB support ticket #35272 to track this

@bsideup
Copy link
Member

bsideup commented Jul 15, 2020

cc @daschl

@daschl
Copy link
Member

daschl commented Jul 15, 2020

@aaronjwhiteside would it be possible for you to enable TRACE level and supply those logs? The reason is the error you are seeing means that the config the client got from the server does not include query, and right now I have a hard time figuring out the timeline of events. If you could send the trace over, it should include the raw configs the client gets from the server and maybe this helps figuring out what's going on.

@aaronjwhiteside
Copy link
Contributor Author

@daschl here you go client-trace.txt

Thanks for looking into this!

@aaronjwhiteside
Copy link
Contributor Author

@daschl this second trace includes more details, like when the server actually decides to push the config containing the query service.

client-trace2.txt

@daschl
Copy link
Member

daschl commented Jul 15, 2020

@aaronjwhiteside thanks for sharing the log, I'll check it out and get back to you

@daschl
Copy link
Member

daschl commented Jul 16, 2020

@aaronjwhiteside this is really interesting. 2 bucket configs arrive at the client, the first one does not have the query service enabled but the second one does. I'm not sure why this is the case, because the container code enables all services before it starts creating a bucket.

Can you post your code and how you are using it so I can give it a try to reproduce? Also, which SDK version are you using?

@aaronjwhiteside
Copy link
Contributor Author

aaronjwhiteside commented Jul 16, 2020

@daschl Java SDK 2.7.11, with Spring Data Couchbase 3.1.2 with modifications. I've also tried with CB 6.0.3, 6.5.0 and 6.5.1 there is no difference between them.

Our setup is fairly custom/esoteric both in terms of TestContainers and the way we configure Spring Data Couchbase... so it's not easy to provide the code. I'll work on trying to provide a minimum test case that reproduces the issue..

@aaronjwhiteside
Copy link
Contributor Author

aaronjwhiteside commented Jul 16, 2020

@daschl Ok turns out to be really simple to reproduce..

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>org.example</groupId>
    <artifactId>test-containers-couchbase-issue-2993</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.couchbase.client</groupId>
            <artifactId>java-client</artifactId>
            <version>2.7.11</version>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>couchbase</artifactId>
            <version>1.14.3</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.30</version>
        </dependency>
    </dependencies>
</project>
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.couchbase.client.java.query.N1qlQuery;
import org.testcontainers.couchbase.BucketDefinition;
import org.testcontainers.couchbase.CouchbaseContainer;

public class Example {
    public static void main(final String...args) {
        try (final CouchbaseContainer container = new CouchbaseContainer()
                .withBucket(new BucketDefinition("bucket1")
                                    .withPrimaryIndex(false))) {
            container.start();

            final CouchbaseEnvironment environment = DefaultCouchbaseEnvironment
                    .builder()
                    .bootstrapCarrierDirectPort(container.getBootstrapCarrierDirectPort())
                    .bootstrapHttpDirectPort(container.getBootstrapHttpDirectPort())
                    .build();

            final Cluster cluster = CouchbaseCluster.create(environment, container.getHost())
                    .authenticate(container.getUsername(), container.getPassword());

            final Bucket bucket = cluster.openBucket("bucket1");
            bucket.query(N1qlQuery.simple("SELECT 1 FROM system:completed_requests WHERE true"));
        }
    }
}

Yields...

[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
[main] INFO org.testcontainers.dockerclient.UnixSocketClientProviderStrategy - Accessing docker with local Unix socket
[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
[main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
[main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 19.03.8
  API Version: 1.40
  Operating System: Docker Desktop
  Total Memory: 9969 MB
[main] INFO org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for index.docker.io
[main] INFO org.testcontainers.DockerClientFactory - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[main] INFO org.testcontainers.DockerClientFactory - Checking the system...
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker environment should have more than 2GB free disk space
[main] INFO 🐳 [couchbase/server:6.5.1] - Creating container for image: couchbase/server:6.5.1
[main] INFO 🐳 [couchbase/server:6.5.1] - Starting container with ID: 002445f26b1cb49b3e122f32a39a44bed8e678ed815c7780a3f702249fe4d4e4
[main] INFO 🐳 [couchbase/server:6.5.1] - Container couchbase/server:6.5.1 is starting: 002445f26b1cb49b3e122f32a39a44bed8e678ed815c7780a3f702249fe4d4e4
[main] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /sharp_chandrasekhar: Waiting for 60 seconds for URL: http://localhost:32940/pools
[ducttape-0] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /sharp_chandrasekhar: Waiting for 30 seconds for URL: http://localhost:32940/pools/default
[ducttape-0] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /sharp_chandrasekhar: Waiting for 30 seconds for URL: http://localhost:32938/admin/ping
[main] INFO 🐳 [couchbase/server:6.5.1] - Container couchbase/server:6.5.1 started in PT13.19S
[main] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /sharp_chandrasekhar: Waiting for 60 seconds for URL: http://localhost:32940/pools/default/buckets/bucket1
[main] INFO 🐳 [couchbase/server:6.5.1] - Couchbase container is ready! UI available at http://localhost:32940
[main] INFO com.couchbase.client.core.CouchbaseCore - CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslTruststoreFile='null', sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, sslHostnameVerificationEnabled=false, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=32940, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=32933, bootstrapCarrierSslPort=11207, ioPoolSize=12, computationPoolSize=12, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, networkResolution=NetworkResolution{name='auto'}, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, analyticsIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.7.16 (git: 2.7.16, core: 1.7.16), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=1000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$4@c667f46, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, compressionMinRatio=0.83, compressionMinSize=32, compressionEnabled=true, operationTracingEnabled=true, operationTracingServerDurationEnabled=true, tracer=ThresholdLogTracer, orphanResponseReportingEnabled=true, orphanResponseReporter=DefaultOrphanResponseReporter, keyValueServiceConfig=KeyValueServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=true, idleTime=0}, queryServiceConfig=QueryServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, searchServiceConfig=SearchServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, viewServiceConfig=ViewServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, analyticsServiceConfig=AnalyticsServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, queryTimeout=75000, viewTimeout=75000, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=2500, connectTimeout=5000, dnsSrvEnabled=false, propagateParentSpan=true}
[cb-io-1-1] INFO com.couchbase.client.core.node.Node - Connected to Node localhost
[cb-computations-12] INFO com.couchbase.client.core.config.ConfigurationProvider - Selected network configuration: external
[cb-computations-12] INFO com.couchbase.client.core.config.ConfigurationProvider - Opened bucket bucket1
[cb-io-1-1] INFO com.couchbase.client.core.node.Node - Disconnected from Node localhost
[cb-io-1-2] INFO com.couchbase.client.core.node.Node - Connected to Node 172.17.0.3 (localhost)
[cb-io-1-2] INFO com.couchbase.client.core.endpoint.Endpoint - [localhost/127.0.0.1:32933][KeyValueEndpoint]: Got notified from Channel as inactive, attempting reconnect.
[cb-io-1-2] INFO com.couchbase.client.core.node.Node - Disconnected from Node 172.17.0.3 (localhost)
[cb-io-1-3] INFO com.couchbase.client.core.endpoint.Endpoint - [localhost/127.0.0.1:32933][KeyValueEndpoint]: Got notified from Channel as inactive, attempting reconnect.
Exception in thread "main" com.couchbase.client.core.ServiceNotAvailableException: The Query service is not enabled or no node in the cluster supports it.
	at com.couchbase.client.core.RequestHandler.checkFeaturesForRequest(RequestHandler.java:276)
	at com.couchbase.client.core.RequestHandler.dispatchRequest(RequestHandler.java:246)
	at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:207)
	at com.couchbase.client.core.RequestHandler.onEvent(RequestHandler.java:78)
	at com.couchbase.client.deps.com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:168)
	at com.couchbase.client.deps.com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125)
	at com.couchbase.client.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

daschl added a commit to daschl/testcontainers-java that referenced this issue Jul 17, 2020
This changeset adds a predicate to the wait strategy to make sure
that it not only returns a 200, but also that every enabled service
is actually already exposed in the config. Since we are polling
the server during bootstrap here, not all of them might show up
at the same time.

Also, while not contributing to the fix we poll the terse bucket
http config "b" instead of the verbose one "buckets" since it is
a little more efficient on the server side and actually the config
the client internally works with.

fixes testcontainers#2993
@daschl
Copy link
Member

daschl commented Jul 17, 2020

@aaronjwhiteside pr #3003 should fix the issue. I think as a workaround in the meantime you can either sleep or re-enable the primary index building which will also "take some time" which increases the chance the config is in the state the client needs.

@daschl daschl self-assigned this Jul 17, 2020
daschl added a commit to daschl/testcontainers-java that referenced this issue Jul 20, 2020
This changeset adds a predicate to the wait strategy to make sure
that it not only returns a 200, but also that every enabled service
is actually already exposed in the config. Since we are polling
the server during bootstrap here, not all of them might show up
at the same time.

Also, while not contributing to the fix we poll the terse bucket
http config "b" instead of the verbose one "buckets" since it is
a little more efficient on the server side and actually the config
the client internally works with.

fixes testcontainers#2993
daschl added a commit to daschl/testcontainers-java that referenced this issue Jul 20, 2020
This changeset adds a predicate to the wait strategy to make sure
that it not only returns a 200, but also that every enabled service
is actually already exposed in the config. Since we are polling
the server during bootstrap here, not all of them might show up
at the same time.

Also, while not contributing to the fix we poll the terse bucket
http config "b" instead of the verbose one "buckets" since it is
a little more efficient on the server side and actually the config
the client internally works with.

fixes testcontainers#2993
@stale
Copy link

stale bot commented Oct 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Oct 17, 2020
@aaronjwhiteside
Copy link
Contributor Author

Keep alive!

@stale stale bot removed the stale label Oct 18, 2020
daschl added a commit to daschl/testcontainers-java that referenced this issue Dec 16, 2020
This changeset adds a predicate to the wait strategy to make sure
that it not only returns a 200, but also that every enabled service
is actually already exposed in the config. Since we are polling
the server during bootstrap here, not all of them might show up
at the same time.

Also, while not contributing to the fix we poll the terse bucket
http config "b" instead of the verbose one "buckets" since it is
a little more efficient on the server side and actually the config
the client internally works with.

fixes testcontainers#2993
bsideup added a commit that referenced this issue Feb 6, 2021
This changeset adds a predicate to the wait strategy to make sure
that it not only returns a 200, but also that every enabled service
is actually already exposed in the config. Since we are polling
the server during bootstrap here, not all of them might show up
at the same time.

Also, while not contributing to the fix we poll the terse bucket
http config "b" instead of the verbose one "buckets" since it is
a little more efficient on the server side and actually the config
the client internally works with.

fixes #2993

Co-authored-by: Sergei Egorov <bsideup@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants