-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Elasticsearch testcontainer #826
Conversation
Hey team This is the first step to move my project under testcontainers umbrella. This is something I might bring within this PR or with another PR. In the meantime anyway, I'd appreciate a review :) Thanks! |
Hi @dadoonet! Nice! 👍 I just have one suggestion - could you please split the PR into a few, step by step? I hope it will not take a lot of your time. Thank you! |
Hmmm. That might take a significant time to do TBH. The full history is there: https://github.com/dadoonet/testcontainers-java-module-elasticsearch/commits/master I choose to squash it because it was not making a lot of sense to keep the history around. May be that was a bad decision though. LMK if this is a blocker on your side and I'll do it in the coming month hopefully. |
It took me finally less time than I was expecting. So I might come with something today. |
@dadoonet great, thank you! |
8b9d7d2
to
7c1a99e
Compare
@bsideup Done. That was actually interesting to do as it helped me to step back a bit and fix some code, added more tests, etc... |
@dadoonet will you submit a PR for each step? It is still a big change to merge at once, would be great to merge them one by one |
Oh? I thought you just wanted to see each commit one by one (which you can do). LMK. I might have time in the middle of coming week. |
This change moves Elasticsearch testcontainers project from https://github.com/dadoonet/testcontainers-java-module-elasticsearch to testcontainers project so it will benefit from automatic releases and will get more exposure. Step 1 just adds ElasticsearchContainer and its documentation.
7c1a99e
to
2a2a5ac
Compare
Hey team. So let's just start with some basics. I'll then send new PR to add other features. |
Oh great, I will give it a look later 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, looking forward to getting this merged. Just had some questions and minor remarks.
...les/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java
Outdated
Show resolved
Hide resolved
...les/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java
Outdated
Show resolved
Hide resolved
...les/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java
Outdated
Show resolved
Hide resolved
...elasticsearch/src/test/java/org/testcontainers/elasticsearch/ElasticsearchContainerTest.java
Show resolved
Hide resolved
...les/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java
Outdated
Show resolved
Hide resolved
...les/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java
Show resolved
Hide resolved
And fix some bugs. :)
Looks like CircleCI is failing for good reasons? |
@kiview Could you try instead: withEnv("discovery.type", "single-node"); Which is something I'd then add by default as for testing I believe this is fine to run one single node. |
Sounds good, I can check tomorrow. |
# Conflicts: # circle.yml
Awesome, I think we solved it! |
@dadoonet Just wanted to confirm, that it now works on my machine as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have it now, just two tiny remarks. Thanks for putting the effort in this PR, very much appreciated.
|
||
/** | ||
* Represents an elasticsearch docker instance which exposes by default port 9200 and 9300 (transport.tcp.port) | ||
* The docker image is by default fetch from docker.elastic.co/elasticsearch/elasticsearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is by default fetched
/** | ||
* Represents an elasticsearch docker instance which exposes by default port 9200 and 9300 (transport.tcp.port) | ||
* The docker image is by default fetch from docker.elastic.co/elasticsearch/elasticsearch | ||
* @author dadoonet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be okay for you to omit the author tag? I know we have it in the current codebase, but I think we strive for removing it.
If you would prefer to keep it, keep it 🙂
|
||
@Test | ||
public void elasticsearchDefaultTest() throws IOException { | ||
container = new ElasticsearchContainer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the try-with-resources pattern here, which means we wouldn't need the stopContainer
method (we use it for other tests). No big deal, though.
/** | ||
* Elasticsearch Docker base URL | ||
*/ | ||
private static final String ELASTICSEARCH_DEFAULT_BASE_URL = "docker.elastic.co/elasticsearch/elasticsearch"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change the name of this constant to ELASTICSEARCH_DEFAULT_IMAGE
or similar?
Thanks for this - looks great to me. I only had two trivial comments but other than that looks good to merge. Cheers! |
circle.yml
Outdated
@@ -31,11 +31,11 @@ jobs: | |||
when: always | |||
- store_test_results: | |||
path: ~/junit | |||
modules-no-jdbc-test-no-selenium: | |||
modules-no-jdbc-test-no-selenium-no-elasticsearch: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need it anymore since we figured out the issue, right?
public ElasticsearchContainer(String dockerImageName) { | ||
super(dockerImageName); | ||
logger().info("Starting an elasticsearch container using [{}]", dockerImageName); | ||
withNetwork(Network.SHARED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove it, doesn't make sense unless you connect multiple containers
<logger name="io.netty" level="WARN" /> | ||
<logger name="org.testcontainers.shaded" level="WARN"/> | ||
|
||
<!-- Prevent noisy logs - any errors thrown will be logged when caught if they need to be --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not relevant anymore
<appender-ref ref="STDOUT"/> | ||
</root> | ||
|
||
<logger name="org.apache.http" level="WARN"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove all but org.testcontainers.shaded
Not sure why travis failed. Could you launch a new build? |
@dadoonet Of course, sorry. Probably Gradle plugin server was not reachable. |
@kiview Was the build canceled? |
Thanks for working with us on this @dadoonet, I think we are good now and we can finally merge. |
This change moves Elasticsearch testcontainers project from https://github.com/dadoonet/testcontainers-java-module-elasticsearch to testcontainers project so it will benefit from automatic releases and will get more exposure.