Skip to content

Commit 6880e2a

Browse files
committed
[TEST] Fix RolloverActionTests.mutateInstance
In some cases it wasn't mutating and caused test failures
1 parent 4c4afef commit 6880e2a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverActionTests.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,21 @@ protected RolloverAction mutateInstance(RolloverAction instance) throws IOExcept
4848
TimeValue maxAge = instance.getMaxAge();
4949
Long maxDocs = instance.getMaxDocs();
5050
switch (between(0, 2)) {
51-
case 0:
52-
maxSize = randomValueOtherThan(maxSize, () -> {
53-
ByteSizeUnit maxSizeUnit = randomFrom(ByteSizeUnit.values());
54-
return new ByteSizeValue(randomNonNegativeLong() / maxSizeUnit.toBytes(1), maxSizeUnit);
55-
});
56-
break;
57-
case 1:
58-
maxAge = TimeValue.parseTimeValue(randomPositiveTimeValue(), "rollover_action_test");
59-
break;
60-
case 2:
61-
maxDocs = randomNonNegativeLong();
62-
break;
63-
default:
64-
throw new AssertionError("Illegal randomisation branch");
51+
case 0:
52+
maxSize = randomValueOtherThan(maxSize, () -> {
53+
ByteSizeUnit maxSizeUnit = randomFrom(ByteSizeUnit.values());
54+
return new ByteSizeValue(randomNonNegativeLong() / maxSizeUnit.toBytes(1), maxSizeUnit);
55+
});
56+
break;
57+
case 1:
58+
maxAge = randomValueOtherThan(maxAge,
59+
() -> TimeValue.parseTimeValue(randomPositiveTimeValue(), "rollover_action_test"));
60+
break;
61+
case 2:
62+
maxDocs = maxDocs == null ? randomNonNegativeLong() : maxDocs + 1;
63+
break;
64+
default:
65+
throw new AssertionError("Illegal randomisation branch");
6566
}
6667
return new RolloverAction(maxSize, maxAge, maxDocs);
6768
}

0 commit comments

Comments
 (0)