From 1197ebb9e9db22b4495fcbec8748e5372fa46a2b Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Wed, 30 Oct 2019 17:12:16 -0500 Subject: [PATCH] Additional assertions for SLM restart tests (#48428) Adds the ability to conditionally wipe SLM policies and ensures that you can read what you wrote across restarts. --- .../elasticsearch/test/rest/ESRestTestCase.java | 16 ++++++++++++++-- .../AbstractFullClusterRestartTestCase.java | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 65c4b9e4870..a3fc7209323 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -473,13 +473,22 @@ public abstract class ESRestTestCase extends ESTestCase { /** * Returns whether to preserve ILM Policies of this test. Defaults to not - * preserviing them. Only runs at all if xpack is installed on the cluster + * preserving them. Only runs at all if xpack is installed on the cluster * being tested. */ protected boolean preserveILMPoliciesUponCompletion() { return false; } + /** + * Returns whether to preserve SLM Policies of this test. Defaults to not + * preserving them. Only runs at all if xpack is installed on the cluster + * being tested. + */ + protected boolean preserveSLMPoliciesUponCompletion() { + return false; + } + /** * A set of ILM policies that should be preserved between runs. */ @@ -514,7 +523,10 @@ public abstract class ESRestTestCase extends ESTestCase { // Clean up SLM policies before trying to wipe snapshots so that no new ones get started by SLM after wiping if (nodeVersions.first().onOrAfter(Version.V_7_4_0)) { // SLM was introduced in version 7.4 - deleteAllSLMPolicies(); + if (preserveSLMPoliciesUponCompletion() == false) { + // Clean up SLM policies before trying to wipe snapshots so that no new ones get started by SLM after wiping + deleteAllSLMPolicies(); + } } SetOnce>>> inProgressSnapshots = new SetOnce<>(); diff --git a/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java b/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java index 6d1d6839e1c..19bd1c12d28 100644 --- a/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java @@ -109,4 +109,9 @@ public abstract class AbstractFullClusterRestartTestCase extends ESRestTestCase protected boolean preserveILMPoliciesUponCompletion() { return true; } + + @Override + protected boolean preserveSLMPoliciesUponCompletion() { + return true; + } }