Skip to content
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

[7.x] Add extra steps to ensure that watch indices are created before test starts (#66416) #66422

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchAction;
import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchRequest;
import org.elasticsearch.xpack.monitoring.LocalStateMonitoring;
import org.elasticsearch.xpack.core.watcher.watch.Watch;
import org.elasticsearch.xpack.monitoring.Monitoring;
import org.elasticsearch.xpack.monitoring.MonitoringService;
import org.elasticsearch.xpack.monitoring.exporter.ClusterAlertsUtil;
Expand Down Expand Up @@ -135,12 +136,7 @@ public void testLocalAlertsRemoval() throws Exception {
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(exporterSettings));

// ensure resources exist
assertBusy(() -> {
assertThat(indexExists(".monitoring-*"), is(true));
ensureYellowAndNoInitializingShards(".monitoring-*");
checkMonitoringTemplates();
assertWatchesExist(true);
});
ensureInitialLocalResources();

// call migration api
MonitoringMigrateAlertsResponse response = client().execute(MonitoringMigrateAlertsAction.INSTANCE,
Expand Down Expand Up @@ -174,12 +170,7 @@ public void testRepeatedLocalAlertsRemoval() throws Exception {
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(exporterSettings));

// ensure resources exist
assertBusy(() -> {
assertThat(indexExists(".monitoring-*"), is(true));
ensureYellowAndNoInitializingShards(".monitoring-*");
checkMonitoringTemplates();
assertWatchesExist(true);
});
ensureInitialLocalResources();

// call migration api
MonitoringMigrateAlertsResponse response = client().execute(MonitoringMigrateAlertsAction.INSTANCE,
Expand Down Expand Up @@ -479,6 +470,7 @@ public void testRemoteAlertsRemoteDisallowsWatcher() throws Exception {
}

private void ensureInitialLocalResources() throws Exception {
waitForWatcherIndices();
assertBusy(() -> {
assertThat(indexExists(".monitoring-*"), is(true));
ensureYellowAndNoInitializingShards(".monitoring-*");
Expand Down Expand Up @@ -595,4 +587,9 @@ private void assertMonitorWatches(final MockWebServer webServer, final boolean r
}
}
}

protected void waitForWatcherIndices() throws Exception {
awaitIndexExists(Watch.INDEX);
assertBusy(() -> ensureYellowAndNoInitializingShards(Watch.INDEX));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected void waitForMonitoringIndices() throws Exception {
assertBusy(this::ensureMonitoringIndicesYellow);
}

private void awaitIndexExists(final String index) throws Exception {
protected void awaitIndexExists(final String index) throws Exception {
assertBusy(() -> assertIndicesExists(index), 30, TimeUnit.SECONDS);
}

Expand Down