Search in sources :

Example 16 with RunnableTask

use of org.flyte.api.v1.RunnableTask in project flytekit-java by flyteorg.

the class ChainedExecutionListenerTest method testChaining.

@Test
public void testChaining() {
    TestingListener listener1 = new TestingListener();
    TestingListener listener2 = new TestingListener();
    ExecutionListener chained = ChainedExecutionListener.of(ImmutableList.of(listener1, listener2));
    ExecutionNode node = ExecutionNode.builder().nodeId("node-1").upstreamNodeIds(ImmutableList.of()).bindings(ImmutableList.of()).runnableTask(new EmptyRunnableTask()).attempts(1).build();
    Literal a = Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofIntegerValue(42L)));
    Literal b = Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofIntegerValue(1337L)));
    chained.pending(node);
    chained.starting(node, ImmutableMap.of("a", a));
    chained.retrying(node, ImmutableMap.of("a", a), new RuntimeException("oops"), /* attempt= */
    0);
    chained.completed(node, ImmutableMap.of("a", a), ImmutableMap.of("b", b));
    chained.error(node, ImmutableMap.of("a", a), new RuntimeException("oops"));
    List<List<Object>> expected = ImmutableList.of(ofPending("node-1"), ofStarting("node-1", ImmutableMap.of("a", a)), ofRetrying("node-1", ImmutableMap.of("a", a), "oops", /* attempt= */
    0), ofCompleted("node-1", ImmutableMap.of("a", a), ImmutableMap.of("b", b)), ofError("node-1", ImmutableMap.of("a", a), "oops"));
    assertEquals(expected, listener1.actions);
    assertEquals(expected, listener2.actions);
}
Also used : Literal(org.flyte.api.v1.Literal) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

RunnableTask (org.flyte.api.v1.RunnableTask)14 Test (org.junit.jupiter.api.Test)10 Literal (org.flyte.api.v1.Literal)8 WorkflowTemplate (org.flyte.api.v1.WorkflowTemplate)8 HashMap (java.util.HashMap)5 TaskTemplate (org.flyte.api.v1.TaskTemplate)5 List (java.util.List)4 TaskIdentifier (org.flyte.api.v1.TaskIdentifier)4 DynamicWorkflowTask (org.flyte.api.v1.DynamicWorkflowTask)3 Resources (org.flyte.api.v1.Resources)3 ByteString (com.google.protobuf.ByteString)2 Container (org.flyte.api.v1.Container)2 ContainerError (org.flyte.api.v1.ContainerError)2 PartialTaskIdentifier (org.flyte.api.v1.PartialTaskIdentifier)2 ClassLoaders.withClassLoader (org.flyte.jflyte.ClassLoaders.withClassLoader)2 FileSystem (org.flyte.jflyte.api.FileSystem)2 RetryableTask (org.flyte.localengine.examples.RetryableTask)2 RetryableWorkflow (org.flyte.localengine.examples.RetryableWorkflow)2 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1