Search in sources :

Example 71 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionContentHandlerTest method assertMkdir.

private void assertMkdir(String path) throws IOException {
    HttpResponse response = doRequest(HttpRequest.Method.PUT, path);
    assertNotNull(response);
    assertThat(response.getStatus(), is(Response.Status.OK));
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"prepared\":\"http://foo:1337" + pathPrefix + "1/prepared\"}"));
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse)

Example 72 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionContentHandlerTest method require_that_file_write_without_body_is_illegal.

@Test
public void require_that_file_write_without_body_is_illegal() throws IOException {
    HttpResponse response = doRequest(HttpRequest.Method.PUT, "/foobio.txt");
    assertNotNull(response);
    assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 73 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_that_tenant_is_in_response.

@Test
public void require_that_tenant_is_in_response() throws Exception {
    MockSession session = new MockSession(1, null);
    localRepo.addSession(session);
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertNotNull(response);
    assertThat(response.getStatus(), is(OK));
    assertThat(session.getStatus(), is(Session.Status.PREPARE));
    assertResponseContains(response, tenantMessage);
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 74 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_get_response_activate_url_on_ok.

@Test
public void require_get_response_activate_url_on_ok() throws Exception {
    MockSession session = new MockSession(1, null);
    localRepo.addSession(session);
    SessionHandler sessHandler = createHandler(fromLocalSessionRepo(localRepo, Clock.systemUTC()));
    sessHandler.handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    session.setStatus(Session.Status.PREPARE);
    zooKeeperClient.writeStatus(Session.Status.PREPARE);
    HttpResponse getResponse = sessHandler.handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.GET, Cmd.PREPARED, 1L));
    assertResponseContains(getResponse, "\"activate\":\"http://foo:1337" + pathPrefix + "1/active\",\"message\":\"Session 1" + preparedMessage);
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 75 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_that_config_change_actions_are_logged_if_existing.

@Test
public void require_that_config_change_actions_are_logged_if_existing() throws Exception {
    List<ServiceInfo> services = Collections.singletonList(new ServiceInfo("serviceName", "serviceType", null, ImmutableMap.of("clustername", "foo", "clustertype", "bar"), "configId", "hostName"));
    ConfigChangeActions actions = new ConfigChangeActions(Arrays.asList(new MockRestartAction("change", services), new MockRefeedAction("change-id", false, "other change", services, "test")));
    MockSession session = new MockSession(1, null, actions);
    localRepo.addSession(session);
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertResponseContains(response, "Change(s) between active and new application that require restart:\\nIn cluster 'foo' of type 'bar");
    assertResponseContains(response, "Change(s) between active and new application that may require re-feed:\\nchange-id: Consider removing data and re-feed document type 'test'");
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) HttpResponse(com.yahoo.container.jdisc.HttpResponse) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) MockRefeedAction(com.yahoo.vespa.config.server.configchange.MockRefeedAction) Test(org.junit.Test)

Aggregations

HttpResponse (com.yahoo.container.jdisc.HttpResponse)103 Test (org.junit.Test)75 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)33 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)24 HttpRequest (com.yahoo.container.jdisc.HttpRequest)16 CompressedApplicationInputStreamTest (com.yahoo.vespa.config.server.http.CompressedApplicationInputStreamTest)6 SessionTest (com.yahoo.vespa.config.server.session.SessionTest)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)5 InnerCNode (com.yahoo.config.codegen.InnerCNode)5 Slime (com.yahoo.slime.Slime)5 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)5 OutputStream (java.io.OutputStream)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ApplicationId (com.yahoo.config.provision.ApplicationId)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3