use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.
the class ApplicationHandlerTest method addApplication.
private static Tenants addApplication(ApplicationId applicationId, long sessionId) throws Exception {
// This method is a good illustration of the spaghetti wiring resulting from no design
// TODO: When this setup looks sane we have refactored sufficiently that there is a design
TenantName tenantName = applicationId.tenant();
Path tenantPath = Tenants.getTenantPath(tenantName);
Path sessionPath = tenantPath.append(Tenant.SESSIONS).append(String.valueOf(sessionId));
MockCurator curator = new MockCurator();
GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
// Creates the application path element in zk
Tenants tenants = new Tenants(componentRegistry);
tenants.addTenant(tenantName);
Tenant tenant = tenants.getTenant(tenantName);
tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
SessionZooKeeperClient sessionClient = new SessionZooKeeperClient(curator, sessionPath);
SessionContext context = new SessionContext(app, sessionClient, new File("/serverDb"), tenant.getApplicationRepo(), null, new SuperModelGenerationCounter(curator));
tenant.getLocalSessionRepo().addSession(new LocalSession(tenantName, sessionId, null, context));
// TODO: Instead, use ApplicationRepository to deploy the application
sessionClient.writeApplicationId(applicationId);
tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenantName, sessionId, componentRegistry, sessionClient, Clock.systemUTC()));
return tenants;
}
use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.
the class SuperModelRequestHandlerTest method test_super_model_remove.
@Test
public void test_super_model_remove() throws IOException, SAXException {
TenantName tenantA = TenantName.from("a");
TenantName tenantB = TenantName.from("b");
long gen = counter.increment();
controller.reloadConfig(tenantA, createApp(tenantA, "foo", 3l, 1));
controller.reloadConfig(tenantA, createApp(tenantA, "bar", 30l, 2));
controller.reloadConfig(tenantB, createApp(tenantB, "baz", 9l, 3));
assertThat(controller.getHandler().getGeneration(), is(gen));
assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(2));
assertThat(controller.getHandler().getSuperModel().applicationModels().get(TenantName.from("a")).size(), is(2));
controller.removeApplication(new ApplicationId.Builder().tenant("a").applicationName("unknown").build());
assertThat(controller.getHandler().getGeneration(), is(gen));
assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(2));
assertThat(controller.getHandler().getSuperModel().applicationModels().get(TenantName.from("a")).size(), is(2));
gen = counter.increment();
controller.removeApplication(new ApplicationId.Builder().tenant("a").applicationName("bar").build());
assertThat(controller.getHandler().getSuperModel().applicationModels().size(), is(2));
assertThat(controller.getHandler().getSuperModel().applicationModels().get(TenantName.from("a")).size(), is(1));
assertThat(controller.getHandler().getGeneration(), is(gen));
}
use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.
the class SuperModelRequestHandlerTest method test_super_model_master_generation.
@Test
public void test_super_model_master_generation() throws IOException, SAXException {
TenantName tenantA = TenantName.from("a");
long masterGen = 10;
ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().masterGeneration(masterGen));
manager = new SuperModelManager(configserverConfig, emptyNodeFlavors(), counter);
controller = new SuperModelRequestHandler(new TestConfigDefinitionRepo(), configserverConfig, manager);
long gen = counter.increment();
controller.reloadConfig(tenantA, createApp(tenantA, "foo", 3L, 1));
assertThat(controller.getHandler().getGeneration(), is(masterGen + gen));
}
use of com.yahoo.config.provision.TenantName 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"));
}
use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.
the class LbServicesProducerTest method createModelAndGetLbServicesConfig.
private LbServicesConfig createModelAndGetLbServicesConfig(RegionName regionName) throws IOException, SAXException {
final Zone zone = new Zone(Environment.prod, regionName);
Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder().zone(zone).properties(new DeployProperties.Builder().build()).zone(zone));
return getLbServicesConfig(new Zone(Environment.prod, regionName), testModel);
}
Aggregations