use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class ExampleModelTest method test.
@Test
public void test() {
List<String> contentNodes = Stream.of("host1", "host2").collect(Collectors.toList());
List<String> containerNodes = Stream.of("host3", "host4").collect(Collectors.toList());
ApplicationInfo application = ExampleModel.createApplication("tenant", "app").addServiceCluster("product-controllers", "container-clustercontroller.1", "container-clustercontroller", contentNodes).then().addServiceCluster("product", "searchnode.1", "searchnode", contentNodes).then().addServiceCluster("admin", "slobrok.1", "slobrok", containerNodes).then().addServiceCluster("default", "container.1", "container", containerNodes).then().build();
assertEquals("tenant.app", application.getApplicationId().toString());
Collection<HostInfo> hostInfos = application.getModel().getHosts();
assertEquals(containerNodes.size() + contentNodes.size(), hostInfos.size());
HostInfo host1 = hostInfos.stream().filter(hostInfo -> hostInfo.getHostname().equals("host1")).findAny().orElseThrow(() -> new RuntimeException());
ServiceInfo controller1 = host1.getServices().stream().filter(i -> i.getServiceType().equals("container-clustercontroller")).findAny().orElseThrow(() -> new RuntimeException());
assertEquals("container-clustercontroller", controller1.getServiceType());
assertEquals("configid/1", controller1.getConfigId());
HostInfo host4 = hostInfos.stream().filter(hostInfo -> hostInfo.getHostname().equals("host4")).findAny().orElseThrow(() -> new RuntimeException());
ServiceInfo slobrok2 = host4.getServices().stream().filter(i -> i.getServiceType().equals("slobrok")).findAny().orElseThrow(() -> new RuntimeException());
assertEquals("configid/2", slobrok2.getConfigId());
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class SuperModelListenerImplTest method sanityCheck.
@Test
public void sanityCheck() {
SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
ServiceMonitorMetrics metrics = mock(ServiceMonitorMetrics.class);
ModelGenerator modelGenerator = mock(ModelGenerator.class);
Zone zone = mock(Zone.class);
List<String> configServers = new ArrayList<>();
SuperModelListenerImpl listener = new SuperModelListenerImpl(slobrokMonitorManager, metrics, modelGenerator, zone, configServers);
SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
SuperModel superModel = mock(SuperModel.class);
when(superModelProvider.snapshot(listener)).thenReturn(superModel);
ApplicationInfo application1 = mock(ApplicationInfo.class);
ApplicationInfo application2 = mock(ApplicationInfo.class);
List<ApplicationInfo> applications = Stream.of(application1, application2).collect(Collectors.toList());
when(superModel.getAllApplicationInfos()).thenReturn(applications);
listener.start(superModelProvider);
verify(slobrokMonitorManager).applicationActivated(superModel, application1);
verify(slobrokMonitorManager).applicationActivated(superModel, application2);
ServiceModel serviceModel = listener.get();
verify(modelGenerator).toServiceModel(superModel, zone, configServers, slobrokMonitorManager);
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class InstanceValidatorTest method mockApplicationInfo.
private ApplicationInfo mockApplicationInfo(ApplicationId appId, int numHosts, List<ServiceInfo> serviceInfo) {
List<HostInfo> hosts = IntStream.range(0, numHosts).mapToObj(i -> new HostInfo("host-" + i + "." + appId.toShortString() + ".yahoo.com", serviceInfo)).collect(Collectors.toList());
Model model = mock(Model.class);
when(model.getHosts()).thenReturn(hosts);
return new ApplicationInfo(appId, 0, model);
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class RoutingProducerTest method createTestApplications.
private Map<ApplicationId, ApplicationInfo> createTestApplications(TenantName tenant, DeployState.Builder deploystateBuilder) throws IOException, SAXException {
Map<ApplicationId, ApplicationInfo> aMap = new LinkedHashMap<>();
ApplicationId fooApp = new ApplicationId.Builder().tenant(tenant).applicationName("foo").build();
ApplicationId barApp = new ApplicationId.Builder().tenant(tenant).applicationName("bar").build();
ApplicationId routingApp = new ApplicationId.Builder().tenant(tenant).applicationName(RoutingProducer.ROUTING_APPLICATION.value()).build();
aMap.put(fooApp, createApplication(fooApp, deploystateBuilder));
aMap.put(barApp, createApplication(barApp, deploystateBuilder));
aMap.put(routingApp, createApplication(routingApp, deploystateBuilder));
return aMap;
}
use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.
the class SuperModelControllerTest method test_lb_config_multiple_apps.
@Test
public void test_lb_config_multiple_apps() throws IOException, SAXException {
Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
models.put(TenantName.from("t1"), new LinkedHashMap<>());
models.put(TenantName.from("t2"), new LinkedHashMap<>());
File testApp1 = new File("src/test/resources/deploy/app");
File testApp2 = new File("src/test/resources/deploy/advancedapp");
File testApp3 = new File("src/test/resources/deploy/advancedapp");
// TODO must fix equals, hashCode on Tenant
Version vespaVersion = Version.fromIntValues(1, 2, 3);
models.get(TenantName.from("t1")).put(applicationId("mysimpleapp"), new ApplicationInfo(applicationId("mysimpleapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp1))));
models.get(TenantName.from("t1")).put(applicationId("myadvancedapp"), new ApplicationInfo(applicationId("myadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp2))));
models.get(TenantName.from("t2")).put(applicationId("minetooadvancedapp"), new ApplicationInfo(applicationId("minetooadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp3))));
SuperModel superModel = new SuperModel(models);
SuperModelController han = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
han.getSuperModel().getConfig(lb);
LbServicesConfig lbc = new LbServicesConfig(lb);
assertThat(lbc.tenants().size(), is(2));
assertThat(lbc.tenants("t1").applications().size(), is(2));
assertThat(lbc.tenants("t2").applications().size(), is(1));
assertThat(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size(), is(1));
assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
Aggregations