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

Examples in Couchbase documentation don't work out of the box #934

Closed
schauder opened this issue Oct 26, 2018 · 11 comments
Closed

Examples in Couchbase documentation don't work out of the box #934

schauder opened this issue Oct 26, 2018 · 11 comments

Comments

@schauder
Copy link

I've created the following test

public class TestcontainerTest {

	@Rule
	public CouchbaseContainer couchbase = new CouchbaseContainer()
			.withClusterAdmin("admin", "admin") // (1) this fixed the first issue
			.withNewBucket(DefaultBucketSettings.builder()
					.enableFlush(true)
					.name("bucket-name")
					.quota(100)
					.type(BucketType.COUCHBASE)
					.build());


	@Test
	public void testSomething() {

	}
}

At first without the lines marked (1).
It failed with an InvalidPasswordException. Adding the line (1) seemed to have fixed that.
But now gives:

11:36:22.628 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@16a0ee18, baseUrl=http://localhost:54657/, path=[/containers/a3502be83b42aa255ee0b4f3e76adf9624c6877ab139204d6ff5e068774ba271/json], queryParams={})
11:36:22.631 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: a3502be83b42aa255ee0b4f3e76adf9624c6877ab139204d6ff5e068774ba271,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@26f94b3f
11:36:22.631 [ducttape-0] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@16a0ee18, baseUrl=http://localhost:54657/, path=[/containers/a3502be83b42aa255ee0b4f3e76adf9624c6877ab139204d6ff5e068774ba271/json], queryParams={})
11:36:22.636 [main] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /dazzling_poitras: Waiting for 60 seconds for URL: http://localhost:33240/ui/index.html
11:36:32.739 [main] INFO 🐳 [couchbase/server:5.5.1] - Container couchbase/server:5.5.1 started
11:36:32.776 [main] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /dazzling_poitras: Waiting for 60 seconds for URL: http://localhost:33240/pools/default/
11:37:32.783 [main] ERROR 🐳 [couchbase/server:5.5.1] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:33240/pools/default/ should return HTTP [200])
	at org.testcontainers.containers.wait.strategy.HttpWaitStrategy.waitUntilReady(HttpWaitStrategy.java:197)
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
	at org.testcontainers.couchbase.CouchbaseContainer.initCluster(CouchbaseContainer.java:231)
	at org.testcontainers.couchbase.CouchbaseContainer.createCouchbaseEnvironment(CouchbaseContainer.java:332)
	at org.testcontainers.couchbase.CouchbaseContainer.getCouchbaseEnvironment(CouchbaseContainer.java:92)
	at org.testcontainers.couchbase.CouchbaseContainer.createCouchbaseCluster(CouchbaseContainer.java:328)
	at org.testcontainers.couchbase.CouchbaseContainer.getCouchbaseCluster(CouchbaseContainer.java:95)
	at org.testcontainers.couchbase.CouchbaseContainer.createBucket(CouchbaseContainer.java:256)
	at org.testcontainers.couchbase.CouchbaseContainer.containerIsStarted(CouchbaseContainer.java:322)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:295)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:237)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:235)
	at org.testcontainers.couchbase.CouchbaseContainer.doStart(CouchbaseContainer.java:130)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:220)
	at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:738)
	at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
11:37:32.784 [main] ERROR 🐳 [couchbase/server:5.5.1] - Container log output (if any) will follow:
11:37:32.792 [tc-okhttp-stream-1188401255] INFO 🐳 [couchbase/server:5.5.1] - STDOUT: Starting Couchbase Server -- Web UI available at http://<ip>:8091
11:37:32.792 [tc-okhttp-stream-1188401255] INFO 🐳 [couchbase/server:5.5.1] - STDOUT: and logs available in /opt/couchbase/var/lib/couchbase/logs
11:37:32.793 [main] DEBUG 🐳 [couchbase/server:5.5.1] - 
+ Profiler [Container startup]
|-- elapsed time [Prepare container configuration and host configuration]     0.000  seconds.
|---+ Profiler [Container startup attempt]
    |-- elapsed time       [Create container]     0.983  seconds.
    |-- elapsed time        [Start container]     0.892  seconds.
    |-- elapsed time   [Inspecting container]     0.004  seconds.
    |-- elapsed time [Call containerIsStarting on subclasses]     0.000  seconds.
    |-- elapsed time [Wait until container has started properly, or there's evidence it failed to start.]     0.004  seconds.
    |-- elapsed time [Wait until container started properly]    70.158  seconds.
    |-- Subtotal     [Container startup attempt]    72.040  seconds.
|-- elapsed time [Container startup attempt]    72.040  seconds.
|-- Total             [Container startup]    72.041  seconds.

11:37:32.805 [main] INFO org.testcontainers.containers.wait.strategy.HttpWaitStrategy - /dazzling_poitras: Waiting for 60 seconds for URL: http://localhost:33240/pools/default/

org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:33240/pools/default/ should return HTTP [200])

	at org.testcontainers.containers.wait.strategy.HttpWaitStrategy.waitUntilReady(HttpWaitStrategy.java:197)
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
	at org.testcontainers.couchbase.CouchbaseContainer.initCluster(CouchbaseContainer.java:231)
	at org.testcontainers.couchbase.CouchbaseContainer.createCouchbaseEnvironment(CouchbaseContainer.java:332)
	at org.testcontainers.couchbase.CouchbaseContainer.getCouchbaseEnvironment(CouchbaseContainer.java:92)
	at org.testcontainers.couchbase.CouchbaseContainer.createCouchbaseCluster(CouchbaseContainer.java:328)
	at org.testcontainers.couchbase.CouchbaseContainer.getCouchbaseCluster(CouchbaseContainer.java:95)
	at org.testcontainers.couchbase.CouchbaseContainer.stopCluster(CouchbaseContainer.java:188)
	at org.testcontainers.couchbase.CouchbaseContainer.stop(CouchbaseContainer.java:183)
	at org.testcontainers.containers.GenericContainer.finished(GenericContainer.java:760)
	at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:36)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


Process finished with exit code 255
@kiview
Copy link
Member

kiview commented Oct 26, 2018

Hey Jens,
can you just check if the following code works? It comes directly from our tests and it should work:

new CouchbaseContainer().withClusterAdmin("admin", "foobar");

Also I assume you are using Testcontainers 1.9.1?

Worst case you might need to add a breakpoint somewhere and look into the container logs to see why Couchbase isn't coming up.

I have no Couchbase experience, so it might be related to the Bucket definiton?

@schauder
Copy link
Author

Yes, that version does work.
Yes, it's Testcontainers 1.9.1

Unfortunately, I never use Couchbase before either. :-/

I took the code almost literally from the readme page of the couchbase module: https://github.com/testcontainers/testcontainers-java/tree/master/modules/couchbase

@kiview
Copy link
Member

kiview commented Oct 26, 2018

Again disclaimer, no Couchbase user here, but this works 🙂

CouchbaseContainer couchbaseContainer = new CouchbaseContainer()
            .withClusterAdmin("admin", "foobar")
            .withNewBucket(DefaultBucketSettings.builder()
            .enableFlush(true)
            .name("bucket-name")
            .quota(100)
            .password("foobar")
            .type(BucketType.COUCHBASE)
            .build());

Can you give it a try? Basically specifying password for the bucket.

@bsideup
Copy link
Member

bsideup commented Oct 26, 2018

Also, maybe @Kaidowei knows what happens

@schauder
Copy link
Author

Ok, that is interesting.

It does work.
But if you change the two passwords to admin it doesn't. So these seem to be a preconfigured user/password.

I thought it would configure a user (and password) to be created.

@kiview
Copy link
Member

kiview commented Oct 26, 2018

This happens for every bucket:

public void createBucket(BucketSettings bucketSetting, UserSettings userSettings, boolean primaryIndex) {
ClusterManager clusterManager = getCouchbaseCluster().clusterManager(clusterUsername, clusterPassword);
// Insert Bucket
BucketSettings bucketSettings = clusterManager.insertBucket(bucketSetting);
try {
// Insert Bucket user
clusterManager.upsertUser(AuthDomain.LOCAL, bucketSetting.name(), userSettings);
} catch (Exception e) {
logger().warn("Unable to insert user '" + bucketSetting.name() + "', maybe you are using older version");
}
if (index) {
Bucket bucket = getCouchbaseCluster().openBucket(bucketSettings.name(), bucketSettings.password());
new CouchbaseQueryServiceWaitStrategy(bucket).waitUntilReady(this);
if (primaryIndex) {
bucket.query(Index.createPrimaryIndex().on(bucketSetting.name()));
}
}
}

Since the classes involved in this operation are not from Testcontainers but from Couchbase, I don't think this is a Testcontainers related problem.
Using secret as the password value works by the way, so maybe Couchbase doesn't allow same value for username and password.

We could probably improve UX by failing early and with more specific errors.

@kiview
Copy link
Member

kiview commented Oct 26, 2018

lol, it's actually super simple and because of the default password policy:

Couchbase Server provides a default password-policy. This demands only that the password have a minimum of six characters.

Sorry for the confusion.

@schauder
Copy link
Author

Thanks, that clears it up.

Having a dedicated error would indeed help.
Also, the example in the documentation could be fixed.

Thanks again.

@kiview kiview changed the title CouchbaseContainer fails to start Examples in Couchbase documentation don't work out of the box Oct 26, 2018
@kiview
Copy link
Member

kiview commented Oct 26, 2018

You are right. I've changed the title of the issue, so that we at least cleanup the examples.

@stale
Copy link

stale bot commented Jan 24, 2019

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 Jan 24, 2019
@stale
Copy link

stale bot commented Feb 7, 2019

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

@stale stale bot closed this as completed Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants