migrate step tests to extend AbstractStepTestCase
This commit is contained in:
parent
c1b00d0154
commit
20b6aaf6b6
|
@ -9,7 +9,7 @@ public class TerminalPolicyStep extends Step {
|
||||||
public static final StepKey KEY = new StepKey("completed", "completed", "completed");
|
public static final StepKey KEY = new StepKey("completed", "completed", "completed");
|
||||||
public static final TerminalPolicyStep INSTANCE = new TerminalPolicyStep(KEY, null);
|
public static final TerminalPolicyStep INSTANCE = new TerminalPolicyStep(KEY, null);
|
||||||
|
|
||||||
private TerminalPolicyStep(StepKey key, StepKey nextStepKey) {
|
TerminalPolicyStep(StepKey key, StepKey nextStepKey) {
|
||||||
super(key, nextStepKey);
|
super(key, nextStepKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
|
*/
|
||||||
|
package org.elasticsearch.xpack.core.indexlifecycle;
|
||||||
|
|
||||||
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||||
|
|
||||||
|
public abstract class AbstractStepTestCase<T extends Step> extends ESTestCase {
|
||||||
|
|
||||||
|
protected abstract T createRandomInstance();
|
||||||
|
protected abstract T mutateInstance(T instance);
|
||||||
|
protected abstract T copyInstance(T instance);
|
||||||
|
|
||||||
|
public void testHashcodeAndEquals() {
|
||||||
|
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(), this::copyInstance, this::mutateInstance);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,8 +17,6 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.IndicesAdminClient;
|
import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -26,14 +24,12 @@ import org.mockito.Mockito;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class AliasStepTests extends ESTestCase {
|
public class AliasStepTests extends AbstractStepTestCase<AliasStep> {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@ -42,12 +38,14 @@ public class AliasStepTests extends ESTestCase {
|
||||||
client = Mockito.mock(Client.class);
|
client = Mockito.mock(Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AliasStep createRandomInstance() {
|
public AliasStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
return new AliasStep(stepKey, nextStepKey, client);
|
return new AliasStep(stepKey, nextStepKey, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AliasStep mutateInstance(AliasStep instance) {
|
public AliasStep mutateInstance(AliasStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -61,18 +59,15 @@ public class AliasStepTests extends ESTestCase {
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Illegal randomisation branch");
|
throw new AssertionError("Illegal randomisation branch");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AliasStep(key, nextKey, instance.getClient());
|
return new AliasStep(key, nextKey, instance.getClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils
|
public AliasStep copyInstance(AliasStep instance) {
|
||||||
.checkEqualsAndHashCode(createRandomInstance(),
|
return new AliasStep(instance.getKey(), instance.getNextStepKey(), instance.getClient());
|
||||||
instance -> new AliasStep(instance.getKey(), instance.getNextStepKey(), instance.getClient()),
|
|
||||||
this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformAction() throws Exception {
|
public void testPerformAction() {
|
||||||
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
||||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
||||||
AliasStep step = createRandomInstance();
|
AliasStep step = createRandomInstance();
|
||||||
|
@ -124,7 +119,7 @@ public class AliasStepTests extends ESTestCase {
|
||||||
Mockito.verify(indicesClient, Mockito.only()).aliases(Mockito.any(), Mockito.any());
|
Mockito.verify(indicesClient, Mockito.only()).aliases(Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformActionFailure() throws Exception {
|
public void testPerformActionFailure() {
|
||||||
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
IndexMetaData indexMetaData = IndexMetaData.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT))
|
||||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
||||||
Exception exception = new RuntimeException();
|
Exception exception = new RuntimeException();
|
||||||
|
|
|
@ -25,14 +25,13 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.node.Node;
|
import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AllocationRoutedStepTests extends ESTestCase {
|
public class AllocationRoutedStepTests extends AbstractStepTestCase<AllocationRoutedStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public AllocationRoutedStep createRandomInstance() {
|
public AllocationRoutedStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -40,6 +39,7 @@ public class AllocationRoutedStepTests extends ESTestCase {
|
||||||
return new AllocationRoutedStep(stepKey, nextStepKey);
|
return new AllocationRoutedStep(stepKey, nextStepKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AllocationRoutedStep mutateInstance(AllocationRoutedStep instance) {
|
public AllocationRoutedStep mutateInstance(AllocationRoutedStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -58,9 +58,9 @@ public class AllocationRoutedStepTests extends ESTestCase {
|
||||||
return new AllocationRoutedStep(key, nextKey);
|
return new AllocationRoutedStep(key, nextKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
public AllocationRoutedStep copyInstance(AllocationRoutedStep instance) {
|
||||||
instance -> new AllocationRoutedStep(instance.getKey(), instance.getNextStepKey()), this::mutateInstance);
|
return new AllocationRoutedStep(instance.getKey(), instance.getNextStepKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConditionMet() {
|
public void testConditionMet() {
|
||||||
|
|
|
@ -15,8 +15,6 @@ import org.elasticsearch.client.AdminClient;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.IndicesAdminClient;
|
import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
@ -25,7 +23,7 @@ import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class DeleteStepTests extends ESTestCase {
|
public class DeleteStepTests extends AbstractStepTestCase<DeleteStep> {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@ -34,6 +32,7 @@ public class DeleteStepTests extends ESTestCase {
|
||||||
client = Mockito.mock(Client.class);
|
client = Mockito.mock(Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DeleteStep createRandomInstance() {
|
public DeleteStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -41,6 +40,7 @@ public class DeleteStepTests extends ESTestCase {
|
||||||
return new DeleteStep(stepKey, nextStepKey, client);
|
return new DeleteStep(stepKey, nextStepKey, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DeleteStep mutateInstance(DeleteStep instance) {
|
public DeleteStep mutateInstance(DeleteStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -59,9 +59,9 @@ public class DeleteStepTests extends ESTestCase {
|
||||||
return new DeleteStep(key, nextKey, instance.getClient());
|
return new DeleteStep(key, nextKey, instance.getClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
public DeleteStep copyInstance(DeleteStep instance) {
|
||||||
instance -> new DeleteStep(instance.getKey(), instance.getNextStepKey(), instance.getClient()), this::mutateInstance);
|
return new DeleteStep(instance.getKey(), instance.getNextStepKey(), instance.getClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexSurvives() {
|
public void testIndexSurvives() {
|
||||||
|
|
|
@ -20,9 +20,44 @@ import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.node.Node;
|
import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
public class EnoughShardsWaitStepTests extends ESTestCase {
|
public class EnoughShardsWaitStepTests extends AbstractStepTestCase<EnoughShardsWaitStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnoughShardsWaitStep createRandomInstance() {
|
||||||
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
int numberOfShards = randomIntBetween(1, 10);
|
||||||
|
return new EnoughShardsWaitStep(stepKey, nextStepKey, numberOfShards);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnoughShardsWaitStep mutateInstance(EnoughShardsWaitStep instance) {
|
||||||
|
StepKey key = instance.getKey();
|
||||||
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
int numberOfShards = instance.getNumberOfShards();
|
||||||
|
switch (between(0, 2)) {
|
||||||
|
case 0:
|
||||||
|
key = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
nextKey = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
numberOfShards = numberOfShards + 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new AssertionError("Illegal randomisation branch");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EnoughShardsWaitStep(key, nextKey, numberOfShards);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnoughShardsWaitStep copyInstance(EnoughShardsWaitStep instance) {
|
||||||
|
return new EnoughShardsWaitStep(instance.getKey(), instance.getNextStepKey(), instance.getNumberOfShards());
|
||||||
|
}
|
||||||
|
|
||||||
public void testConditionMet() {
|
public void testConditionMet() {
|
||||||
int numberOfShards = randomIntBetween(1, 10);
|
int numberOfShards = randomIntBetween(1, 10);
|
||||||
|
|
|
@ -16,8 +16,6 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.IndicesAdminClient;
|
import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
@ -26,8 +24,9 @@ import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class ForceMergeStepTests extends ESTestCase {
|
public class ForceMergeStepTests extends AbstractStepTestCase<ForceMergeStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public ForceMergeStep createRandomInstance() {
|
public ForceMergeStep createRandomInstance() {
|
||||||
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -36,6 +35,7 @@ public class ForceMergeStepTests extends ESTestCase {
|
||||||
return new ForceMergeStep(stepKey, nextStepKey, null, maxNumSegments);
|
return new ForceMergeStep(stepKey, nextStepKey, null, maxNumSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ForceMergeStep mutateInstance(ForceMergeStep instance) {
|
public ForceMergeStep mutateInstance(ForceMergeStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -55,14 +55,13 @@ public class ForceMergeStepTests extends ESTestCase {
|
||||||
throw new AssertionError("Illegal randomisation branch");
|
throw new AssertionError("Illegal randomisation branch");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ForceMergeStep(key, nextKey, null, maxNumSegments);
|
return new ForceMergeStep(key, nextKey, instance.getClient(), maxNumSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testHashcodeAndEquals() {
|
public ForceMergeStep copyInstance(ForceMergeStep instance) {
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
return new ForceMergeStep(instance.getKey(), instance.getNextStepKey(),
|
||||||
instance -> new ForceMergeStep(instance.getKey(), instance.getNextStepKey(),
|
instance.getClient(), instance.getMaxNumSegments());
|
||||||
null, instance.getMaxNumSegments()), this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformActionComplete() {
|
public void testPerformActionComplete() {
|
||||||
|
|
|
@ -12,14 +12,13 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class InitializePolicyContextStepTests extends ESTestCase {
|
public class InitializePolicyContextStepTests extends AbstractStepTestCase<InitializePolicyContextStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public InitializePolicyContextStep createRandomInstance() {
|
public InitializePolicyContextStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -27,6 +26,7 @@ public class InitializePolicyContextStepTests extends ESTestCase {
|
||||||
return new InitializePolicyContextStep(stepKey, nextStepKey);
|
return new InitializePolicyContextStep(stepKey, nextStepKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public InitializePolicyContextStep mutateInstance(InitializePolicyContextStep instance) {
|
public InitializePolicyContextStep mutateInstance(InitializePolicyContextStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -45,9 +45,9 @@ public class InitializePolicyContextStepTests extends ESTestCase {
|
||||||
return new InitializePolicyContextStep(key, nextKey);
|
return new InitializePolicyContextStep(key, nextKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
public InitializePolicyContextStep copyInstance(InitializePolicyContextStep instance) {
|
||||||
instance -> new InitializePolicyContextStep(instance.getKey(), instance.getNextStepKey()), this::mutateInstance);
|
return new InitializePolicyContextStep(instance.getKey(), instance.getNextStepKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddCreationDate() {
|
public void testAddCreationDate() {
|
||||||
|
|
|
@ -13,14 +13,13 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class PhaseAfterStepTests extends ESTestCase {
|
public class PhaseAfterStepTests extends AbstractStepTestCase<PhaseAfterStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public PhaseAfterStep createRandomInstance() {
|
public PhaseAfterStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -32,6 +31,7 @@ public class PhaseAfterStepTests extends ESTestCase {
|
||||||
return new TimeValue(randomLongBetween(1, 10000), randomFrom(TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS));
|
return new TimeValue(randomLongBetween(1, 10000), randomFrom(TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PhaseAfterStep mutateInstance(PhaseAfterStep instance) {
|
public PhaseAfterStep mutateInstance(PhaseAfterStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -54,9 +54,10 @@ public class PhaseAfterStepTests extends ESTestCase {
|
||||||
return new PhaseAfterStep(instance.getNowSupplier(), after, key, nextKey);
|
return new PhaseAfterStep(instance.getNowSupplier(), after, key, nextKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(), instance -> new PhaseAfterStep(instance.getNowSupplier(),
|
public PhaseAfterStep copyInstance(PhaseAfterStep instance) {
|
||||||
instance.getAfter(), instance.getKey(), instance.getNextStepKey()), this::mutateInstance);
|
return new PhaseAfterStep(instance.getNowSupplier(), instance.getAfter(),
|
||||||
|
instance.getKey(), instance.getNextStepKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConditionMet() {
|
public void testConditionMet() {
|
||||||
|
|
|
@ -22,12 +22,11 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.node.Node;
|
import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
public class ReplicasAllocatedStepTests extends ESTestCase {
|
public class ReplicasAllocatedStepTests extends AbstractStepTestCase<ReplicasAllocatedStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public ReplicasAllocatedStep createRandomInstance() {
|
public ReplicasAllocatedStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -35,6 +34,7 @@ public class ReplicasAllocatedStepTests extends ESTestCase {
|
||||||
return new ReplicasAllocatedStep(stepKey, nextStepKey, numberReplicas);
|
return new ReplicasAllocatedStep(stepKey, nextStepKey, numberReplicas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ReplicasAllocatedStep mutateInstance(ReplicasAllocatedStep instance) {
|
public ReplicasAllocatedStep mutateInstance(ReplicasAllocatedStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -56,10 +56,9 @@ public class ReplicasAllocatedStepTests extends ESTestCase {
|
||||||
return new ReplicasAllocatedStep(key, nextKey, numberReplicas);
|
return new ReplicasAllocatedStep(key, nextKey, numberReplicas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
public ReplicasAllocatedStep copyInstance(ReplicasAllocatedStep instance) {
|
||||||
instance -> new ReplicasAllocatedStep(instance.getKey(), instance.getNextStepKey(), instance.getNumberReplicas()),
|
return new ReplicasAllocatedStep(instance.getKey(), instance.getNextStepKey(), instance.getNumberReplicas());
|
||||||
this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConditionMet() {
|
public void testConditionMet() {
|
||||||
|
|
|
@ -22,8 +22,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -34,7 +32,7 @@ import org.mockito.stubbing.Answer;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class RolloverStepTests extends ESTestCase {
|
public class RolloverStepTests extends AbstractStepTestCase<RolloverStep> {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@ -43,6 +41,7 @@ public class RolloverStepTests extends ESTestCase {
|
||||||
client = Mockito.mock(Client.class);
|
client = Mockito.mock(Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public RolloverStep createRandomInstance() {
|
public RolloverStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -56,6 +55,7 @@ public class RolloverStepTests extends ESTestCase {
|
||||||
return new RolloverStep(stepKey, nextStepKey, client, alias, maxSize, maxAge, maxDocs);
|
return new RolloverStep(stepKey, nextStepKey, client, alias, maxSize, maxAge, maxDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public RolloverStep mutateInstance(RolloverStep instance) {
|
public RolloverStep mutateInstance(RolloverStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -93,12 +93,10 @@ public class RolloverStepTests extends ESTestCase {
|
||||||
return new RolloverStep(key, nextKey, instance.getClient(), alias, maxSize, maxAge, maxDocs);
|
return new RolloverStep(key, nextKey, instance.getClient(), alias, maxSize, maxAge, maxDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils
|
public RolloverStep copyInstance(RolloverStep instance) {
|
||||||
.checkEqualsAndHashCode(createRandomInstance(),
|
return new RolloverStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(),
|
||||||
instance -> new RolloverStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(),
|
instance.getAlias(), instance.getMaxSize(), instance.getMaxAge(), instance.getMaxDocs());
|
||||||
instance.getAlias(), instance.getMaxSize(), instance.getMaxAge(), instance.getMaxDocs()),
|
|
||||||
this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformAction() throws Exception {
|
public void testPerformAction() throws Exception {
|
||||||
|
|
|
@ -17,10 +17,8 @@ import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.engine.Segment;
|
import org.elasticsearch.index.engine.Segment;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -32,8 +30,9 @@ import java.util.Spliterator;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
|
||||||
public class SegmentCountStepTests extends ESTestCase {
|
public class SegmentCountStepTests extends AbstractStepTestCase<SegmentCountStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public SegmentCountStep createRandomInstance() {
|
public SegmentCountStep createRandomInstance() {
|
||||||
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
Step.StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -43,6 +42,7 @@ public class SegmentCountStepTests extends ESTestCase {
|
||||||
return new SegmentCountStep(stepKey, nextStepKey, null, maxNumSegments, bestCompression);
|
return new SegmentCountStep(stepKey, nextStepKey, null, maxNumSegments, bestCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SegmentCountStep mutateInstance(SegmentCountStep instance) {
|
public SegmentCountStep mutateInstance(SegmentCountStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -69,11 +69,10 @@ public class SegmentCountStepTests extends ESTestCase {
|
||||||
return new SegmentCountStep(key, nextKey, null, maxNumSegments, bestCompression);
|
return new SegmentCountStep(key, nextKey, null, maxNumSegments, bestCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void testHashcodeAndEquals() {
|
public SegmentCountStep copyInstance(SegmentCountStep instance) {
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(),
|
return new SegmentCountStep(instance.getKey(), instance.getNextStepKey(),
|
||||||
instance -> new SegmentCountStep(instance.getKey(), instance.getNextStepKey(),
|
null, instance.getMaxNumSegments(), instance.isBestCompression());
|
||||||
null, instance.getMaxNumSegments(), instance.isBestCompression()), this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsConditionMet() {
|
public void testIsConditionMet() {
|
||||||
|
|
|
@ -20,8 +20,6 @@ import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -33,7 +31,7 @@ import java.util.Collections;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class ShrinkStepTests extends ESTestCase {
|
public class ShrinkStepTests extends AbstractStepTestCase<ShrinkStep> {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@ -42,6 +40,7 @@ public class ShrinkStepTests extends ESTestCase {
|
||||||
client = Mockito.mock(Client.class);
|
client = Mockito.mock(Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ShrinkStep createRandomInstance() {
|
public ShrinkStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -49,6 +48,7 @@ public class ShrinkStepTests extends ESTestCase {
|
||||||
return new ShrinkStep(stepKey, nextStepKey, client, numberOfShards);
|
return new ShrinkStep(stepKey, nextStepKey, client, numberOfShards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ShrinkStep mutateInstance(ShrinkStep instance) {
|
public ShrinkStep mutateInstance(ShrinkStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -71,12 +71,9 @@ public class ShrinkStepTests extends ESTestCase {
|
||||||
return new ShrinkStep(key, nextKey, instance.getClient(), numberOfShards);
|
return new ShrinkStep(key, nextKey, instance.getClient(), numberOfShards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils
|
public ShrinkStep copyInstance(ShrinkStep instance) {
|
||||||
.checkEqualsAndHashCode(createRandomInstance(),
|
return new ShrinkStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(), instance.getNumberOfShards());
|
||||||
instance -> new ShrinkStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(),
|
|
||||||
instance.getNumberOfShards()),
|
|
||||||
this::mutateInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformAction() throws Exception {
|
public void testPerformAction() throws Exception {
|
||||||
|
|
|
@ -10,11 +10,36 @@ import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class ShrunkenIndexCheckStepTests extends ESTestCase {
|
public class ShrunkenIndexCheckStepTests extends AbstractStepTestCase<ShrunkenIndexCheckStep> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShrunkenIndexCheckStep createRandomInstance() {
|
||||||
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
return new ShrunkenIndexCheckStep(stepKey, nextStepKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShrunkenIndexCheckStep mutateInstance(ShrunkenIndexCheckStep instance) {
|
||||||
|
StepKey key = instance.getKey();
|
||||||
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
|
||||||
|
if (randomBoolean()) {
|
||||||
|
key = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
} else {
|
||||||
|
nextKey = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
}
|
||||||
|
return new ShrunkenIndexCheckStep(key, nextKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShrunkenIndexCheckStep copyInstance(ShrunkenIndexCheckStep instance) {
|
||||||
|
return new ShrunkenIndexCheckStep(instance.getKey(), instance.getNextStepKey());
|
||||||
|
}
|
||||||
|
|
||||||
public void testConditionMet() {
|
public void testConditionMet() {
|
||||||
String sourceIndex = randomAlphaOfLengthBetween(1, 10);
|
String sourceIndex = randomAlphaOfLengthBetween(1, 10);
|
||||||
|
|
|
@ -5,13 +5,37 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.core.indexlifecycle;
|
package org.elasticsearch.xpack.core.indexlifecycle;
|
||||||
|
|
||||||
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
public class TerminalPolicyStepTests extends AbstractStepTestCase<TerminalPolicyStep> {
|
||||||
|
|
||||||
public class TerminalPolicyStepTests extends ESTestCase {
|
@Override
|
||||||
|
public TerminalPolicyStep createRandomInstance() {
|
||||||
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
return new TerminalPolicyStep(stepKey, nextStepKey);
|
||||||
|
}
|
||||||
|
|
||||||
public void testKeys() {
|
@Override
|
||||||
|
public TerminalPolicyStep mutateInstance(TerminalPolicyStep instance) {
|
||||||
|
StepKey key = instance.getKey();
|
||||||
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
|
||||||
|
if (randomBoolean()) {
|
||||||
|
key = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
} else {
|
||||||
|
nextKey = new StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TerminalPolicyStep(key, nextKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TerminalPolicyStep copyInstance(TerminalPolicyStep instance) {
|
||||||
|
return new TerminalPolicyStep(instance.getKey(), instance.getNextStepKey());
|
||||||
|
}
|
||||||
|
public void testInstance() {
|
||||||
assertEquals(new Step.StepKey("completed", "completed", "completed"), TerminalPolicyStep.INSTANCE.getKey());
|
assertEquals(new Step.StepKey("completed", "completed", "completed"), TerminalPolicyStep.INSTANCE.getKey());
|
||||||
assertEquals(null, TerminalPolicyStep.INSTANCE.getNextStepKey());
|
assertNull(TerminalPolicyStep.INSTANCE.getNextStepKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.IndicesAdminClient;
|
import org.elasticsearch.client.IndicesAdminClient;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep.Listener;
|
||||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -26,7 +24,7 @@ import org.mockito.Mockito;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
public class UpdateSettingsStepTests extends ESTestCase {
|
public class UpdateSettingsStepTests extends AbstractStepTestCase<UpdateSettingsStep> {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@ -35,6 +33,7 @@ public class UpdateSettingsStepTests extends ESTestCase {
|
||||||
client = Mockito.mock(Client.class);
|
client = Mockito.mock(Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UpdateSettingsStep createRandomInstance() {
|
public UpdateSettingsStep createRandomInstance() {
|
||||||
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey stepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
StepKey nextStepKey = new StepKey(randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10));
|
||||||
|
@ -43,6 +42,7 @@ public class UpdateSettingsStepTests extends ESTestCase {
|
||||||
return new UpdateSettingsStep(stepKey, nextStepKey, client, settings);
|
return new UpdateSettingsStep(stepKey, nextStepKey, client, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UpdateSettingsStep mutateInstance(UpdateSettingsStep instance) {
|
public UpdateSettingsStep mutateInstance(UpdateSettingsStep instance) {
|
||||||
StepKey key = instance.getKey();
|
StepKey key = instance.getKey();
|
||||||
StepKey nextKey = instance.getNextStepKey();
|
StepKey nextKey = instance.getNextStepKey();
|
||||||
|
@ -65,9 +65,9 @@ public class UpdateSettingsStepTests extends ESTestCase {
|
||||||
return new UpdateSettingsStep(key, nextKey, client, settings);
|
return new UpdateSettingsStep(key, nextKey, client, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashcodeAndEquals() {
|
@Override
|
||||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createRandomInstance(), instance -> new UpdateSettingsStep(instance.getKey(),
|
public UpdateSettingsStep copyInstance(UpdateSettingsStep instance) {
|
||||||
instance.getNextStepKey(), instance.getClient(), instance.getSettings()), this::mutateInstance);
|
return new UpdateSettingsStep(instance.getKey(), instance.getNextStepKey(), instance.getClient(), instance.getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerformAction() {
|
public void testPerformAction() {
|
||||||
|
|
Loading…
Reference in New Issue