-
Notifications
You must be signed in to change notification settings - Fork 25.2k
ClusterClientIT refactor #38872
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
Changes from all commits
314dbec
839ae83
eede9b5
f4fe328
0dd9b56
573080c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,10 +165,8 @@ public void testClusterHealthGreen() throws IOException { | |
assertThat(response.isTimedOut(), equalTo(false)); | ||
assertThat(response.status(), equalTo(RestStatus.OK)); | ||
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN)); | ||
assertNoIndices(response); | ||
} | ||
|
||
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/35450") | ||
public void testClusterHealthYellowClusterLevel() throws IOException { | ||
createIndex("index", Settings.EMPTY); | ||
createIndex("index2", Settings.EMPTY); | ||
|
@@ -178,15 +176,21 @@ public void testClusterHealthYellowClusterLevel() throws IOException { | |
|
||
logger.info("Shard stats\n{}", EntityUtils.toString( | ||
client().performRequest(new Request("GET", "/_cat/shards")).getEntity())); | ||
assertYellowShards(response); | ||
assertThat(response.getIndices().size(), equalTo(0)); | ||
} | ||
|
||
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/35450") | ||
public void testClusterHealthYellowIndicesLevel() throws IOException { | ||
createIndex("index", Settings.EMPTY); | ||
createIndex("index2", Settings.EMPTY); | ||
ClusterHealthRequest request = new ClusterHealthRequest(); | ||
String firstIndex = "index"; | ||
String secondIndex = "index2"; | ||
// including another index that we do not assert on, to ensure that we are not | ||
// accidentally asserting on entire cluster state | ||
String ignoredIndex = "tasks"; | ||
createIndex(firstIndex, Settings.EMPTY); | ||
createIndex(secondIndex, Settings.EMPTY); | ||
if (randomBoolean()) { | ||
createIndex(ignoredIndex, Settings.EMPTY); | ||
} | ||
ClusterHealthRequest request = new ClusterHealthRequest(firstIndex, secondIndex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
request.timeout("5s"); | ||
request.level(ClusterHealthRequest.Level.INDICES); | ||
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync); | ||
|
@@ -212,11 +216,9 @@ private static void assertYellowShards(ClusterHealthResponse response) { | |
assertThat(response.getDelayedUnassignedShards(), equalTo(0)); | ||
assertThat(response.getInitializingShards(), equalTo(0)); | ||
assertThat(response.getUnassignedShards(), equalTo(2)); | ||
assertThat(response.getActiveShardsPercent(), equalTo(50d)); | ||
} | ||
|
||
|
||
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/35450") | ||
|
||
public void testClusterHealthYellowSpecificIndex() throws IOException { | ||
createIndex("index", Settings.EMPTY); | ||
createIndex("index2", Settings.EMPTY); | ||
|
@@ -236,7 +238,6 @@ public void testClusterHealthYellowSpecificIndex() throws IOException { | |
assertThat(response.getDelayedUnassignedShards(), equalTo(0)); | ||
assertThat(response.getInitializingShards(), equalTo(0)); | ||
assertThat(response.getUnassignedShards(), equalTo(1)); | ||
assertThat(response.getActiveShardsPercent(), equalTo(50d)); | ||
assertThat(response.getIndices().size(), equalTo(1)); | ||
Map.Entry<String, ClusterIndexHealth> index = response.getIndices().entrySet().iterator().next(); | ||
assertYellowIndex(index.getKey(), index.getValue(), false); | ||
|
@@ -272,7 +273,19 @@ private static void assertYellowShard(int shardId, ClusterShardHealth shardHealt | |
assertThat(shardHealth.getRelocatingShards(), equalTo(0)); | ||
} | ||
|
||
private static void assertNoIndices(ClusterHealthResponse response) { | ||
assertThat(response.getIndices(), equalTo(emptyMap())); | ||
assertThat(response.getActivePrimaryShards(), equalTo(0)); | ||
assertThat(response.getNumberOfDataNodes(), equalTo(1)); | ||
assertThat(response.getNumberOfNodes(), equalTo(1)); | ||
assertThat(response.getActiveShards(), equalTo(0)); | ||
assertThat(response.getDelayedUnassignedShards(), equalTo(0)); | ||
assertThat(response.getInitializingShards(), equalTo(0)); | ||
assertThat(response.getUnassignedShards(), equalTo(0)); | ||
} | ||
|
||
public void testClusterHealthNotFoundIndex() throws IOException { | ||
createIndex("index", Settings.EMPTY); | ||
ClusterHealthRequest request = new ClusterHealthRequest("notexisted-index"); | ||
request.timeout("5s"); | ||
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync); | ||
|
@@ -284,15 +297,4 @@ public void testClusterHealthNotFoundIndex() throws IOException { | |
assertNoIndices(response); | ||
} | ||
|
||
private static void assertNoIndices(ClusterHealthResponse response) { | ||
assertThat(response.getIndices(), equalTo(emptyMap())); | ||
assertThat(response.getActivePrimaryShards(), equalTo(0)); | ||
assertThat(response.getNumberOfDataNodes(), equalTo(1)); | ||
assertThat(response.getNumberOfNodes(), equalTo(1)); | ||
assertThat(response.getActiveShards(), equalTo(0)); | ||
assertThat(response.getDelayedUnassignedShards(), equalTo(0)); | ||
assertThat(response.getInitializingShards(), equalTo(0)); | ||
assertThat(response.getUnassignedShards(), equalTo(0)); | ||
assertThat(response.getActiveShardsPercent(), equalTo(100d)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that I fully understand the removal of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pushed a fix for this There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
} |
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.
removed this line because it's duplicated from another test that covers this case, see method below.