Search in sources :

Example 11 with Request

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

the class RestApiTest method testbasicRemove.

@Test
public void testbasicRemove() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + remove_test_uri);
    HttpDelete delete = new HttpDelete(request.getUri());
    assertThat(doRest(delete), is(remove_test_response));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) Request(com.yahoo.application.container.handler.Request) Test(org.junit.Test)

Example 12 with Request

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

the class RestApiTest method testCreateIfNonExistingUpdateInDocTrueButQueryParamsFalse.

@Test
public void testCreateIfNonExistingUpdateInDocTrueButQueryParamsFalse() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + update_test_create_if_non_existient_uri + "?create=false");
    HttpPut httpPut = new HttpPut(request.getUri());
    StringEntity entity = new StringEntity(update_test_create_if_non_existient_doc, ContentType.create("application/json"));
    httpPut.setEntity(entity);
    assertThat(doRest(httpPut), is(update_test_create_if_non_existing_response));
    assertThat(getLog(), not(containsString("CREATE IF NON EXISTENT IS TRUE")));
}
Also used : StringEntity(org.apache.http.entity.StringEntity) Request(com.yahoo.application.container.handler.Request) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 13 with Request

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

the class RestApiTest method testbasicUpdateCreateTrue.

@Test
public void testbasicUpdateCreateTrue() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + update_test_uri + "?create=true");
    HttpPut httpPut = new HttpPut(request.getUri());
    StringEntity entity = new StringEntity(update_test_doc, ContentType.create("application/json"));
    httpPut.setEntity(entity);
    assertThat(doRest(httpPut), is(update_test_response));
    assertThat(getLog(), containsString("CREATE IF NON EXISTENT IS TRUE"));
}
Also used : StringEntity(org.apache.http.entity.StringEntity) Request(com.yahoo.application.container.handler.Request) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 14 with Request

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

the class RestApiTest method test_node_patching.

@Test
public void test_node_patching() throws Exception {
    assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com", Utf8.toBytes("{" + "\"currentRestartGeneration\": 1," + "\"currentRebootGeneration\": 3," + "\"flavor\": \"medium-disk\"," + "\"currentVespaVersion\": \"5.104.142\"," + "\"hardwareFailureDescription\": \"memory_mcelog\"," + "\"failCount\": 0," + "\"parentHostname\": \"parent.yahoo.com\"" + "}"), Request.Method.PATCH), "{\"message\":\"Updated host4.yahoo.com\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/node/doesnotexist.yahoo.com", Utf8.toBytes("{\"currentRestartGeneration\": 1}"), Request.Method.PATCH), 404, "{\"error-code\":\"NOT_FOUND\",\"message\":\"No node found with hostname doesnotexist.yahoo.com\"}");
    assertResponse(new Request("http://localhost:8080/nodes/v2/node/host5.yahoo.com", Utf8.toBytes("{\"currentRestartGeneration\": 1}"), Request.Method.PATCH), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Could not set field 'currentRestartGeneration': Node is not allocated\"}");
}
Also used : Request(com.yahoo.application.container.handler.Request) Test(org.junit.Test)

Example 15 with Request

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

the class RestApiTest method setting_node_to_ready_will_reset_certain_fields.

@Test
public void setting_node_to_ready_will_reset_certain_fields() throws Exception {
    final String hostname = "host55.yahoo.com";
    assertResponse(new Request("http://localhost:8080/nodes/v2/state/ready/" + hostname, new byte[0], Request.Method.PUT), "{\"message\":\"Moved " + hostname + " to ready\"}");
    assertFile(new Request("http://localhost:8080/nodes/v2/node/" + hostname), "node55-after-changes.json");
}
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