Browse Source

Fix validate decider roles test

This commit fixes an autoscaling test that is failing due to a
refactoring. Previously, the configured decider would not validate
against a policy specifying no roles, because the empty role marker was
explicitly not included in the list of roles that the decider
supported. Instead of using a marker, we now use an explicit method that
indicates whether or not the decider supports the empty role. The
production implementation of this decider does support the empty role,
but the configured decider in the test no longer maintained this
behavior since it was not overriding the new extension point to indicate
this. This commit addresses that by overriding this method in the
configured decider used in the test.
Jason Tedor 4 years ago
parent
commit
e484faa9cc

+ 7 - 0
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityServiceTests.java

@@ -317,10 +317,17 @@ public class AutoscalingCalculateCapacityServiceTests extends AutoscalingTestCas
     public void testValidateDeciderRoles() {
         Set<String> roles = randomRoles();
         AutoscalingCalculateCapacityService service = new AutoscalingCalculateCapacityService(Set.of(new FixedAutoscalingDeciderService() {
+
             @Override
             public List<DiscoveryNodeRole> roles() {
                 return roles.stream().map(DiscoveryNode::getRoleFromRoleName).collect(Collectors.toList());
             }
+
+            @Override
+            public boolean appliesToEmptyRoles() {
+                return false;
+            }
+
         }));
         SortedSet<String> badRoles = new TreeSet<>(randomRoles());
         badRoles.removeAll(roles);