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

Use codeinclude for Elasticsearch Module #2828

Merged
merged 9 commits into from
Jun 20, 2020
Merged

Conversation

raynigon
Copy link
Contributor

@raynigon raynigon commented Jun 2, 2020

use codeinclude for the elasticsearch module documentation

more details: #1158

use codeinclude for the elasticsearch module documentation
assertEquals(ClusterHealthStatus.GREEN, healths.getStatus());

// Stop the container.
container.stop();
Copy link
Member

Choose a reason for hiding this comment

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

please use try-with-resources to make sure that stop() is executed even if some assert fails

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, but this changed the code in the documentation

Copy link
Member

Choose a reason for hiding this comment

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

@raynigon

  1. please do not resolve conversations started by others.
  2. Judging by other codeincludes, it is possible to do it without changing the semantics in the docs. Please have a look at other codeincludes for some inspiration.

Copy link
Contributor Author

@raynigon raynigon Jun 2, 2020

Choose a reason for hiding this comment

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

First, sorry didnt know that.

Second, what i meant is, previously the docs showed container stopping with stop:
Bildschirmfoto 2020-06-02 um 5 41 28 PM

Now, the code uses try-with-resource statements which is logically different, i just wanted to point this out. If you could give me an example how to show the stop method and using try-with-resource statements in the source code, it would help me a lot. Currently the docs would look like this:
Bildschirmfoto 2020-06-02 um 5 41 40 PM

@raynigon raynigon requested a review from bsideup June 2, 2020 15:34
@kiview
Copy link
Member

kiview commented Jun 3, 2020

I was wondering if it would make more sense to use the code of the existing tests. I think they more or less show the usage for each case. The asserts would make it a bit more verbose though.

This comes from the fact, that I am reluctant to add more heavy automated tests to our pipeline if they basically duplicate existing ones.

modify container tests to reflect the code previously embedded in the documentation
@raynigon
Copy link
Contributor Author

raynigon commented Jun 3, 2020

I was wondering if it would make more sense to use the code of the existing tests. I think they more or less show the usage for each case. The asserts would make it a bit more verbose though.

This comes from the fact, that I am reluctant to add more heavy automated tests to our pipeline if they basically duplicate existing ones.

I tried to merge the existing code of the tests with the code previously embedded in the documentation. i appreciate feedback on how well the new test code reflects the ideas of the original documentation code.

the current version of elasticsearch should be used in the tests. To achieve this, the version can be determined by the version of the elasticsearch library which is included as a dependency.
Comment on lines 124 to 126
Response response = client.performRequest(new Request("GET", "/_cluster/health"));
assertThat(response.getStatusLine().getStatusCode(), is(200));
assertThat(EntityUtils.toString(response.getEntity()), containsString("cluster_name"));
Copy link
Member

Choose a reason for hiding this comment

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

We should probably omit these assertions from the docs...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it possible to exclude lines from a code block with the codeinclude macro?
This would be really helpful feature to decrease the amount of new code in the tests

Copy link
Member

Choose a reason for hiding this comment

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

Not directly to exclude, but you can use the same block ID more than once and every block should be included. e.g. given:

// someBlock {
A
B
// }
C
// someBlock {
D
// }

When rendered via codeinclude, it should appear like:

A
B
D

I'm partly tempted to add explicit excludes support to the codeinclude macro, but I think I'd prefer to try the above approach first.

Copy link
Contributor Author

@raynigon raynigon Jun 4, 2020

Choose a reason for hiding this comment

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

thanks that is exactly what i need

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This leads to a wrong indentation:
Bildschirmfoto 2020-06-06 um 11 10 04

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR could help to solve the problem: rnorth/mkdocs-codeinclude-plugin#14

Copy link
Member

Choose a reason for hiding this comment

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

I've been trying to untangle the PRs on the codeinclude plugin, because I think you're right. Unfortunately they're not independent, and that PR is built upon other PRs that have issues.

I think it'll be a bit of time before that gets merged.

Shall we just go ahead and merge? The indentation issue should get sorted out separately later 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds like a plan :)

@raynigon raynigon force-pushed the master branch 4 times, most recently from ed13b22 to fa31aab Compare June 6, 2020 08:54
Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

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

Thank you @raynigon - I think this is good to go. As mentioned in my comment, I think the code indentation issue will be sorted out separately when the codeinclude plugin is updated.

Thanks for your efforts on this.

@rnorth rnorth merged commit 7278c49 into testcontainers:master Jun 20, 2020
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