use of com.yahoo.vespa.orchestrator.status.StatusService 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());
}
Aggregations