Makes all step tests use `randomStepKey()`

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/AbstractStepTestCase.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/DeleteStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ErrorStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ForceMergeStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/InitializePolicyContextStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/PhaseAfterStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ReplicasAllocatedStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/RolloverStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/SegmentCountStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ShrinkSetAliasStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ShrinkStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ShrunkShardsAllocatedStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/ShrunkenIndexCheckStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/TerminalPolicyStepTests.java
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifec
ycle/UpdateSettingsStepTests.java
This commit is contained in:
Colin Goodheart-Smithe 2018-05-03 10:18:42 +01:00
parent b5ae7a1aeb
commit 61d88a8fdd
No known key found for this signature in database
GPG Key ID: F975E7BDD739B3C7
15 changed files with 41 additions and 40 deletions

View File

@ -24,7 +24,10 @@ public abstract class AbstractStepTestCase<T extends Step> extends ESTestCase {
}
public static StepKey randomStepKey() {
return new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
String randomPhase = randomAlphaOfLength(10);
String randomAction = randomAlphaOfLength(10);
String randomStepName = randomAlphaOfLength(10);
return new StepKey(randomPhase, randomAction, randomStepName);
}
public void testStepNameNotError() {

View File

@ -34,8 +34,8 @@ public class DeleteStepTests extends AbstractStepTestCase<DeleteStep> {
@Override
public DeleteStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
return new DeleteStep(stepKey, nextStepKey, client);
}

View File

@ -32,7 +32,7 @@ public class ErrorStepTests extends AbstractStepTestCase<ErrorStep> {
}
public void testInvalidStepKey() {
StepKey invalidKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey invalidKey = randomStepKey();
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> new ErrorStep(invalidKey));
assertEquals("An error step must have a step key whose step name is " + ErrorStep.NAME, exception.getMessage());
}

View File

@ -28,8 +28,8 @@ public class ForceMergeStepTests extends AbstractStepTestCase<ForceMergeStep> {
@Override
public ForceMergeStep createRandomInstance() {
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int maxNumSegments = randomIntBetween(1, 10);
return new ForceMergeStep(stepKey, nextStepKey, null, maxNumSegments);
@ -67,8 +67,8 @@ public class ForceMergeStepTests extends AbstractStepTestCase<ForceMergeStep> {
public void testPerformActionComplete() {
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int maxNumSegments = randomIntBetween(1, 10);
Client client = mock(Client.class);
AdminClient adminClient = mock(AdminClient.class);
@ -106,8 +106,8 @@ public class ForceMergeStepTests extends AbstractStepTestCase<ForceMergeStep> {
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
Exception exception = new RuntimeException("error");
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int maxNumSegments = randomIntBetween(1, 10);
Client client = mock(Client.class);
AdminClient adminClient = mock(AdminClient.class);

View File

@ -20,8 +20,8 @@ public class InitializePolicyContextStepTests extends AbstractStepTestCase<Initi
@Override
public InitializePolicyContextStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
return new InitializePolicyContextStep(stepKey, nextStepKey);
}

View File

@ -21,8 +21,8 @@ public class PhaseAfterStepTests extends AbstractStepTestCase<PhaseAfterStep> {
@Override
public PhaseAfterStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
TimeValue after = createRandomTimeValue();
return new PhaseAfterStep(null, after, stepKey, nextStepKey);
}

View File

@ -28,8 +28,8 @@ public class ReplicasAllocatedStepTests extends AbstractStepTestCase<ReplicasAll
@Override
public ReplicasAllocatedStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int numberReplicas = randomIntBetween(0, 100);
return new ReplicasAllocatedStep(stepKey, nextStepKey, numberReplicas);
}

View File

@ -46,9 +46,8 @@ public class RolloverStepTests extends AbstractStepTestCase<RolloverStep> {
@Override
public RolloverStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
String alias = randomAlphaOfLengthBetween(1, 20);
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
ByteSizeUnit maxSizeUnit = randomFrom(ByteSizeUnit.values());
ByteSizeValue maxSize = randomBoolean() ? null : new ByteSizeValue(randomNonNegativeLong() / maxSizeUnit.toBytes(1), maxSizeUnit);
Long maxDocs = randomBoolean() ? null : randomNonNegativeLong();

View File

@ -18,7 +18,6 @@ import org.elasticsearch.index.Index;
import org.elasticsearch.index.engine.Segment;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import org.mockito.Mockito;
import java.util.ArrayList;
@ -34,8 +33,8 @@ public class SegmentCountStepTests extends AbstractStepTestCase<SegmentCountStep
@Override
public SegmentCountStep createRandomInstance() {
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int maxNumSegments = randomIntBetween(1, 10);
boolean bestCompression = randomBoolean();
@ -101,8 +100,8 @@ public class SegmentCountStepTests extends AbstractStepTestCase<SegmentCountStep
Mockito.when(client.admin()).thenReturn(adminClient);
Mockito.when(adminClient.indices()).thenReturn(indicesClient);
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
boolean bestCompression = randomBoolean();
Mockito.doAnswer(invocationOnMock -> {
@ -156,8 +155,8 @@ public class SegmentCountStepTests extends AbstractStepTestCase<SegmentCountStep
Mockito.when(client.admin()).thenReturn(adminClient);
Mockito.when(adminClient.indices()).thenReturn(indicesClient);
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
boolean bestCompression = randomBoolean();
Mockito.doAnswer(invocationOnMock -> {
@ -194,8 +193,8 @@ public class SegmentCountStepTests extends AbstractStepTestCase<SegmentCountStep
Mockito.when(client.admin()).thenReturn(adminClient);
Mockito.when(adminClient.indices()).thenReturn(indicesClient);
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
Step.StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int maxNumSegments = randomIntBetween(3, 10);
boolean bestCompression = randomBoolean();

View File

@ -40,8 +40,8 @@ public class ShrinkSetAliasStepTests extends AbstractStepTestCase<ShrinkSetAlias
@Override
public ShrinkSetAliasStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
String shrunkIndexPrefix = randomAlphaOfLength(10);
return new ShrinkSetAliasStep(stepKey, nextStepKey, client, shrunkIndexPrefix);
}

View File

@ -42,8 +42,8 @@ public class ShrinkStepTests extends AbstractStepTestCase<ShrinkStep> {
@Override
public ShrinkStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int numberOfShards = randomIntBetween(1, 20);
String shrunkIndexPrefix = randomAlphaOfLength(10);
return new ShrinkStep(stepKey, nextStepKey, client, numberOfShards, shrunkIndexPrefix);

View File

@ -26,8 +26,8 @@ public class ShrunkShardsAllocatedStepTests extends AbstractStepTestCase<ShrunkS
@Override
public ShrunkShardsAllocatedStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
int numberOfShards = randomIntBetween(1, 10);
String shrunkIndexPrefix = randomAlphaOfLength(10);
return new ShrunkShardsAllocatedStep(stepKey, nextStepKey, numberOfShards, shrunkIndexPrefix);

View File

@ -18,8 +18,8 @@ public class ShrunkenIndexCheckStepTests extends AbstractStepTestCase<ShrunkenIn
@Override
public ShrunkenIndexCheckStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
String shrunkIndexPrefix = randomAlphaOfLength(10);
return new ShrunkenIndexCheckStep(stepKey, nextStepKey, shrunkIndexPrefix);
}

View File

@ -11,8 +11,8 @@ public class TerminalPolicyStepTests extends AbstractStepTestCase<TerminalPolicy
@Override
public TerminalPolicyStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
return new TerminalPolicyStep(stepKey, nextStepKey);
}

View File

@ -35,8 +35,8 @@ public class UpdateSettingsStepTests extends AbstractStepTestCase<UpdateSettings
@Override
public UpdateSettingsStep createRandomInstance() {
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
StepKey stepKey = randomStepKey();
StepKey nextStepKey = randomStepKey();
Settings settings = Settings.builder().put(randomAlphaOfLength(10), randomAlphaOfLength(10)).build();
return new UpdateSettingsStep(stepKey, nextStepKey, client, settings);