Use more reliable "never run" cron pattern in tests (#48608)

The cron schedule "1 2 3 4 5 ?" will run every May 4 at 03:02:01, which
may result in unnecessary test failures once a year. This commit
switches out uses of that schedule in tests for one which will never
execute (because it specifies a day which doesn't exist, Feb. 31). Also
factors the schedule out to a constant to make the intent clearer.
This commit is contained in:
Gordon Brown 2019-10-29 09:33:14 -07:00 committed by GitHub
parent d0cbbf9d58
commit cf235796c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -58,6 +58,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.startsWith;
public class SnapshotLifecycleRestIT extends ESRestTestCase {
private static final String NEVER_EXECUTE_CRON_SCHEDULE = "* * * 31 FEB ? *";
@Override
protected boolean waitForAllSnapshotsWiped() {
@ -206,7 +207,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
// Create a snapshot repo
initializeRepo(repoId);
createSnapshotPolicy(policyName, "snap", "1 2 3 4 5 ?", repoId, indexName, true);
createSnapshotPolicy(policyName, "snap", NEVER_EXECUTE_CRON_SCHEDULE, repoId, indexName, true);
ResponseException badResp = expectThrows(ResponseException.class,
() -> client().performRequest(new Request("POST", "/_slm/policy/" + policyName + "-bad/_execute")));
@ -350,7 +351,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
initializeRepo(repoId);
// Create a policy with a retention period of 1 millisecond
createSnapshotPolicy(policyName, "snap", "1 2 3 4 5 ?", repoId, indexName, true,
createSnapshotPolicy(policyName, "snap", NEVER_EXECUTE_CRON_SCHEDULE, repoId, indexName, true,
new SnapshotRetentionConfiguration(TimeValue.timeValueMillis(1), null, null));
// Manually create a snapshot
@ -446,7 +447,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
// Create a snapshot repo
initializeRepo("repo");
// Create a policy with a retention period of 1 millisecond
createSnapshotPolicy("policy", "snap", "1 2 3 4 5 ?", "repo", "*", true,
createSnapshotPolicy("policy", "snap", NEVER_EXECUTE_CRON_SCHEDULE, "repo", "*", true,
new SnapshotRetentionConfiguration(TimeValue.timeValueMillis(1), null, null));
final String snapshotName = executePolicy("policy");

View File

@ -61,6 +61,7 @@ import static org.hamcrest.Matchers.greaterThan;
*/
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
private static final String NEVER_EXECUTE_CRON_SCHEDULE = "* * * 31 FEB ? *";
private static final String REPO = "repo-id";
List<String> dataNodeNames = null;
@ -121,7 +122,7 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
initializeRepo(REPO);
logger.info("--> creating policy {}", policyName);
createSnapshotPolicy(policyName, "snap", "1 2 3 4 5 ?", REPO, indexName, true);
createSnapshotPolicy(policyName, "snap", NEVER_EXECUTE_CRON_SCHEDULE, REPO, indexName, true);
logger.info("--> blocking master from completing snapshot");
blockAllDataNodes(REPO);
@ -169,7 +170,7 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
initializeRepo(REPO);
logger.info("--> creating policy {}", policyId);
createSnapshotPolicy(policyId, "snap", "1 2 3 4 5 ?", REPO, indexName, true,
createSnapshotPolicy(policyId, "snap", NEVER_EXECUTE_CRON_SCHEDULE, REPO, indexName, true,
false, new SnapshotRetentionConfiguration(TimeValue.timeValueSeconds(0), null, null));
// Create a snapshot and wait for it to be complete (need something that can be deleted)
@ -297,7 +298,7 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
// Create a snapshot repo
initializeRepo(REPO);
createSnapshotPolicy(policyId, "snap", "1 2 3 4 5 ?", REPO, indexName, true,
createSnapshotPolicy(policyId, "snap", NEVER_EXECUTE_CRON_SCHEDULE, REPO, indexName, true,
partialSuccess, new SnapshotRetentionConfiguration(null, 1, 2));
// Create a failed snapshot