use of com.yahoo.vespa.config.server.tenant.Tenants in project vespa by vespa-engine.
the class ApplicationRepositoryTest method setup.
@Before
public void setup() {
Curator curator = new MockCurator();
Tenants tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).build());
tenants.addTenant(tenantName);
tenant = tenants.getTenant(tenantName);
Provisioner provisioner = new SessionHandlerTest.MockProvisioner();
applicationRepository = new ApplicationRepository(tenants, provisioner, clock);
timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(60));
}
use of com.yahoo.vespa.config.server.tenant.Tenants in project vespa by vespa-engine.
the class ApplicationHandlerTest method testDelete.
@Test
public void testDelete() throws Exception {
Clock clock = Clock.systemUTC();
ApplicationId defaultId = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
assertApplicationExists(mytenantName, null, Zone.defaultZone());
long sessionId = 1;
{
// This block is a real test of the interplay of (most of) the components of the config server
// TODO: Extract it to ApplicationRepositoryTest, rewrite to bypass the HTTP layer and extend
// as login is moved from the HTTP layer into ApplicationRepository
Tenants tenants = addApplication(defaultId, sessionId);
ApplicationHandler handler = createApplicationHandler(tenants);
Tenant mytenant = tenants.getTenant(defaultId.tenant());
LocalSession applicationData = mytenant.getLocalSessionRepo().getSession(sessionId);
assertNotNull(applicationData);
assertNotNull(applicationData.getApplicationId());
assertFalse(provisioner.removed);
deleteAndAssertOKResponse(handler, mytenant, defaultId);
assertTrue(provisioner.removed);
assertThat(provisioner.lastApplicationId.tenant(), is(mytenantName));
assertThat(provisioner.lastApplicationId, is(defaultId));
assertNull(mytenant.getLocalSessionRepo().getSession(sessionId));
assertNull(mytenant.getRemoteSessionRepo().getSession(sessionId));
}
sessionId++;
{
addMockApplication(tenants.getTenant(mytenantName), defaultId, sessionId, clock);
deleteAndAssertOKResponseMocked(defaultId, true);
ApplicationId fooId = new ApplicationId.Builder().tenant(mytenantName).applicationName("foo").instanceName("quux").build();
sessionId++;
addMockApplication(tenants.getTenant(mytenantName), fooId, sessionId, clock);
addMockApplication(tenants.getTenant(foobar), fooId, sessionId, clock);
assertApplicationExists(mytenantName, fooId, Zone.defaultZone());
assertApplicationExists(foobar, fooId, Zone.defaultZone());
deleteAndAssertOKResponseMocked(fooId, true);
assertThat(provisioner.lastApplicationId.tenant(), is(mytenantName));
assertThat(provisioner.lastApplicationId, is(fooId));
assertApplicationExists(mytenantName, null, Zone.defaultZone());
assertApplicationExists(foobar, fooId, Zone.defaultZone());
}
sessionId++;
{
ApplicationId baliId = new ApplicationId.Builder().tenant(mytenantName).applicationName("bali").instanceName("quux").build();
addMockApplication(tenants.getTenant(mytenantName), baliId, sessionId, clock);
deleteAndAssertOKResponseMocked(baliId, true);
assertApplicationExists(mytenantName, null, Zone.defaultZone());
}
}
use of com.yahoo.vespa.config.server.tenant.Tenants 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.vespa.config.server.tenant.Tenants in project vespa by vespa-engine.
the class ListApplicationsHandlerTest method setup.
@Before
public void setup() throws Exception {
TestTenantBuilder testBuilder = new TestTenantBuilder();
TenantName mytenant = TenantName.from("mytenant");
TenantName foobar = TenantName.from("foobar");
testBuilder.createTenant(mytenant);
testBuilder.createTenant(foobar);
applicationRepo = testBuilder.tenants().get(mytenant).getApplicationRepo();
applicationRepo2 = testBuilder.tenants().get(foobar).getApplicationRepo();
Tenants tenants = testBuilder.createTenants();
handler = new ListApplicationsHandler(ListApplicationsHandler.testOnlyContext(), tenants, new Zone(Environment.dev, RegionName.from("us-east")));
}
use of com.yahoo.vespa.config.server.tenant.Tenants in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method setUp.
@Before
public void setUp() throws Exception {
mockRequestHandler = new MockRequestHandler();
mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>() {
{
add(new ConfigKey<>("bar", "conf/id", "foo"));
}
});
TestTenantBuilder tb = new TestTenantBuilder();
tb.createTenant(TenantName.from("mytenant")).withRequestHandler(mockRequestHandler).build();
Tenants tenants = tb.createTenants();
handler = new HttpListConfigsHandler(HttpListConfigsHandler.testOnlyContext(), tenants, Zone.defaultZone());
namedHandler = new HttpListNamedConfigsHandler(HttpListConfigsHandler.testOnlyContext(), tenants, Zone.defaultZone());
}
Aggregations