diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 3ce44f06a32..8ca149c3af2 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -323,39 +323,41 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase * */ private void configureAliasesForWatcherIndices() throws Exception { - // alias for .watches, setting the index template to the same as well - if (rarely()) { - String newIndex = ".watches-alias-index"; - BytesReference bytesReference = TemplateUtils.load("/watches.json"); - try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) { - Map parserMap = parser.map(); - Map allMappings = (Map) parserMap.get("mappings"); + if (internalCluster().size() > 0) { + // alias for .watches, setting the index template to the same as well + if (rarely()) { + String newIndex = ".watches-alias-index"; + BytesReference bytesReference = TemplateUtils.load("/watches.json"); + try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) { + Map parserMap = parser.map(); + Map allMappings = (Map) parserMap.get("mappings"); - CreateIndexResponse response = client().admin().indices().prepareCreate(newIndex) - .setCause("Index to test aliases with .watches index") - .addAlias(new Alias(WatchStore.INDEX)) - .setSettings((Map) parserMap.get("settings")) - .addMapping("watch", (Map) allMappings.get("watch")) - .get(); - assertAcked(response); + CreateIndexResponse response = client().admin().indices().prepareCreate(newIndex) + .setCause("Index to test aliases with .watches index") + .addAlias(new Alias(WatchStore.INDEX)) + .setSettings((Map) parserMap.get("settings")) + .addMapping("watch", (Map) allMappings.get("watch")) + .get(); + assertAcked(response); + } } - } - // alias for .triggered-watches, ensuring the index template is set appropriately - if (rarely()) { - String newIndex = ".triggered-watches-alias-index"; - BytesReference bytesReference = TemplateUtils.load("/triggered_watches.json"); - try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) { - Map parserMap = parser.map(); - Map allMappings = (Map) parserMap.get("mappings"); + // alias for .triggered-watches, ensuring the index template is set appropriately + if (rarely()) { + String newIndex = ".triggered-watches-alias-index"; + BytesReference bytesReference = TemplateUtils.load("/triggered_watches.json"); + try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) { + Map parserMap = parser.map(); + Map allMappings = (Map) parserMap.get("mappings"); - CreateIndexResponse response = client().admin().indices().prepareCreate(newIndex) - .setCause("Index to test aliases with .triggered-watches index") - .addAlias(new Alias(TriggeredWatchStore.INDEX_NAME)) - .setSettings((Map) parserMap.get("settings")) - .addMapping("triggered_watch", (Map) allMappings.get("triggered_watch")) - .get(); - assertAcked(response); + CreateIndexResponse response = client().admin().indices().prepareCreate(newIndex) + .setCause("Index to test aliases with .triggered-watches index") + .addAlias(new Alias(TriggeredWatchStore.INDEX_NAME)) + .setSettings((Map) parserMap.get("settings")) + .addMapping("triggered_watch", (Map) allMappings.get("triggered_watch")) + .get(); + assertAcked(response); + } } } }