use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.
the class ConfigServerApplicationTest method toApplicationInstance.
@Test
public void toApplicationInstance() throws Exception {
ConfigServerApplication application = new ConfigServerApplication();
ApplicationInstance applicationInstance = application.toApplicationInstance(configServerList);
assertEquals(ConfigServerApplication.APPLICATION_INSTANCE_ID, applicationInstance.applicationInstanceId());
assertEquals(ConfigServerApplication.TENANT_ID, applicationInstance.tenantId());
assertEquals(ConfigServerApplication.TENANT_ID.toString() + ":" + ConfigServerApplication.APPLICATION_INSTANCE_ID, applicationInstance.reference().toString());
assertEquals(ConfigServerApplication.CLUSTER_ID, applicationInstance.serviceClusters().iterator().next().clusterId());
assertEquals(ServiceStatus.NOT_CHECKED, applicationInstance.serviceClusters().iterator().next().serviceInstances().iterator().next().serviceStatus());
assertTrue(configServerList.contains(applicationInstance.serviceClusters().iterator().next().serviceInstances().iterator().next().hostName().toString()));
}
use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.
the class ModelGeneratorTest method toApplicationModel.
@Test
public void toApplicationModel() throws Exception {
SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
ModelGenerator modelGenerator = new ModelGenerator();
Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
List<String> configServerHosts = Collections.emptyList();
SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
assertEquals(1, applicationInstances.size());
verifyOtherApplication(applicationInstances.values().iterator().next());
}
use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.
the class ModelGeneratorTest method toApplicationModelWithConfigServerApplication.
@Test
public void toApplicationModelWithConfigServerApplication() throws Exception {
SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
ModelGenerator modelGenerator = new ModelGenerator();
Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
List<String> configServerHosts = Stream.of("cfg1", "cfg2", "cfg3").collect(Collectors.toList());
SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
assertEquals(2, applicationInstances.size());
Iterator<Map.Entry<ApplicationInstanceReference, ApplicationInstance>> iterator = applicationInstances.entrySet().iterator();
ApplicationInstance applicationInstance1 = iterator.next().getValue();
ApplicationInstance applicationInstance2 = iterator.next().getValue();
if (applicationInstance1.applicationInstanceId().equals(ConfigServerApplication.APPLICATION_INSTANCE_ID)) {
verifyConfigServerApplication(applicationInstance1);
verifyOtherApplication(applicationInstance2);
} else {
verifyConfigServerApplication(applicationInstance2);
verifyOtherApplication(applicationInstance1);
}
}
use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.
the class ClusterControllerClientFactoryMock method setAllDummyNodesAsUp.
public void setAllDummyNodesAsUp() {
for (ApplicationInstance app : DummyInstanceLookupService.getApplications()) {
Set<HostName> hosts = DummyInstanceLookupService.getContentHosts(app.reference());
for (HostName host : hosts) {
ClusterId clusterName = VespaModelUtil.getContentClusterName(app, host);
int storageNodeIndex = VespaModelUtil.getStorageNodeIndex(app, host);
String globalMapKey = clusterName.s() + storageNodeIndex;
nodes.put(globalMapKey, ClusterControllerNodeState.UP);
}
}
}
use of com.yahoo.vespa.applicationmodel.ApplicationInstance in project vespa by vespa-engine.
the class ApplicationApiImplTest method testGetNodesInGroupWithStatus.
@Test
public void testGetNodesInGroupWithStatus() {
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);
ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-1", new ServiceType("service-type-1"), Arrays.asList(modelUtils.createServiceInstance("config-id-10", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-11", hostName2, ServiceStatus.UP))), modelUtils.createServiceCluster("cluster-2", new ServiceType("service-type-2"), Arrays.asList(modelUtils.createServiceInstance("config-id-20", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-21", hostName3, ServiceStatus.UP)))));
verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), Arrays.asList(hostName1), Arrays.asList());
verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName2), Arrays.asList(hostName1, hostName2), Arrays.asList());
verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName2, hostName3), Arrays.asList(hostName1, hostName2), Arrays.asList(hostName3));
verifyNodesInGroupWithoutRemarks(modelUtils.createApplicationApiImpl(applicationInstance, hostName3), Arrays.asList(), Arrays.asList(hostName3));
}
Aggregations