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

ClusterClientIT refactor #38872

Merged
merged 6 commits into from
Feb 15, 2019
Merged

Conversation

pcsanwald
Copy link
Contributor

Fixes #35450. Goal of this PR is to uncover places where we assert on global cluster state, and, where possible, move to assert only on operations in the test. I've added comments in the PR for removals, but will also summarize here:

  • removed an assertNoIndices from testClusterHealthGreen. The goal of the test is to assert on a response from a green cluster, asserting that indices were not created on the cluster in the process of issuing the request seems a bit arbitrary (i.e. there are lots of side effects we could test for, but don't). and testing for this particular side effect has proved unreliable.

  • add an ignored index to testClusterHealthYellowIndicesLevel to ensure that extra indices aren't throwing off our assertions. The one problematic assertion in this regard is getActiveShardsPercent(), which is calculated on global cluster state (i.e. the index parameter passed in the request isn't used in this calculation). I don't think this assertion is worth the overhead of maintaining a deterministic global cluster state here.

Paul Sanwald added 2 commits February 13, 2019 15:39
issuing a cluster health request. Removing these assertions as they
are not a good fit for an integration test: the we should assume as
little as possible about the global state of the cluster here.

Looking at the code, it seems a bit arbitrary to test for this
particular side effect (that issuing a cluster health request would
unintentionally create an index).
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

createIndex(firstIndex, Settings.EMPTY);
createIndex(secondIndex, Settings.EMPTY);
createIndex(ignoredIndex, Settings.EMPTY);
ClusterHealthRequest request = new ClusterHealthRequest(firstIndex, secondIndex);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I scoped the request to indices created, and because I wasn't able to reproduce the test failures we saw on #35450 locally, I created a third index in order to test the scoping is correct.

@@ -178,15 +175,19 @@ public void testClusterHealthYellowClusterLevel() throws IOException {

logger.info("Shard stats\n{}", EntityUtils.toString(
client().performRequest(new Request("GET", "/_cat/shards")).getEntity()));
assertYellowShards(response);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this line because it's duplicated from another test that covers this case, see method below.

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

I left a couple of minor suggestions. Otherwise, LGTM.

BTW, did you open a discuss issue for getActiveShardsPercent? If you did, it might be useful to link these two issues together.

assertThat(response.getDelayedUnassignedShards(), equalTo(0));
assertThat(response.getInitializingShards(), equalTo(0));
assertThat(response.getUnassignedShards(), equalTo(0));
assertThat(response.getActiveShardsPercent(), equalTo(100d));
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that I fully understand the removal of assertNoIndices. In the comment you mention that you removed it from testClusterHealthGreen, but it looks like it was removed from testClusterHealthNotFoundIndex where it checks that we didn't get anything back when we asked for a non-existing index. I think it might be better to return this check back and, maybe, randomly create a bogus index to make sure that existing indices in the test don't interfere with it (basically do something similar to what you did in testClusterHealthYellowIndicesLevel). And just in case we can just remove this line with ActiveShardsPercent from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed a fix for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Total nitpick, but if you move this method below testClusterHealthNotFoundIndex() it will make diffs better.

String ignoredIndex = "tasks";
createIndex(firstIndex, Settings.EMPTY);
createIndex(secondIndex, Settings.EMPTY);
createIndex(ignoredIndex, Settings.EMPTY);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we can surround this with if (randomBoolean()) { ... } this way we can test both situations when our cluster have only these two indices and when something else is present.

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

assertThat(response.getDelayedUnassignedShards(), equalTo(0));
assertThat(response.getInitializingShards(), equalTo(0));
assertThat(response.getUnassignedShards(), equalTo(0));
assertThat(response.getActiveShardsPercent(), equalTo(100d));
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nitpick, but if you move this method below testClusterHealthNotFoundIndex() it will make diffs better.

@pcsanwald pcsanwald merged commit 207e185 into elastic:master Feb 15, 2019
@pcsanwald pcsanwald deleted the clusterclient-it-refactor branch February 15, 2019 23:54
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 16, 2019
* elastic/master:
  Ensure global test seed is used for all random testing tasks (elastic#38991)
  re-mutes SmokeTestWatcherWithSecurityIT (elastic#38995)
  Rollup jobs should be cleaned up before indices are deleted (elastic#38930)
  relax ML Info Docs expected response (elastic#38993)
  Re-enable single node tests (elastic#38852)
  ClusterClientIT refactor (elastic#38872)
  Fix typo in Index API doc
  Edits to text & formatting in Term Suggester doc (elastic#38963) (elastic#38989)
  Migrate Streamable to Writeable for WatchStatus (elastic#37390)
pcsanwald pushed a commit to pcsanwald/elasticsearch that referenced this pull request Feb 16, 2019
Add fixes for ClusterClientIT test and unmute tests.
pcsanwald pushed a commit to pcsanwald/elasticsearch that referenced this pull request Feb 16, 2019
Add fixes for ClusterClientIT test and unmute tests.
pcsanwald pushed a commit that referenced this pull request Feb 18, 2019
Add fixes for ClusterClientIT test and unmute tests.
pcsanwald pushed a commit that referenced this pull request Feb 18, 2019
Add fixes for ClusterClientIT test and unmute tests.
@danielmitterdorfer danielmitterdorfer added the >test Issues or PRs that are addressing/adding tests label Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>test Issues or PRs that are addressing/adding tests v6.7.0 v7.0.0-rc2 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] ClusterClientIT failure
5 participants