use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionPrepareHandlerTest method require_debug.
@Test
public void require_debug() throws Exception {
HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 9999L, "?debug=true"));
assertThat(response.getStatus(), is(NOT_FOUND));
assertThat(SessionHandlerTest.getRenderedString(response), containsString("NotFoundException"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionPrepareHandlerTest method require_that_config_change_actions_are_in_response.
@Test
public void require_that_config_change_actions_are_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));
assertResponseContains(response, "\"configChangeActions\":{\"restart\":[],\"refeed\":[]}");
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionPrepareHandlerTest method test_application_lock_failure.
@Test
public void test_application_lock_failure() throws InterruptedException, IOException {
String message = "Timed out after waiting PT1M to acquire lock '/provision/v1/locks/foo/bar/default'";
SessionThrowingException session = new SessionThrowingException(new ApplicationLockException(new UncheckedTimeoutException(message)));
localRepo.addSession(session);
HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
assertEquals(500, response.getStatus());
Slime data = getData(response);
assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.errorCodes.APPLICATION_LOCK_FAILURE.name()));
assertThat(data.get().field("message").asString(), is(message));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ApplicationConvergenceCheckerTest method converge.
@Test
public void converge() throws IOException, SAXException {
ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":3}}"));
HttpResponse serviceListResponse = checker.serviceListToCheckForConfigConvergence(application, URI.create("http://foo:234/serviceconverge"));
assertThat(serviceListResponse.getStatus(), is(200));
assertEquals("{\"services\":[" + "{\"host\":\"localhost\"," + "\"port\":1337," + "\"type\":\"container\"," + "\"url\":\"http://foo:234/serviceconverge/localhost:1337\"}]," + "\"debug\":{\"wantedGeneration\":3}," + "\"url\":\"http://foo:234/serviceconverge\"}", SessionHandlerTest.getRenderedString(serviceListResponse));
ServiceResponse serviceResponse = checker.serviceConvergenceCheck(application, "localhost:1337", URI.create("http://foo:234/serviceconverge/localhost:1337"));
assertThat(serviceResponse.getStatus(), is(200));
assertEquals("{" + "\"debug\":{" + "\"host\":\"localhost:1337\"," + "\"wantedGeneration\":3," + "\"currentGeneration\":3}," + "\"url\":\"http://foo:234/serviceconverge/localhost:1337\"," + "\"converged\":true}", SessionHandlerTest.getRenderedString(serviceResponse));
ServiceResponse hostMissingResponse = checker.serviceConvergenceCheck(application, "notPresent:1337", URI.create("http://foo:234/serviceconverge/notPresent:1337"));
assertThat(hostMissingResponse.getStatus(), is(410));
assertEquals("{\"debug\":{" + "\"host\":\"notPresent:1337\"," + "\"wantedGeneration\":3," + "\"problem\":\"Host:port (service) no longer part of application, refetch list of services.\"}," + "\"url\":\"http://foo:234/serviceconverge/notPresent:1337\"}", SessionHandlerTest.getRenderedString(hostMissingResponse));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_correct_error_response.
@Test
public void require_correct_error_response() throws IOException {
final String nonExistingConfigNameUri = "http://yahoo.com:8080/config/v1/nonexisting.config/myid";
final String nonExistingConfigUri = "http://yahoo.com:8080/config/v1/foo.bar/myid/nonexisting/id";
final String illegalConfigNameUri = "http://yahoo.com:8080/config/v1/foobar/myid";
HttpResponse response = handler.handle(HttpRequest.createTestRequest(nonExistingConfigNameUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config: nonexisting.config");
assertTrue(SessionHandlerTest.getRenderedString(response).contains("No such config:"));
response = handler.handle(HttpRequest.createTestRequest(nonExistingConfigUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config id: myid/nonexisting/id");
assertEquals(response.getContentType(), "application/json");
assertTrue(SessionHandlerTest.getRenderedString(response).contains("No such config id:"));
response = handler.handle(HttpRequest.createTestRequest(illegalConfigNameUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Illegal config, must be of form namespace.name.");
}
Aggregations