|
@@ -11,9 +11,12 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.xpack.autoscaling.AutoscalingIntegTestCase;
|
|
|
import org.elasticsearch.xpack.autoscaling.AutoscalingMetadata;
|
|
|
-import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
|
|
|
import org.elasticsearch.xpack.autoscaling.policy.AutoscalingPolicy;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.TreeMap;
|
|
|
+import java.util.TreeSet;
|
|
|
+
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.mutateAutoscalingDeciders;
|
|
|
import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingDeciders;
|
|
@@ -39,7 +42,7 @@ public class TransportPutAutoscalingPolicyActionIT extends AutoscalingIntegTestC
|
|
|
final AutoscalingPolicy policy = putRandomAutoscalingPolicy();
|
|
|
final AutoscalingPolicy updatedPolicy = new AutoscalingPolicy(
|
|
|
policy.name(),
|
|
|
- AutoscalingTestCase.randomRoles(),
|
|
|
+ new TreeSet<>(randomSubsetOf(List.of("data", "data_content", "data_hot", "data_warm", "data_cold"))),
|
|
|
mutateAutoscalingDeciders(policy.deciders())
|
|
|
);
|
|
|
putAutoscalingPolicy(updatedPolicy);
|
|
@@ -73,6 +76,19 @@ public class TransportPutAutoscalingPolicyActionIT extends AutoscalingIntegTestC
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public void testPutNoDeciderPolicy() {
|
|
|
+ String policyName = randomAlphaOfLength(8);
|
|
|
+ IllegalArgumentException exception = expectThrows(
|
|
|
+ IllegalArgumentException.class,
|
|
|
+ () -> putAutoscalingPolicy(new AutoscalingPolicy(policyName, new TreeSet<>(), new TreeMap<>()))
|
|
|
+ );
|
|
|
+
|
|
|
+ assertThat(
|
|
|
+ exception.getMessage(),
|
|
|
+ containsString("no default nor user configured deciders for policy [" + policyName + "] with roles [[]]")
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
private AutoscalingPolicy putRandomAutoscalingPolicy() {
|
|
|
final AutoscalingPolicy policy = randomAutoscalingPolicy();
|
|
|
putAutoscalingPolicy(policy);
|