Search in sources :

Example 11 with HostName

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

the class ApplicationApiImplTest method verifyUpConditionWith.

private void verifyUpConditionWith(HostStatus hostStatus, ServiceStatus serviceStatus, boolean expectUp) {
    HostName hostName1 = modelUtils.createNode("host1", hostStatus);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-1", hostName1, serviceStatus)))));
    ApplicationApiImpl applicationApi = modelUtils.createApplicationApiImpl(applicationInstance, hostName1);
    List<HostName> upStorageNodes = expectUp ? Arrays.asList(hostName1) : new ArrayList<>();
    List<HostName> actualStorageNodes = applicationApi.getUpStorageNodesInGroupInClusterOrder().stream().map(storageNode -> storageNode.hostName()).collect(Collectors.toList());
    assertEquals(upStorageNodes, actualStorageNodes);
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) Arrays(java.util.Arrays) List(java.util.List) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) Test(org.junit.Test) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) Collectors(java.util.stream.Collectors) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 12 with HostName

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

the class ModelTestUtils method createNode.

HostName createNode(String name, HostStatus hostStatus) {
    HostName hostName = new HostName(name);
    hostStatusMap.put(hostName, hostStatus);
    when(statusRegistry.getHostStatus(hostName)).thenReturn(hostStatus);
    return hostName;
}
Also used : HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 13 with HostName

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

the class VespaModelUtilTest method testGetControllerHostName.

@Test
public void testGetControllerHostName() {
    HostName host = VespaModelUtil.getControllerHostName(application, CONTENT_CLUSTER_ID);
    assertThat(host).isEqualTo(controller0Host);
}
Also used : HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 14 with HostName

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

the class VespaModelUtilTest method testGetStorageNodeAtHostWithUnknownHost.

@Test
public void testGetStorageNodeAtHostWithUnknownHost() {
    Optional<ServiceInstance> service = VespaModelUtil.getStorageNodeAtHost(application, new HostName("storage-1"));
    assertFalse(service.isPresent());
}
Also used : ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 15 with HostName

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

the class HostedVespaPolicyTest method testGrantSuspension.

@Test
public void testGrantSuspension() throws HostStateChangeDeniedException {
    final HostedVespaClusterPolicy clusterPolicy = mock(HostedVespaClusterPolicy.class);
    final HostedVespaPolicy policy = new HostedVespaPolicy(clusterPolicy, clientFactory);
    final ApplicationApi applicationApi = mock(ApplicationApi.class);
    when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("tenant:app:default"));
    ClusterApi clusterApi1 = mock(ClusterApi.class);
    ClusterApi clusterApi2 = mock(ClusterApi.class);
    ClusterApi clusterApi3 = mock(ClusterApi.class);
    List<ClusterApi> clusterApis = Arrays.asList(clusterApi1, clusterApi2, clusterApi3);
    when(applicationApi.getClusters()).thenReturn(clusterApis);
    StorageNode storageNode1 = mock(StorageNode.class);
    HostName hostName1 = new HostName("storage-1");
    when(storageNode1.hostName()).thenReturn(hostName1);
    HostName hostName2 = new HostName("host-2");
    StorageNode storageNode3 = mock(StorageNode.class);
    HostName hostName3 = new HostName("storage-3");
    when(storageNode1.hostName()).thenReturn(hostName3);
    List<StorageNode> upStorageNodes = Arrays.asList(storageNode1, storageNode3);
    when(applicationApi.getUpStorageNodesInGroupInClusterOrder()).thenReturn(upStorageNodes);
    // setHostState
    List<HostName> noRemarksHostNames = Arrays.asList(hostName1, hostName2, hostName3);
    when(applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)).thenReturn(noRemarksHostNames);
    InOrder order = inOrder(applicationApi, clusterPolicy, storageNode1, storageNode3);
    policy.grantSuspensionRequest(applicationApi);
    order.verify(applicationApi).getClusters();
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi1);
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi2);
    order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi3);
    order.verify(applicationApi).getUpStorageNodesInGroupInClusterOrder();
    order.verify(storageNode1).setNodeState(ClusterControllerNodeState.MAINTENANCE);
    order.verify(storageNode3).setNodeState(ClusterControllerNodeState.MAINTENANCE);
    order.verify(applicationApi).getNodesInGroupWithStatus(HostStatus.NO_REMARKS);
    order.verify(applicationApi).setHostState(hostName1, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName2, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verify(applicationApi).setHostState(hostName3, HostStatus.ALLOWED_TO_BE_DOWN);
    order.verifyNoMoreInteractions();
}
Also used : ClusterApi(com.yahoo.vespa.orchestrator.model.ClusterApi) InOrder(org.mockito.InOrder) ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) StorageNode(com.yahoo.vespa.orchestrator.model.StorageNode) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Aggregations

HostName (com.yahoo.vespa.applicationmodel.HostName)46 Test (org.junit.Test)20 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)14 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)13 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)9 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)9 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)8 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)8 List (java.util.List)8 ApplicationId (com.yahoo.config.provision.ApplicationId)7 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)7 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)7 Collectors (java.util.stream.Collectors)7 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)6 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)6 TenantId (com.yahoo.vespa.applicationmodel.TenantId)6 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)5 OrchestrationException (com.yahoo.vespa.orchestrator.OrchestrationException)5 StorageNode (com.yahoo.vespa.orchestrator.model.StorageNode)5 IOException (java.io.IOException)5