Search in sources :

Example 6 with ApplicationInfo

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());
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) HostInfo(com.yahoo.config.model.api.HostInfo) Test(org.junit.Test)

Example 7 with ApplicationInfo

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);
}
Also used : Zone(com.yahoo.config.provision.Zone) SuperModel(com.yahoo.config.model.api.SuperModel) ArrayList(java.util.ArrayList) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) Test(org.junit.Test)

Example 8 with ApplicationInfo

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);
}
Also used : IntStream(java.util.stream.IntStream) ApplicationId(com.yahoo.config.provision.ApplicationId) HostInfo(com.yahoo.config.model.api.HostInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) SignedIdentityDocument(com.yahoo.vespa.hosted.athenz.instanceproviderservice.identitydocument.SignedIdentityDocument) HashMap(java.util.HashMap) SERVICE_PROPERTIES_DOMAIN_KEY(com.yahoo.vespa.hosted.athenz.instanceproviderservice.instanceconfirmation.InstanceValidator.SERVICE_PROPERTIES_DOMAIN_KEY) Function(java.util.function.Function) IdentityDocument(com.yahoo.vespa.hosted.athenz.instanceproviderservice.identitydocument.IdentityDocument) SERVICE_PROPERTIES_SERVICE_KEY(com.yahoo.vespa.hosted.athenz.instanceproviderservice.instanceconfirmation.InstanceValidator.SERVICE_PROPERTIES_SERVICE_KEY) Map(java.util.Map) KeyProvider(com.yahoo.vespa.hosted.athenz.instanceproviderservice.KeyProvider) ProviderUniqueId(com.yahoo.vespa.hosted.athenz.instanceproviderservice.identitydocument.ProviderUniqueId) SuperModel(com.yahoo.config.model.api.SuperModel) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) AutoGeneratedKeyProvider(com.yahoo.vespa.hosted.athenz.instanceproviderservice.AutoGeneratedKeyProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Signature(java.security.Signature) Assert.assertTrue(org.junit.Assert.assertTrue) Utils(com.yahoo.vespa.hosted.athenz.instanceproviderservice.impl.Utils) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) PrivateKey(java.security.PrivateKey) Assert.assertFalse(org.junit.Assert.assertFalse) Collections(java.util.Collections) Model(com.yahoo.config.model.api.Model) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) Mockito.mock(org.mockito.Mockito.mock) SuperModel(com.yahoo.config.model.api.SuperModel) Model(com.yahoo.config.model.api.Model) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 9 with ApplicationInfo

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;
}
Also used : ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with ApplicationInfo

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"));
}
Also used : TenantName(com.yahoo.config.provision.TenantName) SuperModel(com.yahoo.config.model.api.SuperModel) SuperModelConfigProvider(com.yahoo.vespa.config.server.model.SuperModelConfigProvider) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) LinkedHashMap(java.util.LinkedHashMap) Version(com.yahoo.config.provision.Version) VespaModel(com.yahoo.vespa.model.VespaModel) UncompressedConfigResponseFactory(com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

Aggregations

ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)14 SuperModel (com.yahoo.config.model.api.SuperModel)7 ApplicationId (com.yahoo.config.provision.ApplicationId)7 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 Test (org.junit.Test)5 TenantName (com.yahoo.config.provision.TenantName)4 HashMap (java.util.HashMap)4 HostInfo (com.yahoo.config.model.api.HostInfo)3 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)3 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)3 SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)2 Zone (com.yahoo.config.provision.Zone)2 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)2 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)2 SuperModelConfigProvider (com.yahoo.vespa.config.server.model.SuperModelConfigProvider)2 UncompressedConfigResponseFactory (com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2