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

Add Elasticsearch testcontainer #826

Merged
merged 15 commits into from
Nov 4, 2018

Conversation

dadoonet
Copy link
Contributor

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.

@dadoonet
Copy link
Contributor Author

Hey team

This is the first step to move my project under testcontainers umbrella.
I still need to check out the recent changes that happened on Elasticsearch side regarding security.

This is something I might bring within this PR or with another PR.

In the meantime anyway, I'd appreciate a review :)

Thanks!

@bsideup
Copy link
Member

bsideup commented Aug 10, 2018

Hi @dadoonet!

Nice! 👍

I just have one suggestion - could you please split the PR into a few, step by step?
Currently it does a lot of things (ElasticsearchResource, plugins, etc) and it's a bit hard to review. Maybe you can contribute the ElasticsearchContainer first, and other "features" on top of it?

I hope it will not take a lot of your time. Thank you!

@bsideup bsideup self-assigned this Aug 10, 2018
@dadoonet
Copy link
Contributor Author

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.

@dadoonet
Copy link
Contributor Author

It took me finally less time than I was expecting. So I might come with something today.

@bsideup
Copy link
Member

bsideup commented Aug 10, 2018

@dadoonet great, thank you!
Sorry for asking, but it will help us a lot to focus on the changes 👍
Looking forward to having an official Elasticsearch module 😍

@dadoonet
Copy link
Contributor Author

@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...

@bsideup
Copy link
Member

bsideup commented Aug 12, 2018

@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

@dadoonet
Copy link
Contributor Author

Oh? I thought you just wanted to see each commit one by one (which you can do).
I can for sure but isn't that a bit overkill ?

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.
@dadoonet
Copy link
Contributor Author

Hey team. So let's just start with some basics. I'll then send new PR to add other features.

@kiview
Copy link
Member

kiview commented Sep 21, 2018

Oh great, I will give it a look later 🙂

Copy link
Member

@kiview kiview left a 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.

@kiview
Copy link
Member

kiview commented Sep 24, 2018

Looks like CircleCI is failing for good reasons?
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (http://localhost:32774/ should return HTTP 200)
Still I retriggered the build.

@dadoonet
Copy link
Contributor Author

dadoonet commented Oct 9, 2018

@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.

@kiview
Copy link
Member

kiview commented Oct 9, 2018

Sounds good, I can check tomorrow.
If you want, just push and we see if CI works

@kiview
Copy link
Member

kiview commented Oct 9, 2018

Awesome, I think we solved it!
I will give it a final review tomorrow.

@kiview kiview self-assigned this Oct 15, 2018
@kiview
Copy link
Member

kiview commented Oct 15, 2018

@dadoonet Just wanted to confirm, that it now works on my machine as well.

Copy link
Member

@kiview kiview left a 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
Copy link
Member

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
Copy link
Member

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();
Copy link
Member

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";
Copy link
Member

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?

@rnorth
Copy link
Member

rnorth commented Oct 15, 2018

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:
Copy link
Member

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);
Copy link
Member

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 -->
Copy link
Member

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"/>
Copy link
Member

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

@testcontainers testcontainers deleted a comment Oct 27, 2018
@testcontainers testcontainers deleted a comment Oct 27, 2018
@testcontainers testcontainers deleted a comment Oct 27, 2018
@dadoonet
Copy link
Contributor Author

Not sure why travis failed. Could you launch a new build?

@kiview
Copy link
Member

kiview commented Nov 2, 2018

@dadoonet Of course, sorry. Probably Gradle plugin server was not reachable.
I triggered a restart.

@dadoonet
Copy link
Contributor Author

dadoonet commented Nov 3, 2018

@kiview Was the build canceled?

@kiview
Copy link
Member

kiview commented Nov 4, 2018

Thanks for working with us on this @dadoonet, I think we are good now and we can finally merge.

@kiview kiview added this to the next milestone Nov 4, 2018
@kiview kiview merged commit 46b6865 into testcontainers:master Nov 4, 2018
@dadoonet dadoonet deleted the pr/elasticsearch branch November 5, 2018 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants