Search in sources :

Example 1 with LbServicesConfig

use of com.yahoo.cloud.config.LbServicesConfig in project vespa by vespa-engine.

the class SuperModelControllerTest method test_lb_config_simple.

@Test
public void test_lb_config_simple() {
    LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
    handler.getSuperModel().getConfig(lb);
    LbServicesConfig lbc = new LbServicesConfig(lb);
    assertThat(lbc.tenants().size(), is(1));
    assertThat(lbc.tenants("a").applications().size(), is(1));
    Applications app = lbc.tenants("a").applications("foo:prod:default:default");
    assertTrue(app.hosts().size() > 0);
}
Also used : Applications(com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) Test(org.junit.Test)

Example 2 with LbServicesConfig

use of com.yahoo.cloud.config.LbServicesConfig in project vespa by vespa-engine.

the class SuperModelConfigProvider method getConfig.

public ConfigPayload getConfig(ConfigKey<?> configKey) {
    // TODO: Override not applied, but not really necessary here
    if (configKey.equals(new ConfigKey<>(LbServicesConfig.class, configKey.getConfigId()))) {
        LbServicesConfig.Builder builder = new LbServicesConfig.Builder();
        getConfig(builder);
        return ConfigPayload.fromInstance(new LbServicesConfig(builder));
    } else if (configKey.equals(new ConfigKey<>(RoutingConfig.class, configKey.getConfigId()))) {
        RoutingConfig.Builder builder = new RoutingConfig.Builder();
        getConfig(builder);
        return ConfigPayload.fromInstance(new RoutingConfig(builder));
    } else {
        throw new ConfigurationRuntimeException(configKey + " is not valid when asking for config from SuperModel");
    }
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) RoutingConfig(com.yahoo.cloud.config.RoutingConfig)

Example 3 with LbServicesConfig

use of com.yahoo.cloud.config.LbServicesConfig in project vespa by vespa-engine.

the class LbServicesProducerTest method testConfigAliases.

@Test
public void testConfigAliases() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder());
    LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel);
    final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services("qrserver");
    assertThat(services.servicealiases().size(), is(1));
    assertThat(services.endpointaliases().size(), is(2));
    assertThat(services.servicealiases(0), is("service1"));
    assertThat(services.endpointaliases(0), is("foo1.bar1.com"));
    assertThat(services.endpointaliases(1), is("foo2.bar2.com"));
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) TenantName(com.yahoo.config.provision.TenantName) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with LbServicesConfig

use of com.yahoo.cloud.config.LbServicesConfig 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)

Example 5 with LbServicesConfig

use of com.yahoo.cloud.config.LbServicesConfig in project vespa by vespa-engine.

the class LbServicesProducerTest method testDeterministicGetConfig.

@Test
public void testDeterministicGetConfig() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder().rotations(rotations));
    LbServicesConfig last = null;
    for (int i = 0; i < 100; i++) {
        testModel = randomizeTenant(testModel, i);
        LbServicesConfig config = getLbServicesConfig(Zone.defaultZone(), testModel);
        if (last != null) {
            assertConfig(last, config);
        }
        last = config;
    }
}
Also used : TenantName(com.yahoo.config.provision.TenantName) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)6 Test (org.junit.Test)5 TenantName (com.yahoo.config.provision.TenantName)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Applications (com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications)1 RoutingConfig (com.yahoo.cloud.config.RoutingConfig)1 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)1 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1 SuperModel (com.yahoo.config.model.api.SuperModel)1 DeployState (com.yahoo.config.model.deploy.DeployState)1 RegionName (com.yahoo.config.provision.RegionName)1 Version (com.yahoo.config.provision.Version)1 Zone (com.yahoo.config.provision.Zone)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 SuperModelConfigProvider (com.yahoo.vespa.config.server.model.SuperModelConfigProvider)1 UncompressedConfigResponseFactory (com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 File (java.io.File)1