Search in sources :

Example 1 with OrchestratorConfig

use of com.yahoo.vespa.orchestrator.config.OrchestratorConfig 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)

Example 2 with OrchestratorConfig

use of com.yahoo.vespa.orchestrator.config.OrchestratorConfig in project vespa by vespa-engine.

the class OrchestratorImplTest method setUp.

@Before
public void setUp() throws Exception {
    // Extract applications and hosts from dummy instance lookup service
    Iterator<ApplicationInstance> iterator = DummyInstanceLookupService.getApplications().iterator();
    ApplicationInstanceReference app1_ref = iterator.next().reference();
    app1 = OrchestratorUtil.toApplicationId(app1_ref);
    app1_host1 = DummyInstanceLookupService.getContentHosts(app1_ref).iterator().next();
    app2 = OrchestratorUtil.toApplicationId(iterator.next().reference());
    clustercontroller = new ClusterControllerClientFactoryMock();
    orchestrator = new OrchestratorImpl(clustercontroller, new InMemoryStatusService(), new OrchestratorConfig(new OrchestratorConfig.Builder()), new DummyInstanceLookupService());
    clustercontroller.setAllDummyNodesAsUp();
}
Also used : OrchestratorConfig(com.yahoo.vespa.orchestrator.config.OrchestratorConfig) ClusterControllerClientFactoryMock(com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactoryMock) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) InMemoryStatusService(com.yahoo.vespa.orchestrator.status.InMemoryStatusService) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Before(org.junit.Before)

Aggregations

ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)2 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)2 OrchestratorConfig (com.yahoo.vespa.orchestrator.config.OrchestratorConfig)2 InMemoryStatusService (com.yahoo.vespa.orchestrator.status.InMemoryStatusService)2 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)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 ClusterControllerClientFactory (com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory)1 ClusterControllerClientFactoryMock (com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactoryMock)1 ReadOnlyStatusRegistry (com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry)1 StatusService (com.yahoo.vespa.orchestrator.status.StatusService)1 Before (org.junit.Before)1 Test (org.junit.Test)1