Search in sources :

Example 11 with TaskIdentifier

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

the class SdkRunnableTaskRegistrarTest method shouldLoadRunnableTasksFromDiscoveredRegistries.

@Test
void shouldLoadRunnableTasksFromDiscoveredRegistries() {
    // given
    String testTaskName = "org.flyte.flytekit.SdkRunnableTaskRegistrarTest$TestTask";
    String otherTestTaskName = "org.flyte.flytekit.SdkRunnableTaskRegistrarTest$OtherTestTask";
    TaskIdentifier expectedTestTaskId = TaskIdentifier.builder().project("project").domain("domain").name(testTaskName).version("version").build();
    TypedInterface typedInterface = TypedInterface.builder().inputs(SdkTypes.nulls().getVariableMap()).outputs(SdkTypes.nulls().getVariableMap()).build();
    RetryStrategy retries = RetryStrategy.builder().retries(0).build();
    RetryStrategy otherRetries = RetryStrategy.builder().retries(1).build();
    Map<Resources.ResourceName, String> limits = new HashMap<>();
    limits.put(Resources.ResourceName.CPU, "0.5");
    limits.put(Resources.ResourceName.MEMORY, "2Gi");
    Map<Resources.ResourceName, String> requests = new HashMap<>();
    requests.put(Resources.ResourceName.CPU, "2");
    requests.put(Resources.ResourceName.MEMORY, "5Gi");
    Resources resources = Resources.builder().limits(limits).requests(requests).build();
    RunnableTask expectedTask = createRunnableTask(testTaskName, typedInterface, retries, null);
    TaskIdentifier expectedOtherTestTaskId = TaskIdentifier.builder().project("project").domain("domain").name(otherTestTaskName).version("version").build();
    RunnableTask expectedOtherTask = createRunnableTask(otherTestTaskName, typedInterface, otherRetries, resources);
    // when
    Map<TaskIdentifier, RunnableTask> tasks = registrar.load(ENV);
    // then
    assertAll(() -> assertThat(tasks, hasKey(is(expectedTestTaskId))), () -> assertThat(tasks, hasKey(is(expectedOtherTestTaskId))));
    assertTaskEquals(tasks.get(expectedTestTaskId), expectedTask);
    assertTaskEquals(tasks.get(expectedOtherTestTaskId), expectedOtherTask);
}
Also used : TypedInterface(org.flyte.api.v1.TypedInterface) TaskIdentifier(org.flyte.api.v1.TaskIdentifier) HashMap(java.util.HashMap) Resources(org.flyte.api.v1.Resources) RunnableTask(org.flyte.api.v1.RunnableTask) RetryStrategy(org.flyte.api.v1.RetryStrategy) Test(org.junit.jupiter.api.Test)

Aggregations

TaskIdentifier (org.flyte.api.v1.TaskIdentifier)11 PartialTaskIdentifier (org.flyte.api.v1.PartialTaskIdentifier)8 HashMap (java.util.HashMap)4 RunnableTask (org.flyte.api.v1.RunnableTask)3 TaskTemplate (org.flyte.api.v1.TaskTemplate)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 DynamicWorkflowTask (org.flyte.api.v1.DynamicWorkflowTask)2 RetryStrategy (org.flyte.api.v1.RetryStrategy)2 TypedInterface (org.flyte.api.v1.TypedInterface)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 IdentifierOuterClass (flyteidl.core.IdentifierOuterClass)1 Container (org.flyte.api.v1.Container)1 ContainerError (org.flyte.api.v1.ContainerError)1 DynamicJobSpec (org.flyte.api.v1.DynamicJobSpec)1 DynamicWorkflowTaskRegistrar (org.flyte.api.v1.DynamicWorkflowTaskRegistrar)1 Literal (org.flyte.api.v1.Literal)1 PartialWorkflowIdentifier (org.flyte.api.v1.PartialWorkflowIdentifier)1 Resources (org.flyte.api.v1.Resources)1 RunnableTaskRegistrar (org.flyte.api.v1.RunnableTaskRegistrar)1