Migrate common autoscaling test code to base class
This commit moves some code repeated in a few autoscaling tests related to writeable and x-content registries to the autoscaling tests base class.
This commit is contained in:
parent
dd99e6d951
commit
79c72cd398
|
@ -10,7 +10,6 @@ import org.elasticsearch.cluster.Diff;
|
|||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractDiffableSerializationTestCase;
|
||||
|
@ -29,12 +28,12 @@ public class AutoscalingMetadataDiffableSerializationTests extends AbstractDiffa
|
|||
|
||||
@Override
|
||||
protected NamedWriteableRegistry getNamedWriteableRegistry() {
|
||||
return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables());
|
||||
return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NamedXContentRegistry xContentRegistry() {
|
||||
return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent());
|
||||
return AutoscalingTestCase.getAutoscalingXContentRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
package org.elasticsearch.xpack.autoscaling;
|
||||
|
||||
import org.elasticsearch.common.Randomness;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.autoscaling.decision.AlwaysAutoscalingDecider;
|
||||
import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecider;
|
||||
|
@ -118,4 +121,12 @@ public abstract class AutoscalingTestCase extends ESTestCase {
|
|||
return new AutoscalingMetadata(policies);
|
||||
}
|
||||
|
||||
public static NamedWriteableRegistry getAutoscalingNamedWriteableRegistry() {
|
||||
return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables());
|
||||
}
|
||||
|
||||
public static NamedXContentRegistry getAutoscalingXContentRegistry() {
|
||||
return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,11 +10,10 @@ import org.elasticsearch.cluster.AbstractDiffable;
|
|||
import org.elasticsearch.cluster.Diff;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractDiffableSerializationTestCase;
|
||||
import org.elasticsearch.xpack.autoscaling.Autoscaling;
|
||||
import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
|
||||
|
||||
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.mutateAutoscalingPolicy;
|
||||
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingPolicyOfName;
|
||||
|
@ -25,12 +24,12 @@ public class AutoscalingPolicyMetadataDiffableSerializationTests extends Abstrac
|
|||
|
||||
@Override
|
||||
protected NamedWriteableRegistry getNamedWriteableRegistry() {
|
||||
return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables());
|
||||
return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NamedXContentRegistry xContentRegistry() {
|
||||
return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent());
|
||||
return AutoscalingTestCase.getAutoscalingXContentRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,11 +8,10 @@ package org.elasticsearch.xpack.autoscaling.policy;
|
|||
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractSerializingTestCase;
|
||||
import org.elasticsearch.xpack.autoscaling.Autoscaling;
|
||||
import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
|
||||
|
||||
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.mutateAutoscalingPolicy;
|
||||
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingPolicyOfName;
|
||||
|
@ -23,12 +22,12 @@ public class AutoscalingPolicySerializingTests extends AbstractSerializingTestCa
|
|||
|
||||
@Override
|
||||
protected NamedWriteableRegistry getNamedWriteableRegistry() {
|
||||
return new NamedWriteableRegistry(new Autoscaling(Settings.EMPTY).getNamedWriteables());
|
||||
return AutoscalingTestCase.getAutoscalingNamedWriteableRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NamedXContentRegistry xContentRegistry() {
|
||||
return new NamedXContentRegistry(new Autoscaling(Settings.EMPTY).getNamedXContent());
|
||||
return AutoscalingTestCase.getAutoscalingXContentRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue