use of com.yahoo.config.provision.ApplicationId 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.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationHandlerTest method testClusterControllerStatus.
@Test
public void testClusterControllerStatus() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
String host = "foo.yahoo.com";
String url = toUrlPath(application, Zone.defaultZone(), true) + "/clustercontroller/" + host + "/status/v1/clusterName1";
when(mockHttpProxy.get(any(), eq(host), eq("container-clustercontroller"), eq("clustercontroller-status/v1/clusterName1"))).thenReturn(new StaticResponse(200, "text/html", "<html>...</html>"));
HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>...</html>");
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationHandlerTest method testFailingProvisioner.
@Test
@Ignore
public void testFailingProvisioner() throws Exception {
provisioner = new SessionHandlerTest.FailingMockProvisioner();
mockHandler = createMockApplicationHandler(provisioner, new ApplicationConvergenceChecker(stateApiFactory), new HttpProxy(new SimpleHttpFetcher()), new LogServerLogGrabber());
final ApplicationId applicationId = ApplicationId.defaultId();
addMockApplication(tenants.getTenant(mytenantName), applicationId, 1, Clock.systemUTC());
assertApplicationExists(mytenantName, applicationId, Zone.defaultZone());
provisioner.activated = true;
String url = "http://myhost:14000/application/v2/tenant/" + mytenantName + "/application/" + applicationId.application();
deleteAndAssertResponse(mockHandler, url, 500, null, "{\"message\":\"Cannot remove application\"}", com.yahoo.jdisc.http.HttpRequest.Method.DELETE);
assertApplicationExists(mytenantName, applicationId, Zone.defaultZone());
Assert.assertTrue(provisioner.activated);
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationHandlerTest method testFileDistributionStatus.
@Test
public void testFileDistributionStatus() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
Zone zone = Zone.defaultZone();
HttpResponse response = fileDistributionStatus(application, zone);
assertEquals(200, response.getStatus());
SessionHandlerTest.getRenderedString(response);
assertEquals("{\"hosts\":[{\"hostname\":\"mytesthost\",\"status\":\"UNKNOWN\",\"message\":\"error: Connection error(104)\",\"fileReferences\":[]}],\"status\":\"UNKNOWN\"}", SessionHandlerTest.getRenderedString(response));
// 404 for unknown application
ApplicationId unknown = new ApplicationId.Builder().applicationName("unknown").tenant(mytenantName).build();
HttpResponse responseForUnknown = fileDistributionStatus(unknown, zone);
assertEquals(404, responseForUnknown.getStatus());
assertEquals("{\"error-code\":\"NOT_FOUND\",\"message\":\"No such application id: mytenant.unknown\"}", SessionHandlerTest.getRenderedString(responseForUnknown));
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class SessionActiveHandlerTest method writeApplicationId.
private void writeApplicationId(SessionZooKeeperClient zkc, String applicationName) {
ApplicationId id = ApplicationId.from(tenant, ApplicationName.from(applicationName), InstanceName.defaultName());
zkc.writeApplicationId(id);
}
Aggregations