fix tests

This commit is contained in:
Tal Levy 2018-04-05 12:43:10 -07:00
parent e3e669067c
commit 1a2afac98b
3 changed files with 9 additions and 10 deletions

View File

@ -17,6 +17,8 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
import org.elasticsearch.xpack.core.XPackClientPlugin;
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.indexlifecycle.DeleteAction;
@ -54,13 +56,13 @@ public class IndexLifecycleInitialisationIT extends ESIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal));
settings.put(XPackSettings.INDEX_LIFECYCLE_ENABLED.getKey(), true);
settings.put(LifecycleSettings.LIFECYCLE_POLL_INTERVAL_SETTING.getKey(), "1s");
settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false);
settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false);
settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false);
settings.put(XPackSettings.LOGSTASH_ENABLED.getKey(), false);
settings.put(LifecycleSettings.LIFECYCLE_POLL_INTERVAL, "1s");
return settings.build();
}
@ -84,7 +86,7 @@ public class IndexLifecycleInitialisationIT extends ESIntegTestCase {
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class);
return Arrays.asList(LocalStateCompositeXPackPlugin.class, IndexLifecycle.class);
}
@Override

View File

@ -20,7 +20,6 @@ import org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleType;
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
import org.elasticsearch.xpack.core.indexlifecycle.MockActionTests;
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import org.elasticsearch.xpack.core.indexlifecycle.PhaseAfterStep;
@ -47,7 +46,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
private String lifecycleName;
@Override
protected LifecyclePolicy doParseInstance(XContentParser parser) throws IOException {
protected LifecyclePolicy doParseInstance(XContentParser parser) {
return LifecyclePolicy.parse(parser, lifecycleName);
}
@ -69,20 +68,18 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
@Override
protected LifecyclePolicy createTestInstance() {
return randomLifecyclePolicy(null);
lifecycleName = randomAlphaOfLength(5);
return randomLifecyclePolicy(lifecycleName);
}
static LifecyclePolicy randomLifecyclePolicy(@Nullable String lifecycleName) {
if (lifecycleName == null) {
lifecycleName = randomAlphaOfLengthBetween(1, 20);
}
int numberPhases = randomInt(5);
Map<String, Phase> phases = new HashMap<>(numberPhases);
for (int i = 0; i < numberPhases; i++) {
TimeValue after = TimeValue.parseTimeValue(randomTimeValue(0, 1000000000, "s", "m", "h", "d"), "test_after");
Map<String, LifecycleAction> actions = new HashMap<>();
if (randomBoolean()) {
MockAction action = MockActionTests.randomMockAction(null);
MockAction action = new MockAction();
actions.put(action.getWriteableName(), action);
}
String phaseName = randomAlphaOfLength(10);

View File

@ -76,7 +76,7 @@ public class PolicyStepsRegistryTests extends ESTestCase {
}
public void testUpdateFromNothingToSomethingToNothing() {
LifecyclePolicy newPolicy = randomLifecyclePolicy(null);
LifecyclePolicy newPolicy = randomLifecyclePolicy(randomAlphaOfLength(5));
List<Step> policySteps = newPolicy.toSteps(null, () -> 0L);
Map<String, LifecyclePolicy> policyMap = Collections.singletonMap(newPolicy.getName(), newPolicy);
MetaData metaData = MetaData.builder()