HostedVespaClusterPolicy implements ClusterPolicy { ConcurrentSuspensionLimitForCluster getConcurrentSuspensionLimit(ClusterApi clusterApi) { if (clusterApi.isStorageCluster()) { return ConcurrentSuspensionLimitForCluster.ONE_NODE; } if (VespaModelUtil.CLUSTER_CONTROLLER_SERVICE_TYPE.equals(clusterApi.serviceType())) { return ConcurrentSuspensionLimitForCluster.FIFTY_PERCENT; } if (VespaModelUtil.METRICS_PROXY_SERVICE_TYPE.equals(clusterApi.serviceType())) { return ConcurrentSuspensionLimitForCluster.ALL_NODES; } if (VespaModelUtil.ADMIN_CLUSTER_ID.equals(clusterApi.clusterId())) { if (VespaModelUtil.SLOBROK_SERVICE_TYPE.equals(clusterApi.serviceType())) { return ConcurrentSuspensionLimitForCluster.ONE_NODE; } return ConcurrentSuspensionLimitForCluster.ALL_NODES; } if (clusterApi.getApplication().applicationId().equals(VespaModelUtil.TENANT_HOST_APPLICATION_ID)) { return ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT; } return ConcurrentSuspensionLimitForCluster.TEN_PERCENT; }  @Override SuspensionReasons verifyGroupGoingDownIsFine(ClusterApi clusterApi); @Override void verifyGroupGoingDownPermanentlyIsFine(ClusterApi clusterApi);  }
@Test public void testSlobrokSuspensionLimit() { when(clusterApi.clusterId()).thenReturn(VespaModelUtil.ADMIN_CLUSTER_ID); when(clusterApi.serviceType()).thenReturn(VespaModelUtil.SLOBROK_SERVICE_TYPE); assertEquals(ConcurrentSuspensionLimitForCluster.ONE_NODE, 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)); }
@Test public void testStorageSuspensionLimit() { when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id")); when(clusterApi.isStorageCluster()).thenReturn(true); assertEquals(ConcurrentSuspensionLimitForCluster.ONE_NODE, policy.getConcurrentSuspensionLimit(clusterApi)); }
@Test public void testTenantHostSuspensionLimit() { when(applicationApi.applicationId()).thenReturn(VespaModelUtil.TENANT_HOST_APPLICATION_ID); when(clusterApi.isStorageCluster()).thenReturn(false); assertEquals(ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT, policy.getConcurrentSuspensionLimit(clusterApi)); }
@Test public void testDefaultSuspensionLimit() { when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("a:b:c")); when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id")); when(clusterApi.isStorageCluster()).thenReturn(false); assertEquals(ConcurrentSuspensionLimitForCluster.TEN_PERCENT, policy.getConcurrentSuspensionLimit(clusterApi)); }