[TEST] check if .watches index / alias exists before creating it

Original commit: elastic/x-pack-elasticsearch@74d85121eb
This commit is contained in:
Simon Willnauer 2016-12-18 10:17:43 +01:00
parent 278496d5e5
commit c9cfedc3cb
1 changed files with 8 additions and 4 deletions

View File

@ -134,8 +134,10 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
} }
public void testDeletedWhileQueued() throws Exception { public void testDeletedWhileQueued() throws Exception {
assertAcked(client().admin().indices().prepareCreate(".watches")); if (client().admin().indices().prepareExists(Watch.INDEX).get().isExists() == false) {
// we rarely create an .watches alias in the base class
assertAcked(client().admin().indices().prepareCreate(Watch.INDEX));
}
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
Wid wid = new Wid("_id", 1, now); Wid wid = new Wid("_id", 1, now);
ScheduleTriggerEvent event = new ScheduleTriggerEvent("_id", now, now); ScheduleTriggerEvent event = new ScheduleTriggerEvent("_id", now, now);
@ -314,8 +316,10 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
// Watcher could prevent to start if a watch record tried to executed twice or more and the watch didn't exist // Watcher could prevent to start if a watch record tried to executed twice or more and the watch didn't exist
// for that watch record or the execution threadpool rejected the watch record. // for that watch record or the execution threadpool rejected the watch record.
// A watch record without a watch is the easiest to simulate, so that is what this test does. // A watch record without a watch is the easiest to simulate, so that is what this test does.
assertAcked(client().admin().indices().prepareCreate(Watch.INDEX)); if (client().admin().indices().prepareExists(Watch.INDEX).get().isExists() == false) {
// we rarely create an .watches alias in the base class
assertAcked(client().admin().indices().prepareCreate(Watch.INDEX));
}
DateTime triggeredTime = new DateTime(2015, 11, 5, 0, 0, 0, 0, DateTimeZone.UTC); DateTime triggeredTime = new DateTime(2015, 11, 5, 0, 0, 0, 0, DateTimeZone.UTC);
final String watchRecordIndex = HistoryStore.getHistoryIndexNameForTime(triggeredTime); final String watchRecordIndex = HistoryStore.getHistoryIndexNameForTime(triggeredTime);