|
80 | 80 | import org.elasticsearch.test.InternalSettingsPlugin; |
81 | 81 | import org.elasticsearch.threadpool.ThreadPool; |
82 | 82 | import org.elasticsearch.xcontent.XContentType; |
| 83 | +import org.junit.After; |
83 | 84 | import org.junit.Assert; |
84 | 85 |
|
85 | 86 | import java.io.IOException; |
@@ -305,25 +306,26 @@ public void testHeapUsageEstimateIsPresent() { |
305 | 306 | } |
306 | 307 |
|
307 | 308 | public void testNodeWriteLoadsArePresent() { |
308 | | - // Disable write load decider to begin with |
309 | | - setWriteLoadDeciderEnablement(WriteLoadConstraintSettings.WriteLoadDeciderStatus.DISABLED); |
310 | | - |
311 | | - InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class); |
312 | | - ClusterInfoServiceUtils.refresh(clusterInfoService); |
313 | | - Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolStats = clusterInfoService.getClusterInfo() |
314 | | - .getNodeUsageStatsForThreadPools(); |
315 | | - assertNotNull(nodeThreadPoolStats); |
316 | | - /** Not collecting stats yet because allocation write load stats collection is disabled by default. |
317 | | - * see {@link WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING} */ |
318 | | - assertTrue(nodeThreadPoolStats.isEmpty()); |
319 | | - |
320 | | - // Enable collection for node write loads. |
321 | | - setWriteLoadDeciderEnablement( |
322 | | - randomBoolean() |
323 | | - ? WriteLoadConstraintSettings.WriteLoadDeciderStatus.ENABLED |
324 | | - : WriteLoadConstraintSettings.WriteLoadDeciderStatus.LOW_THRESHOLD_ONLY |
325 | | - ); |
326 | 309 | try { |
| 310 | + // Disable write load decider to begin with |
| 311 | + setWriteLoadDeciderEnablement(WriteLoadConstraintSettings.WriteLoadDeciderStatus.DISABLED); |
| 312 | + |
| 313 | + InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class); |
| 314 | + ClusterInfoServiceUtils.refresh(clusterInfoService); |
| 315 | + Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolStats = clusterInfoService.getClusterInfo() |
| 316 | + .getNodeUsageStatsForThreadPools(); |
| 317 | + assertNotNull(nodeThreadPoolStats); |
| 318 | + /** Not collecting stats yet because allocation write load stats collection is disabled by default. |
| 319 | + * see {@link WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING} */ |
| 320 | + assertTrue(nodeThreadPoolStats.isEmpty()); |
| 321 | + |
| 322 | + // Enable collection for node write loads. |
| 323 | + setWriteLoadDeciderEnablement( |
| 324 | + randomBoolean() |
| 325 | + ? WriteLoadConstraintSettings.WriteLoadDeciderStatus.ENABLED |
| 326 | + : WriteLoadConstraintSettings.WriteLoadDeciderStatus.LOW_THRESHOLD_ONLY |
| 327 | + ); |
| 328 | + |
327 | 329 | // Force a ClusterInfo refresh to run collection of the node thread pool usage stats. |
328 | 330 | ClusterInfoServiceUtils.refresh(clusterInfoService); |
329 | 331 | nodeThreadPoolStats = clusterInfoService.getClusterInfo().getNodeUsageStatsForThreadPools(); |
@@ -361,10 +363,10 @@ public void testShardWriteLoadsArePresent() { |
361 | 363 |
|
362 | 364 | final InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class); |
363 | 365 |
|
364 | | - // Explicitly disable write load decider |
365 | | - setWriteLoadDeciderEnablement(WriteLoadConstraintSettings.WriteLoadDeciderStatus.DISABLED); |
366 | | - |
367 | 366 | try { |
| 367 | + // Explicitly disable write load decider |
| 368 | + setWriteLoadDeciderEnablement(WriteLoadConstraintSettings.WriteLoadDeciderStatus.DISABLED); |
| 369 | + |
368 | 370 | // Stats should not be collected when the decider is disabled |
369 | 371 | { |
370 | 372 | ClusterInfoServiceUtils.refresh(clusterInfoService); |
|
0 commit comments