Skip to content

[ILM] reduce time restriction on IndexLifecycleExplainResponse #35954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,12 @@ private IndexLifecycleExplainResponse(String index, boolean managedByILM, String
throw new IllegalArgumentException("[" + POLICY_NAME_FIELD.getPreferredName() + "] cannot be null for managed index");
}
// check to make sure that step details are either all null or all set.
long numNull = Stream.of(phase, action, step, phaseTime, actionTime, stepTime).filter(Objects::isNull).count();
if (numNull > 0 && numNull < 6) {
long numNull = Stream.of(phase, action, step).filter(Objects::isNull).count();
if (numNull > 0 && numNull < 3) {
throw new IllegalArgumentException("managed index response must have complete step details [" +
PHASE_FIELD.getPreferredName() + "=" + phase + ", " +
PHASE_TIME_FIELD.getPreferredName() + "=" + phaseTime + ", " +
ACTION_FIELD.getPreferredName() + "=" + action + ", " +
ACTION_TIME_FIELD.getPreferredName() + "=" + actionTime + ", " +
STEP_FIELD.getPreferredName() + "=" + step + ", " +
STEP_TIME_FIELD.getPreferredName() + "=" + stepTime + "]");
STEP_FIELD.getPreferredName() + "=" + step + "]");
}
} else {
if (policyName != null || lifecycleDate != null || phase != null || action != null || step != null || failedStep != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static IndexLifecycleExplainResponse randomManagedIndexExplainResponse()
}

public void testInvalidStepDetails() {
final int numNull = randomIntBetween(1, 6);
final int numNull = randomIntBetween(1, 3);
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () ->
IndexLifecycleExplainResponse.newManagedIndexResponse(randomAlphaOfLength(10),
randomAlphaOfLength(10),
Expand All @@ -78,9 +78,9 @@ public void testInvalidStepDetails() {
(numNull == 2) ? null : randomAlphaOfLength(10),
(numNull == 3) ? null : randomAlphaOfLength(10),
randomBoolean() ? null : randomAlphaOfLength(10),
(numNull == 4) ? null : randomNonNegativeLong(),
(numNull == 5) ? null : randomNonNegativeLong(),
(numNull == 6) ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : new BytesArray(new RandomStepInfo(() -> randomAlphaOfLength(10)).toString()),
randomBoolean() ? null : PhaseExecutionInfoTests.randomPhaseExecutionInfo("")));
assertThat(exception.getMessage(), startsWith("managed index response must have complete step details"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,12 @@ private IndexLifecycleExplainResponse(String index, boolean managedByILM, String
throw new IllegalArgumentException("[" + POLICY_NAME_FIELD.getPreferredName() + "] cannot be null for managed index");
}
// check to make sure that step details are either all null or all set.
long numNull = Stream.of(phase, action, step, phaseTime, actionTime, stepTime).filter(Objects::isNull).count();
if (numNull > 0 && numNull < 6) {
long numNull = Stream.of(phase, action, step).filter(Objects::isNull).count();
if (numNull > 0 && numNull < 3) {
throw new IllegalArgumentException("managed index response must have complete step details [" +
PHASE_FIELD.getPreferredName() + "=" + phase + ", " +
PHASE_TIME_FIELD.getPreferredName() + "=" + phaseTime + ", " +
ACTION_FIELD.getPreferredName() + "=" + action + ", " +
ACTION_TIME_FIELD.getPreferredName() + "=" + actionTime + ", " +
STEP_FIELD.getPreferredName() + "=" + step + ", " +
STEP_TIME_FIELD.getPreferredName() + "=" + stepTime + "]");
STEP_FIELD.getPreferredName() + "=" + step + "]");
}
} else {
if (policyName != null || lifecycleDate != null || phase != null || action != null || step != null || failedStep != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static IndexLifecycleExplainResponse randomManagedIndexExplainResponse()
}

public void testInvalidStepDetails() {
final int numNull = randomIntBetween(1, 6);
final int numNull = randomIntBetween(1, 3);
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () ->
IndexLifecycleExplainResponse.newManagedIndexResponse(randomAlphaOfLength(10),
randomAlphaOfLength(10),
Expand All @@ -69,9 +69,9 @@ public void testInvalidStepDetails() {
(numNull == 2) ? null : randomAlphaOfLength(10),
(numNull == 3) ? null : randomAlphaOfLength(10),
randomBoolean() ? null : randomAlphaOfLength(10),
(numNull == 4) ? null : randomNonNegativeLong(),
(numNull == 5) ? null : randomNonNegativeLong(),
(numNull == 6) ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : randomNonNegativeLong(),
randomBoolean() ? null : new BytesArray(new RandomStepInfo(() -> randomAlphaOfLength(10)).toString()),
randomBoolean() ? null : PhaseExecutionInfoTests.randomPhaseExecutionInfo("")));
assertThat(exception.getMessage(), startsWith("managed index response must have complete step details"));
Expand Down Expand Up @@ -109,7 +109,7 @@ protected IndexLifecycleExplainResponse mutateInstance(IndexLifecycleExplainResp
BytesReference stepInfo = instance.getStepInfo();
PhaseExecutionInfo phaseExecutionInfo = instance.getPhaseExecutionInfo();
if (managed) {
switch (between(0, 7)) {
switch (between(0, 10)) {
case 0:
index = index + randomAlphaOfLengthBetween(1, 5);
break;
Expand All @@ -120,11 +120,17 @@ protected IndexLifecycleExplainResponse mutateInstance(IndexLifecycleExplainResp
phase = randomAlphaOfLengthBetween(1, 5);
action = randomAlphaOfLengthBetween(1, 5);
step = randomAlphaOfLengthBetween(1, 5);
break;
case 3:
phaseTime = randomValueOtherThan(phaseTime, () -> randomLongBetween(0, 100000));
break;
case 4:
actionTime = randomValueOtherThan(actionTime, () -> randomLongBetween(0, 100000));
break;
case 5:
stepTime = randomValueOtherThan(stepTime, () -> randomLongBetween(0, 100000));
break;
case 3:
case 6:
if (Strings.hasLength(failedStep) == false) {
failedStep = randomAlphaOfLength(10);
} else if (randomBoolean()) {
Expand All @@ -133,10 +139,10 @@ protected IndexLifecycleExplainResponse mutateInstance(IndexLifecycleExplainResp
failedStep = null;
}
break;
case 4:
case 7:
policyTime = randomValueOtherThan(policyTime, () -> randomLongBetween(0, 100000));
break;
case 5:
case 8:
if (Strings.hasLength(stepInfo) == false) {
stepInfo = new BytesArray(randomByteArrayOfLength(100));
} else if (randomBoolean()) {
Expand All @@ -146,10 +152,10 @@ protected IndexLifecycleExplainResponse mutateInstance(IndexLifecycleExplainResp
stepInfo = null;
}
break;
case 6:
case 9:
phaseExecutionInfo = randomValueOtherThan(phaseExecutionInfo, () -> PhaseExecutionInfoTests.randomPhaseExecutionInfo(""));
break;
case 7:
case 10:
return IndexLifecycleExplainResponse.newUnmanagedIndexResponse(index);
default:
throw new AssertionError("Illegal randomisation branch");
Expand Down