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);
}
Aggregations