Search in sources :

Example 11 with TenantName

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;
}
Also used : Path(com.yahoo.path.Path) TenantName(com.yahoo.config.provision.TenantName) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) GlobalComponentRegistry(com.yahoo.vespa.config.server.GlobalComponentRegistry) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionContext(com.yahoo.vespa.config.server.session.SessionContext) SuperModelGenerationCounter(com.yahoo.vespa.config.server.SuperModelGenerationCounter) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 12 with TenantName

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));
}
Also used : TenantName(com.yahoo.config.provision.TenantName) Test(org.junit.Test)

Example 13 with TenantName

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));
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) TenantName(com.yahoo.config.provision.TenantName) Test(org.junit.Test)

Example 14 with TenantName

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"));
}
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 15 with TenantName

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);
}
Also used : Zone(com.yahoo.config.provision.Zone) TenantName(com.yahoo.config.provision.TenantName) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

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