Search in sources :

Example 1 with ReadOnlyStatusRegistry

use of com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry in project vespa by vespa-engine.

the class OrchestratorImplTest method testGetHost.

@Test
public void testGetHost() throws Exception {
    ClusterControllerClientFactory clusterControllerClientFactory = mock(ClusterControllerClientFactory.class);
    StatusService statusService = mock(StatusService.class);
    InstanceLookupService lookupService = mock(InstanceLookupService.class);
    orchestrator = new OrchestratorImpl(clusterControllerClientFactory, statusService, new OrchestratorConfig(new OrchestratorConfig.Builder()), lookupService);
    HostName hostName = new HostName("host.yahoo.com");
    TenantId tenantId = new TenantId("tenant");
    ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId("applicationInstanceId");
    ApplicationInstanceReference reference = new ApplicationInstanceReference(tenantId, applicationInstanceId);
    ApplicationInstance applicationInstance = new ApplicationInstance(tenantId, applicationInstanceId, Stream.of(new ServiceCluster(new ClusterId("clusterId"), new ServiceType("serviceType"), Stream.of(new ServiceInstance(new ConfigId("configId1"), hostName, ServiceStatus.UP), new ServiceInstance(new ConfigId("configId2"), hostName, ServiceStatus.NOT_CHECKED)).collect(Collectors.toSet()))).collect(Collectors.toSet()));
    when(lookupService.findInstanceByHost(hostName)).thenReturn(Optional.of(applicationInstance));
    ReadOnlyStatusRegistry readOnlyStatusRegistry = mock(ReadOnlyStatusRegistry.class);
    when(statusService.forApplicationInstance(reference)).thenReturn(readOnlyStatusRegistry);
    when(readOnlyStatusRegistry.getHostStatus(hostName)).thenReturn(HostStatus.ALLOWED_TO_BE_DOWN);
    Host host = orchestrator.getHost(hostName);
    assertEquals(reference, host.getApplicationInstanceReference());
    assertEquals(hostName, host.getHostName());
    assertEquals(HostStatus.ALLOWED_TO_BE_DOWN, host.getHostStatus());
    assertEquals(2, host.getServiceInstances().size());
}
Also used : OrchestratorConfig(com.yahoo.vespa.orchestrator.config.OrchestratorConfig) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) StatusService(com.yahoo.vespa.orchestrator.status.StatusService) InMemoryStatusService(com.yahoo.vespa.orchestrator.status.InMemoryStatusService) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ReadOnlyStatusRegistry(com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry) ClusterControllerClientFactory(com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Aggregations

ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)1 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)1 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)1 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)1 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)1 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)1 TenantId (com.yahoo.vespa.applicationmodel.TenantId)1 OrchestratorConfig (com.yahoo.vespa.orchestrator.config.OrchestratorConfig)1 ClusterControllerClientFactory (com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory)1 InMemoryStatusService (com.yahoo.vespa.orchestrator.status.InMemoryStatusService)1 ReadOnlyStatusRegistry (com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry)1 StatusService (com.yahoo.vespa.orchestrator.status.StatusService)1 Test (org.junit.Test)1