Search in sources :

Example 1 with ServiceCluster

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

the class ClusterApiImplTest method testStorageCluster.

@Test
public void testStorageCluster() {
    HostName hostName1 = new HostName("host1");
    HostName hostName2 = new HostName("host2");
    HostName hostName3 = new HostName("host3");
    ServiceCluster serviceCluster = modelUtils.createServiceCluster("cluster", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("storage-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("storage-2", hostName2, ServiceStatus.DOWN)));
    ClusterApiImpl clusterApi = new ClusterApiImpl(applicationApi, serviceCluster, new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), hostName1, hostName3), new HashMap<>(), modelUtils.getClusterControllerClientFactory());
    assertTrue(clusterApi.isStorageCluster());
    assertEquals(Optional.of(hostName1), clusterApi.storageNodeInGroup().map(storageNode -> storageNode.hostName()));
    assertEquals(Optional.of(hostName1), clusterApi.upStorageNodeInGroup().map(storageNode -> storageNode.hostName()));
}
Also used : Arrays(java.util.Arrays) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) HashMap(java.util.HashMap) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ArrayList(java.util.ArrayList) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 2 with ServiceCluster

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

the class ClusterApiImplTest method testServicesDownAndNotInGroup.

@Test
public void testServicesDownAndNotInGroup() {
    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)));
    ClusterApiImpl clusterApi = new ClusterApiImpl(applicationApi, serviceCluster, new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), hostName5), modelUtils.getHostStatusMap(), modelUtils.getClusterControllerClientFactory());
    assertEquals("{ clusterId=cluster, serviceType=service-type }", clusterApi.clusterInfo());
    assertFalse(clusterApi.isStorageCluster());
    assertEquals("[ServiceInstance{configId=service-2, hostName=host2, serviceStatus=DOWN}, " + "ServiceInstance{configId=service-3, hostName=host3, serviceStatus=UP}, " + "ServiceInstance{configId=service-4, hostName=host4, serviceStatus=DOWN}]", clusterApi.servicesDownAndNotInGroupDescription());
    assertEquals("[host3, host4]", clusterApi.nodesAllowedToBeDownNotInGroupDescription());
    assertEquals(60, clusterApi.percentageOfServicesDown());
    assertEquals(80, clusterApi.percentageOfServicesDownIfGroupIsAllowedToBeDown());
}
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 3 with ServiceCluster

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

the class VespaModelUtilTest method verifyNonControllerClusterIsNotRecognized.

@Test
public void verifyNonControllerClusterIsNotRecognized() {
    ServiceCluster cluster = createServiceCluster(new ServiceType("foo"));
    assertFalse(VespaModelUtil.isClusterController(cluster));
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) Test(org.junit.Test)

Example 4 with ServiceCluster

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

the class VespaModelUtilTest method verifyContentClusterIsRecognized.

@Test
public void verifyContentClusterIsRecognized() {
    ServiceCluster cluster = createServiceCluster(VespaModelUtil.DISTRIBUTOR_SERVICE_TYPE);
    assertTrue(VespaModelUtil.isContent(cluster));
    cluster = createServiceCluster(VespaModelUtil.STORAGENODE_SERVICE_TYPE);
    assertTrue(VespaModelUtil.isContent(cluster));
    cluster = createServiceCluster(VespaModelUtil.SEARCHNODE_SERVICE_TYPE);
    assertTrue(VespaModelUtil.isContent(cluster));
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Test(org.junit.Test)

Example 5 with ServiceCluster

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

the class VespaModelUtilTest method verifyNonStorageClusterIsNotRecognized.

@Test
public void verifyNonStorageClusterIsNotRecognized() {
    ServiceCluster cluster = createServiceCluster(new ServiceType("foo"));
    assertFalse(VespaModelUtil.isStorage(cluster));
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) Test(org.junit.Test)

Aggregations

ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)16 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)11 Test (org.junit.Test)11 HostName (com.yahoo.vespa.applicationmodel.HostName)8 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)7 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)5 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)5 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)5 TenantId (com.yahoo.vespa.applicationmodel.TenantId)5 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)4 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1