Search in sources :

Example 16 with ServiceType

use of com.yahoo.vespa.applicationmodel.ServiceType in project vespa by vespa-engine.

the class ClusterApiImplTest method testNoServices.

@Test
public void testNoServices() {
    HostName hostName1 = modelUtils.createNode("host1", HostStatus.NO_REMARKS);
    HostName hostName2 = modelUtils.createNode("host2", HostStatus.NO_REMARKS);
    HostName hostName3 = modelUtils.createNode("host3", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName hostName4 = modelUtils.createNode("host4", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName hostName5 = modelUtils.createNode("host5", HostStatus.NO_REMARKS);
    ServiceCluster serviceCluster = modelUtils.createServiceCluster("cluster", new ServiceType("service-type"), Arrays.asList(modelUtils.createServiceInstance("service-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("service-2", hostName2, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-3", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("service-4", hostName4, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-5", hostName5, ServiceStatus.UP)));
    verifyNoServices(serviceCluster, false, false, hostName1);
    verifyNoServices(serviceCluster, true, false, hostName2);
    verifyNoServices(serviceCluster, true, false, hostName3);
    verifyNoServices(serviceCluster, true, false, hostName4);
    verifyNoServices(serviceCluster, false, false, hostName5);
    verifyNoServices(serviceCluster, false, false, hostName1, hostName2);
    verifyNoServices(serviceCluster, true, false, hostName2, hostName3);
    verifyNoServices(serviceCluster, true, true, hostName2, hostName3, hostName4);
    verifyNoServices(serviceCluster, false, true, hostName1, hostName2, hostName3, hostName4);
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 17 with ServiceType

use of com.yahoo.vespa.applicationmodel.ServiceType in project vespa by vespa-engine.

the class HostedVespaClusterPolicyTest method verifyGroupGoingDownIsFine.

private void verifyGroupGoingDownIsFine(boolean noServicesOutsideGroupIsDown, boolean noServicesInGroupIsUp, int percentageOfServicesDownIfGroupIsAllowedToBeDown, boolean expectSuccess) {
    when(clusterApi.noServicesOutsideGroupIsDown()).thenReturn(noServicesOutsideGroupIsDown);
    when(clusterApi.noServicesInGroupIsUp()).thenReturn(noServicesInGroupIsUp);
    when(clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown()).thenReturn(20);
    doReturn(ConcurrentSuspensionLimitForCluster.TEN_PERCENT).when(policy).getConcurrentSuspensionLimit(clusterApi);
    when(clusterApi.serviceType()).thenReturn(new ServiceType("service-type"));
    when(clusterApi.percentageOfServicesDown()).thenReturn(5);
    when(clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown()).thenReturn(percentageOfServicesDownIfGroupIsAllowedToBeDown);
    when(clusterApi.servicesDownAndNotInGroupDescription()).thenReturn("services-down-and-not-in-group");
    when(clusterApi.nodesAllowedToBeDownNotInGroupDescription()).thenReturn("allowed-to-be-down");
    NodeGroup nodeGroup = mock(NodeGroup.class);
    when(clusterApi.getNodeGroup()).thenReturn(nodeGroup);
    when(nodeGroup.toCommaSeparatedString()).thenReturn("node-group");
    when(clusterApi.noServicesInGroupIsUp()).thenReturn(false);
    try {
        policy.verifyGroupGoingDownIsFine(clusterApi);
        if (!expectSuccess) {
            fail();
        }
    } catch (HostStateChangeDeniedException e) {
        if (!expectSuccess) {
            assertEquals("Changing the state of node-group would violate enough-services-up: " + "Suspension percentage for service type service-type would increase from " + "5% to 13%, over the limit of 10%. These instances may be down: " + "services-down-and-not-in-group and these hosts are allowed to be down: " + "allowed-to-be-down", e.getMessage());
            assertEquals("enough-services-up", e.getConstraintName());
        }
    }
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) NodeGroup(com.yahoo.vespa.orchestrator.model.NodeGroup)

Example 18 with ServiceType

use of com.yahoo.vespa.applicationmodel.ServiceType in project vespa by vespa-engine.

the class ApplicationApiImplTest method testGetUpStorageNodesInGroupInClusterOrder.

@Test
public void testGetUpStorageNodesInGroupInClusterOrder() {
    HostName hostName1 = new HostName("host1");
    HostName hostName2 = new HostName("host2");
    HostName hostName3 = new HostName("host3");
    HostName hostName4 = new HostName("host4");
    HostName hostName5 = new HostName("host5");
    HostName hostName6 = new HostName("host6");
    HostName hostName7 = new HostName("host7");
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-3", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-30", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-31", hostName2, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-10", hostName3, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-11", hostName4, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-4", new ServiceType("service-type-4"), Arrays.asList(modelUtils.createServiceInstance("config-id-40", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-41", hostName2, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-42", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-43", hostName5, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-20", hostName6, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-21", hostName7, ServiceStatus.UP)))));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName2), hostName2);
    // host3 is DOWN
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName3));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName4), hostName4);
    // not a storage cluster
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName5));
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName3), hostName1);
    // For the node group (host1, host4), they both have an up storage node (service instance)
    // with clusters (cluster-3, cluster-1) respectively, and so the order of the hosts are reversed
    // (host4, host1) when sorted by the clusters.
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5, hostName6), hostName4, hostName1);
    verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4, hostName5, hostName7), hostName4, hostName7, hostName1);
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 19 with ServiceType

use of com.yahoo.vespa.applicationmodel.ServiceType in project vespa by vespa-engine.

the class ApplicationApiImplTest method testGetStorageNodesAllowedToBeDownInGroupInReverseClusterOrder.

@Test
public void testGetStorageNodesAllowedToBeDownInGroupInReverseClusterOrder() {
    HostName allowedToBeDownHost1 = modelUtils.createNode("host1", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost2 = modelUtils.createNode("host2", HostStatus.NO_REMARKS);
    HostName allowedToBeDownHost3 = modelUtils.createNode("host3", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName allowedToBeDownHost4 = modelUtils.createNode("host4", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost5 = modelUtils.createNode("host5", HostStatus.ALLOWED_TO_BE_DOWN);
    HostName noRemarksHost6 = modelUtils.createNode("host6", HostStatus.NO_REMARKS);
    HostName allowedToBeDownHost7 = modelUtils.createNode("host7", HostStatus.ALLOWED_TO_BE_DOWN);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-4", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-40", allowedToBeDownHost1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-41", noRemarksHost2, ServiceStatus.DOWN))), modelUtils.createServiceCluster("cluster-1", new ServiceType("service-type-1"), Arrays.asList(modelUtils.createServiceInstance("config-id-10", allowedToBeDownHost1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-11", allowedToBeDownHost3, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-3", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-30", allowedToBeDownHost4, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-31", noRemarksHost5, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-20", noRemarksHost6, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-21", allowedToBeDownHost7, ServiceStatus.UP)))));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1), allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, noRemarksHost2));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost3));
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, noRemarksHost6), allowedToBeDownHost1);
    // allowedToBeDownHost4 is in cluster-3, while allowedToBeDownHost1 is in cluster-4, so allowedToBeDownHost4 should be ordered
    // before allowedToBeDownHost1.
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, noRemarksHost6, allowedToBeDownHost4), allowedToBeDownHost4, allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost1, allowedToBeDownHost4, allowedToBeDownHost7), allowedToBeDownHost7, allowedToBeDownHost4, allowedToBeDownHost1);
    verifyStorageNodesAllowedToBeDown(modelUtils.createApplicationApiImpl(applicationInstance, allowedToBeDownHost4, allowedToBeDownHost1, allowedToBeDownHost7), allowedToBeDownHost7, allowedToBeDownHost4, allowedToBeDownHost1);
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Aggregations

ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)19 Test (org.junit.Test)14 HostName (com.yahoo.vespa.applicationmodel.HostName)10 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)9 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)7 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)7 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)6 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)5 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ServiceClusterKey (com.yahoo.vespa.applicationmodel.ServiceClusterKey)2 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1 HostInfo (com.yahoo.config.model.api.HostInfo)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1