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

feat: add Elasticsearch module #1574

Merged
merged 12 commits into from
Sep 5, 2023

Conversation

mdelapenya
Copy link
Member

@mdelapenya mdelapenya commented Sep 5, 2023

What does this PR do?

This PR adds a Go module for Elasticsearch including the following features:

  • support for Elasticsearch 6.x and above
  • support for passing a custom password
  • support for retrieving the CACert needed for configuring an HTTP connection over TLS
  • support for getting container settings in order to create an HTTP connection

For Elasticsearch 7 and below:

  • there is no ability to support TLS
  • if no password is set, then unauthenticated HTTP requests can be done to the elasticsearch instance
  • if a password is set, then only authenticated HTTP requests can be done to the elasticsearch instance (only over HTTP, no HTTPS support)

For Elasticsearch 8 and above:

  • if no password is set, unauthenticated HTTPS requests won't be allowed (secure by default)
  • if password is set, only authenticated HTTPS requests will be allowed, using the CACert internally extracted from the container (see below).
  • the module will extract the default CACert file from the container, storing its bytes in the container instance as a setting. It will be possible to use it afterwards to build an HTTPS request.

As we mentioned, the container exposes setting to create an HTTP connection. It's responsibility of the consumer to build it properly. For demonstration purpose, we have included examples and tests showing how to create the connection with:

  1. a plan HTTP client from the standard library,
  2. the Elasticsearch Go client: https://github.com/elastic/go-elasticsearch

Why is it important?

Adding modules is always great, but in particular Elasticsearch is a widely used technology.

@mdelapenya mdelapenya requested a review from a team as a code owner September 5, 2023 12:16
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Sep 5, 2023
@mdelapenya mdelapenya self-assigned this Sep 5, 2023
@netlify
Copy link

netlify bot commented Sep 5, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit afe295e
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/64f7236f61d9a700088554c2
😎 Deploy Preview https://deploy-preview-1574--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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -89,8 +89,6 @@ func read() Config {
return applyEnvironmentConfiguration(config)
}

fmt.Printf("Testcontainers properties file has been found: %s\n", tcProp)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this print was here affecting the Go Examples, which matches the output of a test. That's why I'm removing it here

@@ -0,0 +1,100 @@
package elasticsearch_test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Go examples for first time: I'm going to add them to all the modules, and the module generator, as they are true executable documentation that will land into the https://pkg.go.dev/github.com/testcontainers/testcontainers-go docs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another massive benefit is that code snippets to our docs site will be taken from the examples, therefore no test code will be copy&pasted.

@mdelapenya mdelapenya merged commit 5711936 into testcontainers:main Sep 5, 2023
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 6, 2023
* main:
  chore(deps): bump mkdocs-material from 8.2.7 to 9.2.8 (testcontainers#1580)
  feat: add Elasticsearch module (testcontainers#1574)
@mdelapenya mdelapenya deleted the elasticsearch-module branch September 6, 2023 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants