From 3b97936587dc6a30a14c674a327f8b7e702d69fc Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 13 Sep 2016 09:49:36 +0000 Subject: [PATCH] test: Remove WatcherBackwardsCompatibilityTests as it was specifically build for testing upgrade from 2.x to 5.x and to verify the scripts and template work/serialize as expected. On the master this is test is no longer relevant. The OldWatcherIndicesBackwardsCompatibilityIT covers a major upgrade too. Original commit: elastic/x-pack-elasticsearch@657881916b0df707f838e3b0085bcdb360114973 --- .../WatcherBackwardsCompatibilityTests.java | 129 ------------------ .../resources/bwc_indices/bwc_index_2_3_5.zip | Bin 7916 -> 0 bytes 2 files changed, 129 deletions(-) delete mode 100644 elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatcherBackwardsCompatibilityTests.java delete mode 100644 elasticsearch/x-pack/watcher/src/test/resources/bwc_indices/bwc_index_2_3_5.zip diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatcherBackwardsCompatibilityTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatcherBackwardsCompatibilityTests.java deleted file mode 100644 index 4dc2c4b4cad..00000000000 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatcherBackwardsCompatibilityTests.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.watcher.test.integration; - -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestUtil; -import org.elasticsearch.Version; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.script.MockScriptPlugin; -import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath; -import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; -import org.elasticsearch.xpack.watcher.transport.actions.get.GetWatchResponse; -import org.elasticsearch.xpack.watcher.watch.WatchStore; - -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0) -@LuceneTestCase.SuppressFileSystems("ExtrasFS") -public class WatcherBackwardsCompatibilityTests extends AbstractWatcherIntegrationTestCase { - - private static final String INDEX_NAME = WatchStore.INDEX; - private static final String TYPE_NAME = WatchStore.DOC_TYPE; - - @Override - protected boolean enableSecurity() { - return false; - } - - @Override - protected boolean timeWarped() { - return false; - } - - @Override - protected List> pluginTypes() { - List> plugins = super.pluginTypes(); - plugins.add(FoolMeScriptLang.class); - return plugins; - } - - public void testWatchLoadedSuccessfullyAfterUpgrade() throws Exception { - // setup node - Path dataDir = createTempDir(); - Path clusterDir = Files.createDirectory(dataDir.resolve(cluster().getClusterName())); - try (InputStream stream = WatcherBackwardsCompatibilityTests.class. - getResourceAsStream("/bwc_indices/bwc_index_2_3_5.zip")) { - TestUtil.unzip(stream, clusterDir); - } - - Settings.Builder nodeSettings = Settings.builder() - .put(super.nodeSettings(0)) - .put(Environment.PATH_DATA_SETTING.getKey(), dataDir); - internalCluster().startNode(nodeSettings.build()); - ensureYellow(); - - // verify cluster state: - assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertThat(state.metaData().indices().size(), equalTo(1)); // only the .watches index - // (the watch has a very high interval (99 weeks)) - assertThat(state.metaData().indices().get(INDEX_NAME), notNullValue()); - assertThat(state.metaData().indices().get(INDEX_NAME).getCreationVersion(), equalTo(Version.V_2_3_5)); - assertThat(state.metaData().indices().get(INDEX_NAME).getUpgradedVersion(), equalTo(Version.CURRENT)); - assertThat(state.metaData().indices().get(INDEX_NAME).getMappings().size(), equalTo(1)); - assertThat(state.metaData().indices().get(INDEX_NAME).getMappings().get(TYPE_NAME), notNullValue()); - }); - - // verify existing watcher documents: - SearchResponse searchResponse = client().prepareSearch(INDEX_NAME) - .setTypes(TYPE_NAME) - .get(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); - assertThat(searchResponse.getHits().getAt(0).id(), equalTo("log_error_watch")); - - // Verify that we can get the watch, which means the watch stored in ES 2.3.5 cluster has been successfully - // loaded with the current version of ES: - ensureWatcherStarted(); - assertThat(watcherClient().prepareWatcherStats().get().getWatchesCount(), equalTo(1L)); - GetWatchResponse getWatchResponse = watcherClient().prepareGetWatch("log_error_watch").get(); - assertThat(getWatchResponse.isFound(), is(true)); - Map watchSourceAsMap = getWatchResponse.getSource().getAsMap(); - assertThat(ObjectPath.eval("trigger.schedule.interval", watchSourceAsMap), equalTo("99w")); - assertThat(ObjectPath.eval("input.search.request.body.query.bool.filter.1.range.date.to", watchSourceAsMap), - equalTo("{{ctx.trigger.scheduled_time}}")); - assertThat(ObjectPath.eval("actions.log_error.logging.text", watchSourceAsMap), - equalTo("Found {{ctx.payload.hits.total}} errors in the logs")); - - // Check that all scripts have been upgraded, so that the language has been set to groovy (legacy language default): - assertThat(ObjectPath.eval("input.search.request.body.query.bool.filter.2.script.script.lang", watchSourceAsMap), - equalTo("groovy")); - assertThat(ObjectPath.eval("input.search.request.body.aggregations.avg_grade.avg.script.lang", watchSourceAsMap), - equalTo("groovy")); - assertThat(ObjectPath.eval("condition.script.lang", watchSourceAsMap), equalTo("groovy")); - } - - // Fool the script service that this is the groovy script language, so that we can just load the watch upon startup - // and verify that the lang options on scripts have been set. - public static class FoolMeScriptLang extends MockScriptPlugin{ - - @Override - protected Map, Object>> pluginScripts() { - return Collections.singletonMap("ctx.payload.hits.total > 0", (vars) -> true); - } - - @Override - public String pluginScriptLang() { - return "groovy"; - } - } - -} diff --git a/elasticsearch/x-pack/watcher/src/test/resources/bwc_indices/bwc_index_2_3_5.zip b/elasticsearch/x-pack/watcher/src/test/resources/bwc_indices/bwc_index_2_3_5.zip deleted file mode 100644 index 5d074c0ab5da1b342131863fd693eb9637a21e78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7916 zcmb7JcRbX87(e5Xy*H7Od3T&MN=97C8AoJqM<<)Cl)X!2>rl#$5|x!G3RyX;IAjzl zmC-K^es@WslFsXU?vMMv-=F7sKA-1#f8U2hkdRUW2(M66<|E%ee19VYa06W3>``7| zLxWuak|w??qfXBbqmzDA03y;QA^?Dt8UIb>kNa!kL?TO$8pjSV*{_ zch3yTqUyfWkt2(;X{W>O<=Fbl2BL&aBHQiVZmd{+q8knB2A^3@`{It!;CpiJgD>>s zXIxj<=%}X-jbI~$lu^Faq6z4*m}9iBJY3zpLW0`p_JH&Wg;S=fC3#uJSrS)ei*FC^ zPicX~ToA)hwR)6B%7;GVO$e|^jAxIE9<4p?=l5~oh~rDo*A?gX5+8{{YiBhu=SD81 znjV6q9SpU5iK50;=LZ4#F;&=5Ss+<|L2)p}Wc^fOTVmmfbg`qpL>b&VocB-a*1gGY zq3gVe_=H);AO$UCVJgwsgUkjLp}xb=Bxv42Thu3icMY}LXw3pq7p5s=6xWRB%3Mzt z>ZQ8KvIY)VFmlDp6+z&0vz;#>Pd~?hxg^4$tzDU#Q=sJ(OlwWRzQim8ga$0WjMX{0jcXX$cz}qx zZ@H2x%Ll1Q1WL#-4TcjH8cOX!$~y`toa}hldC%y$nYwE;83ZP&aDyd|hGs;WJ%Jmk zhZ?332_q*_NfSHYbnG>BWbBwk_q&)fMMp&I3P3Nn zWiXiJac4C3+Y6d@UALYIuy-=Z^;c>+RjBXyx|QYqgx<^R*D?Y%BIk9|#Zqmq&Rg-^ z(QrO(^=hzpmT#EffOV!lH<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