use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class ScrewdriverApiTest method testTriggerJobForApplication.
@Test
public void testTriggerJobForApplication() {
ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
DeploymentQueue deploymentQueue = tester.controller().applications().deploymentTrigger().deploymentQueue();
tester.containerTester().updateSystemVersion();
Application app = tester.createApplication();
tester.controller().applications().lockOrThrow(app.id(), application -> tester.controller().applications().store(application.withProjectId(1)));
// Unknown application
assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/foo/application/bar", new byte[0], Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"foo.bar not found\"}");
// Invalid job
assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "invalid".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Unknown job name 'invalid'\"}");
// component is triggered if no job is specified in request body
assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), new byte[0], Request.Method.POST), 200, "{\"message\":\"Triggered component for tenant1.application1\"}");
assertFalse(deploymentQueue.jobs().isEmpty());
assertEquals(JobType.component.jobName(), deploymentQueue.jobs().get(0).jobName());
assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
deploymentQueue.takeJobsToRun();
// Triggers specific job when given
assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "staging-test".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 200, "{\"message\":\"Triggered staging-test for tenant1.application1\"}");
assertFalse(deploymentQueue.jobs().isEmpty());
assertEquals(JobType.stagingTest.jobName(), deploymentQueue.jobs().get(0).jobName());
assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testbasicEncodingV2.
@Test
public void testbasicEncodingV2() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + get_enc_test_uri_v2);
HttpGet get = new HttpGet(request.getUri());
String rest = doRest(get);
assertThat(rest, containsString(get_enc_response_part1_v2));
assertThat(rest, containsString(get_enc_response_part2));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testUseExpressionOnVisit.
@Test
public void testUseExpressionOnVisit() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_uri_selection_rewrite);
HttpGet get = new HttpGet(request.getUri());
String rest = doRest(get);
assertThat(rest, containsString(visit_test_response_selection_rewrite));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method wanted_document_count_returned_parameter_is_propagated.
@Test
public void wanted_document_count_returned_parameter_is_propagated() throws IOException {
Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?wantedDocumentCount=321", getFirstListenPort()));
HttpGet get = new HttpGet(request.getUri());
String rest = doRest(get);
assertThat(rest, containsString("min docs returned: 321"));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testSlashesInId.
@Test
public void testSlashesInId() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + id_test_uri);
HttpGet get = new HttpGet(request.getUri());
final String rest = doRest(get);
assertThat(rest, containsString(id_response_part1));
assertThat(rest, containsString(id_response_part2));
}
Aggregations