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 correctly support .withReuse(true) #2794

Closed
aaronjwhiteside opened this issue May 26, 2020 · 8 comments
Closed

Comments

@aaronjwhiteside
Copy link
Contributor

After the container has been started the second time around the health checks fail ,because now certain apis require authentication.

The culprit lies in containerIsStarting():

https://github.com/testcontainers/testcontainers-java/blob/master/modules/couchbase/src/main/java/org/testcontainers/couchbase/CouchbaseContainer.java#L188-L199

waitUntilNodeIsOnline() fails the second time around because configureAdminUser() has already been called which now protects the api used in waitUntilNodeIsOnline().

Our current work around looks something like this:

        final CouchbaseContainer couchbase = new CouchbaseContainer("couchbase:enterprise-6.5.0") {
            @Override
            protected void configure() {
                super.configure();
                // needed because a random network alias is assigned in addition to anything we try to set withNetworkAliases("couchbase") which causes the hash comparision to fail.
                setNetworkAliases(Collections.singletonList("couchbase"));
            }

            @Override
            protected void containerIsStarting(final InspectContainerResponse containerInfo, final boolean reused) {
                if (!reused) {
                    super.containerIsStarting(containerInfo, reused);
                }
            }

            @Override
            protected void containerIsStarted(final InspectContainerResponse containerInfo, final boolean reused) {
                if (!reused) {
                    super.containerIsStarted(containerInfo, reused);
                } else {
                    this.logger().info("Couchbase container is ready! UI available at http://{}:{}", this.getHost(), this.getMappedPort(8091));
                }
            }
        }

It would be good if the correct fix was applied upstream, so that others may take advantage of CouchbaseContainer and .withReuse(true).

@daschl daschl self-assigned this May 29, 2020
@aaronjwhiteside
Copy link
Contributor Author

Any comments on the proposed solution/approach? I could open a PR for this..

Note: I wouldn't actually suggest pushing the changes to the configure() method upstream.

@daschl
Copy link
Member

daschl commented Jul 17, 2020

@aaronjwhiteside one thing we can try is just sending the credentials along with every http request - I haven't tried it for sure, but maybe the server ignores it if it's not needed and then it will "just work"?

@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
@jorgerod
Copy link

jorgerod commented Oct 19, 2021

Any news? I have the same problem

@kiview
Copy link
Member

kiview commented Oct 19, 2021

Did the workaround by @aaronjwhiteside work for you @jorgerod?
If yes, we might consider it for upstream. However, since the reusable feature is not a stable feature, I'd be hesitant to make upstream changes that are clearly reusability-aware at the moment.

@daschl
Copy link
Member

daschl commented Oct 19, 2021

@kiview I think we still should try sending the credentials with every request - that could work in all cases which would make the workaround not needed. But I did not try it yet, so we'd have to check that first.

@albihnf
Copy link
Contributor

albihnf commented Feb 13, 2025

Added PR with fix.

A workaround would be to extend CouchbaseContainer and override the two methods
protected void containerIsStarting(InspectContainerResponse containerInfo, boolean reused)
protected void containerIsStarted(InspectContainerResponse containerInfo, boolean reused)

See 63dea7a

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

5 participants