testcontainers-go icon indicating copy to clipboard operation
testcontainers-go copied to clipboard

feat(elasticsearch): add option to skip cert retrieval

Open ImFlog opened this issue 1 year ago • 1 comments

What does this PR do?

Add a new option to skip certificate retrieval.

Why is it important?

In some edge cases, it seems that the certificates are not available on the container and even if elasticsearch is working, the containers throw an error.

Related issues

Link related issues below. Insert the issue link or reference after the word "Closes" if merging this should automatically close it.

  • Closes #2207

How to test this PR

There should be no impact because the default behavior is still to retrieve the certs. One can use the WithoutCertRetrieval function in the RunContainer method.

ImFlog avatar May 03 '24 20:05 ImFlog

Deploy Preview for testcontainers-go ready!

Name Link
Latest commit e42fd7136d4e4c7cc30b84f676c004f4e0d51c27
Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/666828eab46f680008b1e5bb
Deploy Preview https://deploy-preview-2530--testcontainers-go.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar May 03 '24 20:05 netlify[bot]

Hello @mdelapenya, no worries for the delay, I am using testcontainers without the module in the meantime :)

The tricky part is I don't understand why the cert is impacted by the fact that I map a data dir. This doesn't really make sense to me and after some debugging I couldn't find anything in the base image that could provoke this behavior. Having the data bind directly at startup is pretty important to me to load my Elasticsearch with actual data for my tests but I cannot because of this behavior.

In #2207 It seems that another case to trigger this is when xpack is disabled (which makes more sense).

As I don't really care about certificates in my integration tests I thought that we could explicitly bypass the cert retrieval (even if it's not the cleanliest).

ImFlog avatar Jun 11 '24 10:06 ImFlog

Could you add a test where you're able to preload the index? That will help me debug and review it more in depth

Thanks!

mdelapenya avatar Jun 12 '24 16:06 mdelapenya

In the base issue I created a repository that reproduce the issue : https://github.com/ImFlog/repro-testcontainer-es Do you need something else ?

ImFlog avatar Jun 14 '24 08:06 ImFlog

Hi @ImFlog I noticed the repro version uses testcontainers-go v0.27.0, but in #2475 we added the very same feature, but using certain xpack properties. So if you upgrade to the v0.31.0 release, the latest, then you'll have the same behavior you proposed here.

In the repro, apart from bumping to the latest and greatest release, add this functional option to the RunContainer func:

		testcontainers.WithEnv(map[string]string{
			"xpack.security.enabled": "false",
		}),

And I think this is more Elasticsearch-idiomatic, as whoever knowing about Elastic configuration will understand properly what's going on here (ex-Elastic here 🙋 😉)

So if you agree, I think we should close this one.

mdelapenya avatar Jun 14 '24 15:06 mdelapenya

I just tried and indeed it works as expected. I don't understand why I didn't saw this other related issue. I'll close this as well as the associated Issue. Thank you for the help 🙏

ImFlog avatar Jun 24 '24 13:06 ImFlog