Search in sources :

Example 36 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method testbasicVisit.

@Test
public void testbasicVisit() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_uri);
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString(visit_response_part1));
    assertThat(rest, containsString(visit_response_part2));
    assertThat(rest, containsString(visit_response_part3));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 37 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method visit_fieldset_parameter_is_propagated.

@Test
public void visit_fieldset_parameter_is_propagated() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?fieldSet=foo,baz", getFirstListenPort()));
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString("field set: 'foo,baz'"));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 38 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method fails_to_deallocate_node_with_hardware_failure.

@Test
public void fails_to_deallocate_node_with_hardware_failure() throws Exception {
    assertResponse(new Request("http://localhost:8080/nodes/v2/node", ("[" + asNodeJson("host12.yahoo.com", "default") + "]").getBytes(StandardCharsets.UTF_8), Request.Method.POST), "{\"message\":\"Added 1 nodes to the provisioned state\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/node/host12.yahoo.com", Utf8.toBytes("{\"hardwareFailureDescription\": \"memory_mcelog\"}"), Request.Method.PATCH), "{\"message\":\"Updated host12.yahoo.com\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/state/failed/host12.yahoo.com", new byte[0], Request.Method.PUT), "{\"message\":\"Moved host12.yahoo.com to failed\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/state/dirty/host12.yahoo.com", new byte[0], Request.Method.PUT), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Could not deallocate host12.yahoo.com: It has a hardware failure\"}");
}
Also used : Request(com.yahoo.application.container.handler.Request) Test(org.junit.Test)

Example 39 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method post_node_with_invalid_ip_address.

@Test
public void post_node_with_invalid_ip_address() throws Exception {
    Request req = new Request("http://localhost:8080/nodes/v2/node", ("[" + asNodeJson("host-with-ip.yahoo.com", "default", "foo") + "]").getBytes(StandardCharsets.UTF_8), Request.Method.POST);
    assertResponse(req, 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"A node must have at least one valid IP address: 'foo' is not an IP string literal.\"}");
}
Also used : Request(com.yahoo.application.container.handler.Request) Test(org.junit.Test)

Example 40 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method post_node_with_ip_address.

@Test
public void post_node_with_ip_address() throws Exception {
    assertResponse(new Request("http://localhost:8080/nodes/v2/node", ("[" + asNodeJson("ipv4-host.yahoo.com", "default", "127.0.0.1") + "]").getBytes(StandardCharsets.UTF_8), Request.Method.POST), "{\"message\":\"Added 1 nodes to the provisioned state\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/node", ("[" + asNodeJson("ipv6-host.yahoo.com", "default", "::1") + "]").getBytes(StandardCharsets.UTF_8), Request.Method.POST), "{\"message\":\"Added 1 nodes to the provisioned state\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/node", ("[" + asNodeJson("dual-stack-host.yahoo.com", "default", "127.0.0.1", "::1") + "]").getBytes(StandardCharsets.UTF_8), Request.Method.POST), "{\"message\":\"Added 1 nodes to the provisioned state\"}");
}
Also used : Request(com.yahoo.application.container.handler.Request) Test(org.junit.Test)

Aggregations

Request (com.yahoo.application.container.handler.Request)46 Test (org.junit.Test)44 StringContains.containsString (org.hamcrest.core.StringContains.containsString)17 HttpGet (org.apache.http.client.methods.HttpGet)14 Response (com.yahoo.application.container.handler.Response)7 StringEntity (org.apache.http.entity.StringEntity)7 HttpPut (org.apache.http.client.methods.HttpPut)4 HttpPost (org.apache.http.client.methods.HttpPost)3 Application (com.yahoo.vespa.hosted.controller.Application)2 ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)2 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)2 HttpResponse (org.apache.http.HttpResponse)2 HttpDelete (org.apache.http.client.methods.HttpDelete)2 MockHttpHandler (com.yahoo.application.container.handlers.MockHttpHandler)1 MockRenderer (com.yahoo.application.container.renderers.MockRenderer)1 Version (com.yahoo.component.Version)1 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)1 HttpRequest (com.yahoo.jdisc.http.HttpRequest)1 DiscFilterRequest (com.yahoo.jdisc.http.filter.DiscFilterRequest)1 ServletOrJdiscHttpRequest (com.yahoo.jdisc.http.servlet.ServletOrJdiscHttpRequest)1