Skip to content

Commit

Permalink
Use separate policies for tests in SnapshotLifecycleRestIT (elastic#5…
Browse files Browse the repository at this point in the history
…1075)

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 elastic#48531
Resolves elastic#48017
  • Loading branch information
dakrone committed Jan 17, 2020
1 parent 83c92cf commit 4622905
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ protected boolean waitForAllSnapshotsWiped() {
}

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));
Expand All @@ -84,7 +84,7 @@ public void testMissingRepo() throws Exception {
@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<IndexRequestBuilder> indexReqs = new ArrayList<>();
Expand Down Expand Up @@ -154,7 +154,7 @@ public void testFullPolicySnapshot() throws Exception {

@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);
Expand Down Expand Up @@ -203,7 +203,7 @@ public void testPolicyFailure() throws Exception {
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++) {
Expand Down Expand Up @@ -350,7 +350,7 @@ public void testStartStopStatus() throws Exception {
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<IndexRequestBuilder> indexReqs = new ArrayList<>();
Expand Down Expand Up @@ -421,8 +421,8 @@ public void testBasicTimeBasedRetention() throws Exception {
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));
Expand Down

0 comments on commit 4622905

Please sign in to comment.