Search in sources :

Example 16 with ApplicationId

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());
    }
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) Clock(java.time.Clock) ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Example 17 with ApplicationId

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>");
}
Also used : StaticResponse(com.yahoo.vespa.config.server.http.StaticResponse) HttpResponse(com.yahoo.container.jdisc.HttpResponse) ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Example 18 with ApplicationId

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);
}
Also used : HttpProxy(com.yahoo.vespa.config.server.application.HttpProxy) ApplicationConvergenceChecker(com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) SimpleHttpFetcher(com.yahoo.vespa.config.server.http.SimpleHttpFetcher) ApplicationId(com.yahoo.config.provision.ApplicationId) LogServerLogGrabber(com.yahoo.vespa.config.server.application.LogServerLogGrabber) Ignore(org.junit.Ignore) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Example 19 with ApplicationId

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));
}
Also used : Zone(com.yahoo.config.provision.Zone) HttpResponse(com.yahoo.container.jdisc.HttpResponse) ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Example 20 with ApplicationId

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

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11