Search in sources :

Example 6 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testHTTPGetConnectionTimeOut.

@Test
public void testHTTPGetConnectionTimeOut() throws Exception {
    Task task = new Task();
    Input input = new Input();
    Instant start = Instant.now();
    input.setConnectionTimeOut(110);
    input.setMethod("GET");
    input.setUri("http://10.255.14.15");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    task.setStatus(Status.SCHEDULED);
    task.setScheduledTime(0);
    httpTask.start(workflow, task, workflowExecutor);
    Instant end = Instant.now();
    long diff = end.toEpochMilli() - start.toEpochMilli();
    Assert.assertEquals(task.getStatus(), Status.FAILED);
    Assert.assertTrue(diff >= 110l);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) Instant(java.time.Instant) Test(org.junit.Test)

Example 7 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testHTTPGETReadTimeOut.

@Test
public void testHTTPGETReadTimeOut() throws Exception {
    Task task = new Task();
    Input input = new Input();
    input.setReadTimeOut(-1);
    input.setMethod("GET");
    input.setUri("http://localhost:7009/json");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    task.setStatus(Status.SCHEDULED);
    task.setScheduledTime(0);
    httpTask.start(workflow, task, workflowExecutor);
    Assert.assertEquals(task.getStatus(), Status.FAILED);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) Test(org.junit.Test)

Example 8 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testTextGET.

@Test
public void testTextGET() {
    Task task = new Task();
    Input input = new Input();
    input.setUri("http://localhost:7009/text");
    input.setMethod("GET");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    httpTask.start(workflow, task, workflowExecutor);
    Map<String, Object> hr = (Map<String, Object>) task.getOutputData().get("response");
    Object response = hr.get("body");
    assertEquals(Task.Status.COMPLETED, task.getStatus());
    assertEquals(TEXT_RESPONSE, response);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 9 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testExecute.

@Test
public void testExecute() {
    Task task = new Task();
    Input input = new Input();
    input.setUri("http://localhost:7009/json");
    input.setMethod("GET");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    task.setStatus(Status.SCHEDULED);
    task.setScheduledTime(0);
    boolean executed = httpTask.execute(workflow, task, workflowExecutor);
    assertFalse(executed);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) Test(org.junit.Test)

Example 10 with Input

use of com.netflix.conductor.contribs.http.HttpTask.Input in project conductor by Netflix.

the class TestHttpTask method testFailure.

@Test
public void testFailure() {
    Task task = new Task();
    Input input = new Input();
    input.setUri("http://localhost:7009/failure");
    input.setMethod("GET");
    task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
    httpTask.start(workflow, task, workflowExecutor);
    assertEquals("Task output: " + task.getOutputData(), Task.Status.FAILED, task.getStatus());
    assertEquals(ERROR_RESPONSE, task.getReasonForIncompletion());
    task.setStatus(Status.SCHEDULED);
    task.getInputData().remove(HttpTask.REQUEST_PARAMETER_NAME);
    httpTask.start(workflow, task, workflowExecutor);
    assertEquals(Task.Status.FAILED, task.getStatus());
    assertEquals(HttpTask.MISSING_REQUEST, task.getReasonForIncompletion());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) Test(org.junit.Test)

Aggregations

Task (com.netflix.conductor.common.metadata.tasks.Task)12 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)12 Input (com.netflix.conductor.contribs.http.HttpTask.Input)12 Test (org.junit.Test)12 HashMap (java.util.HashMap)8 Map (java.util.Map)7 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)1 Workflow (com.netflix.conductor.common.run.Workflow)1 Configuration (com.netflix.conductor.core.config.Configuration)1 DeciderService (com.netflix.conductor.core.execution.DeciderService)1 ParametersUtils (com.netflix.conductor.core.execution.ParametersUtils)1 TaskMapper (com.netflix.conductor.core.execution.mapper.TaskMapper)1 ExternalPayloadStorageUtils (com.netflix.conductor.core.utils.ExternalPayloadStorageUtils)1 MetadataDAO (com.netflix.conductor.dao.MetadataDAO)1 Instant (java.time.Instant)1