diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2023-08-01 15:16:57 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2023-08-01 15:16:57 +0200 |
commit | 5c7ee97241489c69858ca813d164a3d4309409ab (patch) | |
tree | 213f8e5b34b61a04b89b75ae5ab8a69727f23e49 /orchestrator/src/test | |
parent | ad484e51eb9d86bb47288aa742ac06ad82f1a354 (diff) |
Use orchestration override if present
Diffstat (limited to 'orchestrator/src/test')
3 files changed, 30 insertions, 24 deletions
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java index 7ca1e1ebad6..ee62ffabd30 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java @@ -103,7 +103,7 @@ public class OrchestratorTest { fail(); } catch (HostStateChangeDeniedException e) { assertTrue(e.getMessage().contains("Changing the state of cfg2 would violate enough-services-up")); - assertTrue(e.getMessage().contains("[cfg1] are suspended.")); + assertTrue(e.getMessage().contains("[cfg1] is suspended.")); } // cfg1 is removed from the application @@ -115,7 +115,7 @@ public class OrchestratorTest { fail(); } catch (HostStateChangeDeniedException e) { assertTrue(e.getMessage().contains("Changing the state of cfg2 would violate enough-services-up")); - assertTrue(e.getMessage().contains("[1 missing config server] are down.")); + assertTrue(e.getMessage().contains("[1 missing config server] is down.")); } // cfg1 is reprovisioned, added to the node repo, and activated @@ -130,7 +130,7 @@ public class OrchestratorTest { fail(); } catch (HostStateChangeDeniedException e) { assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up")); - assertTrue(e.getMessage().contains("[cfg2] are suspended")); + assertTrue(e.getMessage().contains("[cfg2] is suspended")); } // etc (should be the same as for cfg1) diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java index b073f546cce..49978f824c4 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java @@ -33,7 +33,6 @@ import java.util.EnumSet; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.junit.Assert.assertEquals; @@ -95,7 +94,7 @@ public class ClusterApiImplTest { assertFalse(clusterApi.isStorageCluster()); assertEquals(" [host3, host4] are suspended. [ServiceInstance{configId=service-2, hostName=host2, " + "serviceStatus=ServiceStatusInfo{status=DOWN, since=Optional.empty, lastChecked=Optional.empty}}] " + - "are down.", + "is down.", clusterApi.downDescription()); assertEquals(60, clusterApi.percentageOfServicesDownOutsideGroup()); assertEquals(80, clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown()); @@ -178,8 +177,9 @@ public class ClusterApiImplTest { policy.verifyGroupGoingDownIsFine(clusterApi); fail(); } catch (HostStateChangeDeniedException e) { - assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " + - "servers are down or suspended already: [1 missing config server] are down.")); + assertEquals("Changing the state of cfg1 would violate enough-services-up: 1 config server is already down: " + + "[1 missing config server] is down.", + e.getMessage()); } } @@ -197,8 +197,9 @@ public class ClusterApiImplTest { policy.verifyGroupGoingDownIsFine(clusterApi); fail(); } catch (HostStateChangeDeniedException e) { - assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " + - "server hosts are down or suspended already: [1 missing config server host] are down.")); + assertEquals("Changing the state of cfg1 would violate enough-services-up: 1 config server host is already down: " + + "[1 missing config server host] is down.", + e.getMessage()); } } @@ -212,8 +213,9 @@ public class ClusterApiImplTest { policy.verifyGroupGoingDownIsFine(clusterApi); fail(); } catch (HostStateChangeDeniedException e) { - assertTrue(e.getMessage().contains("Changing the state of cfg1 would violate enough-services-up: 33% of the config " + - "servers are down or suspended already: [1 missing config server] are down.")); + assertEquals("Changing the state of cfg1 would violate enough-services-up: 1 config server is already down: " + + "[1 missing config server] is down.", + e.getMessage()); } } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java index eb70d809855..47bdcd4e68e 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/policy/HostedVespaClusterPolicyTest.java @@ -10,6 +10,7 @@ import com.yahoo.vespa.applicationmodel.ServiceType; import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.orchestrator.model.ApplicationApi; import com.yahoo.vespa.orchestrator.model.ClusterApi; +import com.yahoo.vespa.orchestrator.model.ClusterPolicyOverride; import com.yahoo.vespa.orchestrator.model.NodeGroup; import com.yahoo.vespa.orchestrator.model.VespaModelUtil; import org.junit.Before; @@ -36,6 +37,7 @@ public class HostedVespaClusterPolicyTest { @Before public void setUp() { when(clusterApi.getApplication()).thenReturn(applicationApi); + when(clusterApi.clusterPolicyOverride()).thenReturn(ClusterPolicyOverride.fromDeployedSize(3)); when(zone.system()).thenReturn(SystemName.main); NodeGroup nodeGroup = mock(NodeGroup.class); @@ -62,24 +64,24 @@ public class HostedVespaClusterPolicyTest { public void testSlobrokSuspensionLimit() { when(clusterApi.clusterId()).thenReturn(VespaModelUtil.ADMIN_CLUSTER_ID); when(clusterApi.serviceType()).thenReturn(ServiceType.SLOBROK); - assertEquals(ConcurrentSuspensionLimitForCluster.ONE_NODE, - policy.getConcurrentSuspensionLimit(clusterApi)); + assertEquals(SuspensionLimit.fromAllowedDown(1), + policy.getConcurrentSuspensionLimit(clusterApi)); } @Test public void testAdminSuspensionLimit() { when(clusterApi.clusterId()).thenReturn(VespaModelUtil.ADMIN_CLUSTER_ID); when(clusterApi.serviceType()).thenReturn(new ServiceType("non-slobrok-service-type")); - assertEquals(ConcurrentSuspensionLimitForCluster.ALL_NODES, - policy.getConcurrentSuspensionLimit(clusterApi)); + assertEquals(SuspensionLimit.fromAllowedDownRatio(1.0), + policy.getConcurrentSuspensionLimit(clusterApi)); } @Test public void testStorageSuspensionLimit() { when(clusterApi.serviceType()).thenReturn(ServiceType.STORAGE); when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id")); - assertEquals(ConcurrentSuspensionLimitForCluster.ALL_NODES, - policy.getConcurrentSuspensionLimit(clusterApi)); + assertEquals(SuspensionLimit.fromAllowedDownRatio(1.0), + policy.getConcurrentSuspensionLimit(clusterApi)); } @Test @@ -87,12 +89,12 @@ public class HostedVespaClusterPolicyTest { when(applicationApi.applicationId()).thenReturn(VespaModelUtil.TENANT_HOST_APPLICATION_ID); when(clusterApi.clusterId()).thenReturn(ClusterId.TENANT_HOST); when(clusterApi.serviceType()).thenReturn(ServiceType.HOST_ADMIN); - assertEquals(ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT, + assertEquals(SuspensionLimit.fromAllowedDownRatio(0.2), policy.getConcurrentSuspensionLimit(clusterApi)); when(zone.system()).thenReturn(SystemName.cd); - assertEquals(ConcurrentSuspensionLimitForCluster.FIFTY_PERCENT, + assertEquals(SuspensionLimit.fromAllowedDownRatio(0.5), policy.getConcurrentSuspensionLimit(clusterApi)); } @@ -101,7 +103,7 @@ public class HostedVespaClusterPolicyTest { when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("a:b:c")); when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id")); when(clusterApi.serviceType()).thenReturn(new ServiceType("some-service-type")); - assertEquals(ConcurrentSuspensionLimitForCluster.TEN_PERCENT, + assertEquals(SuspensionLimit.fromAllowedDownRatio(0.1), policy.getConcurrentSuspensionLimit(clusterApi)); } @@ -132,12 +134,14 @@ public class HostedVespaClusterPolicyTest { boolean expectSuccess) throws HostStateChangeDeniedException { when(clusterApi.noServicesOutsideGroupIsDown()).thenReturn(noServicesOutsideGroupIsDown); when(clusterApi.allServicesDown()).thenReturn(noServicesInGroupIsUp); + when(clusterApi.servicesDownIfGroupIsAllowedToBeDown()).thenReturn(20); when(clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown()).thenReturn(20); - doReturn(ConcurrentSuspensionLimitForCluster.TEN_PERCENT).when(policy).getConcurrentSuspensionLimit(clusterApi); + doReturn(SuspensionLimit.fromAllowedDownRatio(0.1)).when(policy).getConcurrentSuspensionLimit(clusterApi); when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("a:b:c")); when(clusterApi.serviceType()).thenReturn(new ServiceType("service-type")); when(clusterApi.serviceDescription(true)).thenReturn("services of {service-type,cluster-id}"); + when(clusterApi.servicesDownOutsideGroup()).thenReturn(5); when(clusterApi.percentageOfServicesDownOutsideGroup()).thenReturn(5); when(clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown()).thenReturn(percentageOfServicesDownIfGroupIsAllowedToBeDown); when(clusterApi.downDescription()).thenReturn(" Down description"); @@ -153,9 +157,9 @@ public class HostedVespaClusterPolicyTest { } } catch (HostStateChangeDeniedException e) { if (!expectSuccess) { - assertEquals("Changing the state of node-group would violate enough-services-up: The percentage of downed " + - "or suspended services of {service-type,cluster-id} would increase from 5% to 13% (limit is 10%): " + - "Down description", + assertEquals("Changing the state of node-group would violate enough-services-up: The percentage of " + + "services of {service-type,cluster-id} that are down would increase from 5% to 13% " + + "which is beyond the limit of 10%: Down description", e.getMessage()); assertEquals("enough-services-up", e.getConstraintName()); } |