diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java index dcff0a27f92..9e4e971f423 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java @@ -26,20 +26,8 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; @ClusterScope(scope = TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0) public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTestCase { - public AbstractIndicesCleanerTestCase() throws Exception { - super(); - } - static Integer INDEX_TEMPLATE_VERSION = null; - @Override - protected Settings nodeSettings(int nodeOrdinal) { - Settings.Builder settings = Settings.builder() - .put(super.nodeSettings(nodeOrdinal)) - .put(MonitoringService.INTERVAL.getKey(), "-1"); - return settings.build(); - } - public void testNothingToDelete() throws Exception { internalCluster().startNode(); diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java index b74701d35fe..eff2c607840 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java @@ -24,10 +24,6 @@ import static org.hamcrest.Matchers.equalTo; public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase { - public LocalIndicesCleanerTests() throws Exception { - super(); - } - private final boolean cleanUpWatcherHistory = randomBoolean(); @Override diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 1ced4cd7208..9a23ee788e7 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -32,7 +32,6 @@ import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringDoc; import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils; import org.elasticsearch.xpack.core.ssl.SSLService; -import org.elasticsearch.xpack.monitoring.MonitoringService; import org.elasticsearch.xpack.monitoring.MonitoringTestUtils; import org.elasticsearch.xpack.monitoring.collector.indices.IndexRecoveryMonitoringDoc; import org.elasticsearch.xpack.monitoring.exporter.ClusterAlertsUtil; @@ -74,10 +73,6 @@ import static org.hamcrest.Matchers.notNullValue; numDataNodes = 1, numClientNodes = 0, transportClientRatio = 0.0, supportsDedicatedMasters = false) public class HttpExporterIT extends MonitoringIntegTestCase { - public HttpExporterIT() throws Exception { - super(); - } - private final List clusterAlertBlacklist = rarely() ? randomSubsetOf(Arrays.asList(ClusterAlertsUtil.WATCH_IDS)) : Collections.emptyList(); private final boolean templatesExistsAlready = randomBoolean(); @@ -96,7 +91,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase { } @After - public void stopWebServer() throws Exception { + public void stopWebServer() { if (webServer != null) { webServer.close(); } @@ -113,7 +108,6 @@ public class HttpExporterIT extends MonitoringIntegTestCase { // we make an exporter on demand per test return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MonitoringService.INTERVAL.getKey(), "-1") .put("xpack.monitoring.exporters._http.type", "http") .put("xpack.monitoring.exporters._http.ssl.truststore.password", "foobar") // ensure that ssl can be used by settings .put("xpack.monitoring.exporters._http.headers.ignored", "value") // ensure that headers can be used by settings diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java index 4d94bbecee8..1d84cae65bb 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java @@ -41,8 +41,8 @@ public abstract class LocalExporterIntegTestCase extends MonitoringIntegTestCase protected Settings localExporterSettings() { return Settings.builder() - .put(MonitoringService.ENABLED.getKey(), false) - .put(MonitoringService.INTERVAL.getKey(), "3s") + .put("xpack.monitoring.collection.enabled", false) + .put("xpack.monitoring.collection.interval", "1s") .put("xpack.monitoring.exporters." + exporterName + ".type", LocalExporter.TYPE) .put("xpack.monitoring.exporters." + exporterName + ".enabled", false) .put("xpack.monitoring.exporters." + exporterName + ".cluster_alerts.management.enabled", false) diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 004de800a53..77863a0eba2 100644 --- a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -515,7 +515,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { // delete anything that may happen to already exist assertAcked(client().admin().indices().prepareDelete(".monitoring-*").get()); - assertThat("Must be no enabled exporters before enabling monitoring", getMonitoringUsageExporters().isEmpty(), is(true)); + assertThat("Must be no enabled exporters before enabling monitoring", getMonitoringUsageExportersDefined(), is(true)); final Settings settings = Settings.builder() .put("xpack.monitoring.collection.enabled", true) @@ -524,9 +524,8 @@ public class MonitoringIT extends ESSingleNodeTestCase { assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); + assertBusy(() -> assertThat("[_local] exporter not enabled yet", getMonitoringUsageExportersDefined(), is(false))); assertBusy(() -> { - assertThat("[_local] exporter not enabled yet", getMonitoringUsageExporters().isEmpty(), is(false)); - assertThat("No monitoring documents yet", client().prepareSearch(".monitoring-es-" + TEMPLATE_VERSION + "-*") .setSize(0) @@ -547,10 +546,9 @@ public class MonitoringIT extends ESSingleNodeTestCase { assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); + assertBusy(() -> assertThat("Exporters are not yet stopped", getMonitoringUsageExportersDefined(), is(true))); assertBusy(() -> { try { - assertThat("Exporters are not yet stopped", getMonitoringUsageExporters().isEmpty(), is(true)); - // now wait until Monitoring has actually stopped final NodesStatsResponse response = client().admin().cluster().prepareNodesStats().clear().setThreadPool(true).get(); @@ -573,7 +571,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { }); } - private Map getMonitoringUsageExporters() throws Exception { + private boolean getMonitoringUsageExportersDefined() throws Exception { final XPackUsageResponse usageResponse = new XPackUsageRequestBuilder(client()).execute().get(); final Optional monitoringUsage = usageResponse.getUsages() @@ -584,7 +582,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { assertThat("Monitoring feature set does not exist", monitoringUsage.isPresent(), is(true)); - return monitoringUsage.get().getExporters(); + return monitoringUsage.get().getExporters().isEmpty(); } /**