[TEST] Wait for Exporters independent of results (elastic/x-pack-elasticsearch#4031)

This should force waiting on the exporters so that the data can be awaited
separately.

Original commit: elastic/x-pack-elasticsearch@1e675f2786
This commit is contained in:
Chris Earle 2018-02-23 13:09:10 -05:00 committed by GitHub
parent 67b6009944
commit 0402ef4853
5 changed files with 8 additions and 32 deletions

View File

@ -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();

View File

@ -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

View File

@ -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<String> 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

View File

@ -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)

View File

@ -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<String, Object> getMonitoringUsageExporters() throws Exception {
private boolean getMonitoringUsageExportersDefined() throws Exception {
final XPackUsageResponse usageResponse = new XPackUsageRequestBuilder(client()).execute().get();
final Optional<MonitoringFeatureSetUsage> 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();
}
/**