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;
}
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;
}
}
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));
}
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));
}
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();
}
}
Aggregations