|
32 | 32 | import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchAction;
|
33 | 33 | import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchRequest;
|
34 | 34 | import org.elasticsearch.xpack.monitoring.LocalStateMonitoring;
|
| 35 | +import org.elasticsearch.xpack.core.watcher.watch.Watch; |
35 | 36 | import org.elasticsearch.xpack.monitoring.Monitoring;
|
36 | 37 | import org.elasticsearch.xpack.monitoring.MonitoringService;
|
37 | 38 | import org.elasticsearch.xpack.monitoring.exporter.ClusterAlertsUtil;
|
@@ -135,12 +136,7 @@ public void testLocalAlertsRemoval() throws Exception {
|
135 | 136 | assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(exporterSettings));
|
136 | 137 |
|
137 | 138 | // ensure resources exist
|
138 |
| - assertBusy(() -> { |
139 |
| - assertThat(indexExists(".monitoring-*"), is(true)); |
140 |
| - ensureYellowAndNoInitializingShards(".monitoring-*"); |
141 |
| - checkMonitoringTemplates(); |
142 |
| - assertWatchesExist(true); |
143 |
| - }); |
| 139 | + ensureInitialLocalResources(); |
144 | 140 |
|
145 | 141 | // call migration api
|
146 | 142 | MonitoringMigrateAlertsResponse response = client().execute(MonitoringMigrateAlertsAction.INSTANCE,
|
@@ -174,12 +170,7 @@ public void testRepeatedLocalAlertsRemoval() throws Exception {
|
174 | 170 | assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(exporterSettings));
|
175 | 171 |
|
176 | 172 | // ensure resources exist
|
177 |
| - assertBusy(() -> { |
178 |
| - assertThat(indexExists(".monitoring-*"), is(true)); |
179 |
| - ensureYellowAndNoInitializingShards(".monitoring-*"); |
180 |
| - checkMonitoringTemplates(); |
181 |
| - assertWatchesExist(true); |
182 |
| - }); |
| 173 | + ensureInitialLocalResources(); |
183 | 174 |
|
184 | 175 | // call migration api
|
185 | 176 | MonitoringMigrateAlertsResponse response = client().execute(MonitoringMigrateAlertsAction.INSTANCE,
|
@@ -479,6 +470,7 @@ public void testRemoteAlertsRemoteDisallowsWatcher() throws Exception {
|
479 | 470 | }
|
480 | 471 |
|
481 | 472 | private void ensureInitialLocalResources() throws Exception {
|
| 473 | + waitForWatcherIndices(); |
482 | 474 | assertBusy(() -> {
|
483 | 475 | assertThat(indexExists(".monitoring-*"), is(true));
|
484 | 476 | ensureYellowAndNoInitializingShards(".monitoring-*");
|
@@ -595,4 +587,9 @@ private void assertMonitorWatches(final MockWebServer webServer, final boolean r
|
595 | 587 | }
|
596 | 588 | }
|
597 | 589 | }
|
| 590 | + |
| 591 | + protected void waitForWatcherIndices() throws Exception { |
| 592 | + awaitIndexExists(Watch.INDEX); |
| 593 | + assertBusy(() -> ensureYellowAndNoInitializingShards(Watch.INDEX)); |
| 594 | + } |
598 | 595 | }
|
0 commit comments