Search in sources :

Example 41 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class LbServicesProducerTest method randomizeTenant.

private Map<TenantName, Map<ApplicationId, ApplicationInfo>> randomizeTenant(Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel, int seed) {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> randomizedTenants = new LinkedHashMap<>();
    List<TenantName> keys = new ArrayList<>(testModel.keySet());
    Collections.shuffle(keys, new Random(seed));
    for (TenantName key : keys) {
        randomizedTenants.put(key, randomizeApplications(testModel.get(key), randomizedTenants.size()));
    }
    return randomizedTenants;
}
Also used : Random(java.util.Random) TenantName(com.yahoo.config.provision.TenantName) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 42 with TenantName

use of com.yahoo.config.provision.TenantName 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)

Example 43 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class LbServicesProducerTest method testConfigAliasesWithRotations.

@Test
public void testConfigAliasesWithRotations() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder().rotations(rotations));
    RegionName regionName = RegionName.from("us-east-1");
    LbServicesConfig conf = getLbServicesConfig(new Zone(Environment.prod, regionName), testModel);
    final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:" + regionName.value() + ":default").hosts("foo.foo.yahoo.com").services("qrserver");
    assertThat(services.servicealiases().size(), is(1));
    assertThat(services.endpointaliases().size(), is(4));
    assertThat(services.servicealiases(0), is("service1"));
    assertThat(services.endpointaliases(0), is("foo1.bar1.com"));
    assertThat(services.endpointaliases(1), is("foo2.bar2.com"));
    assertThat(services.endpointaliases(2), is(rotation1));
    assertThat(services.endpointaliases(3), is(rotation2));
}
Also used : RegionName(com.yahoo.config.provision.RegionName) TenantName(com.yahoo.config.provision.TenantName) Zone(com.yahoo.config.provision.Zone) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 44 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class SuperModelRequestHandlerTest method test_super_model_reload.

@Test
public void test_super_model_reload() throws IOException, SAXException {
    TenantName tenantA = TenantName.from("a");
    assertNotNull(controller.getHandler());
    long gen = counter.increment();
    controller.reloadConfig(tenantA, createApp(tenantA, "foo", 3l, 1));
    assertNotNull(controller.getHandler());
    assertThat(controller.getHandler().getGeneration(), is(gen));
    controller.reloadConfig(tenantA, createApp(tenantA, "foo", 4l, 2));
    assertThat(controller.getHandler().getGeneration(), is(gen));
    // Test that a new app is used when there already exist an application with the same id
    ApplicationId appId = new ApplicationId.Builder().tenant(tenantA).applicationName("foo").build();
    assertThat(controller.getHandler().getSuperModel().applicationModels().get(tenantA).get(appId).getGeneration(), is(4l));
    gen = counter.increment();
    controller.reloadConfig(tenantA, createApp(tenantA, "bar", 2l, 3));
    assertThat(controller.getHandler().getGeneration(), is(gen));
}
Also used : TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 45 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class TenantsTestCase method testTenantWatching.

@Test
public void testTenantWatching() throws Exception {
    TenantName newTenant = TenantName.from("newTenant");
    List<TenantName> expectedTenants = Arrays.asList(TenantName.defaultName(), newTenant);
    try {
        tenants.addTenant(newTenant);
        // Poll for the watcher to pick up the tenant from zk, and add it
        int tries = 0;
        while (true) {
            if (tries > 5000)
                fail("Didn't react on watch");
            if (tenants.getAllTenantNames().containsAll(expectedTenants)) {
                break;
            }
            tries++;
            Thread.sleep(10);
        }
    } finally {
        assertTrue(tenants.getAllTenantNames().containsAll(expectedTenants));
        tenants.close();
    }
}
Also used : TenantName(com.yahoo.config.provision.TenantName) Test(org.junit.Test)

Aggregations

TenantName (com.yahoo.config.provision.TenantName)48 Test (org.junit.Test)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Map (java.util.Map)12 LinkedHashMap (java.util.LinkedHashMap)11 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)9 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)4 ApplicationName (com.yahoo.config.provision.ApplicationName)4 SuperModel (com.yahoo.config.model.api.SuperModel)3 Slime (com.yahoo.slime.Slime)3 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)3 PrepareParams (com.yahoo.vespa.config.server.session.PrepareParams)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 DeployState (com.yahoo.config.model.deploy.DeployState)2 Version (com.yahoo.config.provision.Version)2 Zone (com.yahoo.config.provision.Zone)2 ConfigKey (com.yahoo.vespa.config.ConfigKey)2