From 731c96b5074c6dbde61a454605b8fae83baccbad Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 17 Jan 2020 13:26:40 -0700 Subject: [PATCH] =?UTF-8?q?[7.x]=20Use=20separate=20policies=20for=20tests?= =?UTF-8?q?=20in=20SnapshotLifecycleRest=E2=80=A6=20(#51181)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These policies store statistics, but since stats updating is asynchronous, it's possible for the update from one test to bleed into a separate one. This change switches the tests to use separate policy ids so that their stats are tracked independently. It also relaxes the checking constraint in one of the tests. Hopefully this: Resolves #48531 Resolves #48017 --- .../xpack/slm/SnapshotLifecycleRestIT.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java index bffde8f9c17..fc772d64e6f 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java @@ -66,10 +66,10 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { } public void testMissingRepo() throws Exception { - SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy("test-policy", "snap", + SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy("missing-repo-policy", "snap", "*/1 * * * * ?", "missing-repo", Collections.emptyMap(), SnapshotRetentionConfiguration.EMPTY); - Request putLifecycle = new Request("PUT", "/_slm/policy/test-policy"); + Request putLifecycle = new Request("PUT", "/_slm/policy/missing-repo-policy"); XContentBuilder lifecycleBuilder = JsonXContent.contentBuilder(); policy.toXContent(lifecycleBuilder, ToXContent.EMPTY_PARAMS); putLifecycle.setJsonEntity(Strings.toString(lifecycleBuilder)); @@ -84,7 +84,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { @SuppressWarnings("unchecked") public void testFullPolicySnapshot() throws Exception { final String indexName = "test"; - final String policyName = "test-policy"; + final String policyName = "full-policy"; final String repoId = "full-policy-repo"; int docCount = randomIntBetween(10, 50); List indexReqs = new ArrayList<>(); @@ -154,7 +154,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { @SuppressWarnings("unchecked") public void testPolicyFailure() throws Exception { - final String policyName = "test-policy"; + final String policyName = "failure-policy"; final String repoName = "policy-failure-repo"; final String indexPattern = "index-doesnt-exist"; initializeRepo(repoName); @@ -203,7 +203,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { issueUrl = "https://github.com/elastic/elasticsearch/issues/48531") public void testPolicyManualExecution() throws Exception { final String indexName = "test"; - final String policyName = "test-policy"; + final String policyName = "manual-policy"; final String repoId = "manual-execution-repo"; int docCount = randomIntBetween(10, 50); for (int i = 0; i < docCount; i++) { @@ -350,7 +350,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { issueUrl = "https://github.com/elastic/elasticsearch/issues/48017") public void testBasicTimeBasedRetention() throws Exception { final String indexName = "test"; - final String policyName = "test-policy"; + final String policyName = "basic-time-policy"; final String repoId = "time-based-retention-repo"; int docCount = randomIntBetween(10, 50); List indexReqs = new ArrayList<>(); @@ -421,8 +421,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase { int retentionRun = (int) stats.get(SnapshotLifecycleStats.RETENTION_RUNS.getPreferredName()); int totalTaken = (int) stats.get(SnapshotLifecycleStats.TOTAL_TAKEN.getPreferredName()); int totalDeleted = (int) stats.get(SnapshotLifecycleStats.TOTAL_DELETIONS.getPreferredName()); - assertThat(snapsTaken, equalTo(1)); - assertThat(totalTaken, equalTo(1)); + assertThat(snapsTaken, greaterThanOrEqualTo(1)); + assertThat(totalTaken, greaterThanOrEqualTo(1)); assertThat(retentionRun, greaterThanOrEqualTo(1)); assertThat(snapsDeleted, greaterThanOrEqualTo(1)); assertThat(totalDeleted, greaterThanOrEqualTo(1));