use of com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest in project vespa by vespa-engine.
the class StateRestAPITest method retireAndExpectHttp200Response.
private String retireAndExpectHttp200Response(Optional<String> responseWait) throws Exception {
JSONObject json = new JSONObject().put("state", new JSONObject().put("current", new JSONObject().put("state", "retired").put("reason", "No reason"))).put("condition", "FORCE");
if (responseWait.isPresent()) {
json.put("response-wait", responseWait.get());
}
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
assertEquals(result.toString(true), 200, result.getHttpReturnCode());
assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
StringBuilder print = new StringBuilder();
result.printContent(print);
return print.toString();
}
use of com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest in project vespa by vespa-engine.
the class StateRestAPITest method testUnknownMaster.
@Test
public void testUnknownMaster() throws Exception {
setupDummyStateApi();
stateApi.induceException(new UnknownMasterException());
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2"));
assertEquals(result.toString(true), 503, result.getHttpReturnCode());
assertEquals(result.toString(true), "Service Unavailable", result.getHttpReturnCodeDescription());
assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
String expected = "{\"message\":\"No known master cluster controller currently exists.\"}";
assertEquals(expected, result.getContent().toString());
assertTrue(result.getHeader("Location") == null);
}
use of com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest in project vespa by vespa-engine.
the class StateRestAPITest method retireAndExpectHttp400Response.
private String retireAndExpectHttp400Response(String condition, String responseWait) throws Exception {
JSONObject json = new JSONObject().put("state", new JSONObject().put("current", new JSONObject().put("state", "retired").put("reason", "No reason"))).put("condition", condition).put("response-wait", responseWait);
HttpResult result = execute(new HttpRequest().setPath("/cluster/v2/foo/3").setPostContent(json));
assertEquals(result.toString(true), 400, result.getHttpReturnCode());
assertEquals(result.toString(true), "application/json", result.getHeader("Content-Type"));
StringBuilder print = new StringBuilder();
result.printContent(print);
return print.toString();
}
Aggregations