From 4b2680dac70749fe00563fc8ecf64429bfe8c40e Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Wed, 5 Apr 2017 10:36:43 +0100 Subject: [PATCH] Tests: Ensure watch index is deleted to execute test correctly The test requires no watch index or alias to exist, so making sure this is deleted as part of the test. relates elastic/x-pack-elasticsearch#920 Original commit: elastic/x-pack-elasticsearch@c1cc953ce36962c3abbeb94f5d64490b29f3fea4 --- .../xpack/watcher/transport/action/get/GetWatchTests.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java index 94098cf7355..6854a3e241b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.watcher.transport.action.get; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.xpack.watcher.condition.AlwaysCondition; import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; @@ -55,6 +56,10 @@ public class GetWatchTests extends AbstractWatcherIntegrationTestCase { } public void testGetNotFoundOnNonExistingIndex() throws Exception { + // ensure index/alias is deleted, test infra might have created it automatically + try { + client().admin().indices().prepareDelete(Watch.INDEX).get(); + } catch (IndexNotFoundException e) {} Exception e = expectThrows(Exception.class, () -> watcherClient().getWatch(new GetWatchRequest("_name")).get()); assertThat(e.getMessage(), containsString("no such index")); }