Skip to content

Commit f6ecade

Browse files
fix test: remove optionality of results based on enable/disable
1 parent 68bcc2f commit f6ecade

File tree

1 file changed

+20
-39
lines changed

1 file changed

+20
-39
lines changed

server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -305,47 +305,28 @@ public void testHeapUsageEstimateIsPresent() {
305305
}
306306

307307
public void testNodeWriteLoadsArePresent() {
308-
try {
309-
// Disable write load decider to begin with
310-
setWriteLoadDeciderEnablement(WriteLoadConstraintSettings.WriteLoadDeciderStatus.DISABLED);
311-
312-
InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class);
313-
ClusterInfoServiceUtils.refresh(clusterInfoService);
314-
Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolStats = clusterInfoService.getClusterInfo()
315-
.getNodeUsageStatsForThreadPools();
316-
assertNotNull(nodeThreadPoolStats);
317-
/** Not collecting stats yet because allocation write load stats collection is disabled by default.
318-
* see {@link WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING} */
319-
assertTrue(nodeThreadPoolStats.isEmpty());
320-
321-
// Enable collection for node write loads.
322-
setWriteLoadDeciderEnablement(
323-
randomBoolean()
324-
? WriteLoadConstraintSettings.WriteLoadDeciderStatus.ENABLED
325-
: WriteLoadConstraintSettings.WriteLoadDeciderStatus.LOW_THRESHOLD_ONLY
326-
);
308+
InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class);
327309

328-
// Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
329-
ClusterInfoServiceUtils.refresh(clusterInfoService);
330-
nodeThreadPoolStats = clusterInfoService.getClusterInfo().getNodeUsageStatsForThreadPools();
310+
// Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
311+
ClusterInfoServiceUtils.refresh(clusterInfoService);
312+
Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolStats = clusterInfoService.getClusterInfo()
313+
.getNodeUsageStatsForThreadPools();
314+
assertNotNull(nodeThreadPoolStats);
331315

332-
/** Verify that each node has usage stats reported. */
333-
ClusterState state = getInstanceFromNode(ClusterService.class).state();
334-
assertEquals(state.nodes().size(), nodeThreadPoolStats.size());
335-
for (DiscoveryNode node : state.nodes()) {
336-
assertTrue(nodeThreadPoolStats.containsKey(node.getId()));
337-
NodeUsageStatsForThreadPools nodeUsageStatsForThreadPools = nodeThreadPoolStats.get(node.getId());
338-
assertThat(nodeUsageStatsForThreadPools.nodeId(), equalTo(node.getId()));
339-
NodeUsageStatsForThreadPools.ThreadPoolUsageStats writeThreadPoolStats = nodeUsageStatsForThreadPools
340-
.threadPoolUsageStatsMap()
341-
.get(ThreadPool.Names.WRITE);
342-
assertNotNull(writeThreadPoolStats);
343-
assertThat(writeThreadPoolStats.totalThreadPoolThreads(), greaterThanOrEqualTo(0));
344-
assertThat(writeThreadPoolStats.averageThreadPoolUtilization(), greaterThanOrEqualTo(0.0f));
345-
assertThat(writeThreadPoolStats.maxThreadPoolQueueLatencyMillis(), greaterThanOrEqualTo(0L));
346-
}
347-
} finally {
348-
clearWriteLoadDeciderEnablementSetting();
316+
/** Verify that each node has usage stats reported. */
317+
ClusterState state = getInstanceFromNode(ClusterService.class).state();
318+
assertEquals(state.nodes().size(), nodeThreadPoolStats.size());
319+
for (DiscoveryNode node : state.nodes()) {
320+
assertTrue(nodeThreadPoolStats.containsKey(node.getId()));
321+
NodeUsageStatsForThreadPools nodeUsageStatsForThreadPools = nodeThreadPoolStats.get(node.getId());
322+
assertThat(nodeUsageStatsForThreadPools.nodeId(), equalTo(node.getId()));
323+
NodeUsageStatsForThreadPools.ThreadPoolUsageStats writeThreadPoolStats = nodeUsageStatsForThreadPools
324+
.threadPoolUsageStatsMap()
325+
.get(ThreadPool.Names.WRITE);
326+
assertNotNull(writeThreadPoolStats);
327+
assertThat(writeThreadPoolStats.totalThreadPoolThreads(), greaterThanOrEqualTo(0));
328+
assertThat(writeThreadPoolStats.averageThreadPoolUtilization(), greaterThanOrEqualTo(0.0f));
329+
assertThat(writeThreadPoolStats.maxThreadPoolQueueLatencyMillis(), greaterThanOrEqualTo(0L));
349330
}
350331
}
351332

0 commit comments

Comments
 (0)