Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests in HierarchicalForkJoinSubworkflowRerunSpec & HierarchicalForkJoinSubworkflowRestartSpec #257

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test-harness/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ dependencies {
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation "jakarta.ws.rs:jakarta.ws.rs-api:${revJAXRS}"
testImplementation "org.glassfish.jersey.core:jersey-common:${revJerseyCommon}"
testImplementation "org.awaitility:awaitility:${revAwaitility}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package com.netflix.conductor.test.integration

import java.util.concurrent.TimeUnit

import org.springframework.beans.factory.annotation.Autowired

import com.netflix.conductor.common.metadata.tasks.Task
Expand All @@ -30,6 +32,8 @@ import static com.netflix.conductor.common.metadata.tasks.TaskType.TASK_TYPE_JOI
import static com.netflix.conductor.common.metadata.tasks.TaskType.TASK_TYPE_SUB_WORKFLOW
import static com.netflix.conductor.test.util.WorkflowTestUtil.verifyPolledAndAcknowledgedTask

import static org.awaitility.Awaitility.await

class HierarchicalForkJoinSubworkflowRerunSpec extends AbstractSpecification {

@Shared
Expand Down Expand Up @@ -230,10 +234,23 @@ class HierarchicalForkJoinSubworkflowRerunSpec extends AbstractSpecification {
tasks[3].status == Task.Status.IN_PROGRESS
}

when: "poll and complete the integration_task_2 task in the root workflow"
when: "poll and complete integration_task_2 in root and mid level workflow"
def rootJoinId = workflowExecutionService.getExecutionStatus(rootWorkflowId, true).getTaskByRefName("fanouttask_join").taskId
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def newMidLevelWorkflowId = workflowExecutionService.getExecutionStatus(rootWorkflowId, true).getTasks().get(1).subWorkflowId
// The root workflow has an integration_task_2. Its subworkflow also has an integration_task_2.
// We have NO guarantees which will be polled and completed first, so the assertions done in previous versions of this test were wrong.
await().atMost(10, TimeUnit.SECONDS).until {
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def rootWf = workflowExecutionService.getExecutionStatus(rootWorkflowId, true)
def midWf = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true)

rootWf.status == Workflow.WorkflowStatus.RUNNING &&
rootWf.tasks[2].taskType == 'integration_task_2' &&
rootWf.tasks[2].status == Task.Status.COMPLETED &&
midWf.status == Workflow.WorkflowStatus.RUNNING &&
midWf.tasks[2].taskType == 'integration_task_2' &&
midWf.tasks[2].status == Task.Status.COMPLETED
}

then: "verify that a new mid level workflow is created and is in RUNNING state"
newMidLevelWorkflowId != midLevelWorkflowId
Expand All @@ -251,9 +268,8 @@ class HierarchicalForkJoinSubworkflowRerunSpec extends AbstractSpecification {
tasks[3].status == Task.Status.IN_PROGRESS
}

when: "poll and complete the integration_task_2 task in the root-level workflow"
when: "mid level workflow is in RUNNING state"
def midJoinId = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true).getTaskByRefName("fanouttask_join").taskId
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def newLeafWorkflowId = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true).getTasks().get(1).subWorkflowId

then: "verify that a new leaf workflow is created and is in RUNNING state"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package com.netflix.conductor.test.integration

import java.util.concurrent.TimeUnit

import org.springframework.beans.factory.annotation.Autowired

import com.netflix.conductor.common.metadata.tasks.Task
Expand All @@ -29,6 +31,8 @@ import static com.netflix.conductor.common.metadata.tasks.TaskType.TASK_TYPE_JOI
import static com.netflix.conductor.common.metadata.tasks.TaskType.TASK_TYPE_SUB_WORKFLOW
import static com.netflix.conductor.test.util.WorkflowTestUtil.verifyPolledAndAcknowledgedTask

import static org.awaitility.Awaitility.await

class HierarchicalForkJoinSubworkflowRestartSpec extends AbstractSpecification {

@Shared
Expand Down Expand Up @@ -231,10 +235,23 @@ class HierarchicalForkJoinSubworkflowRestartSpec extends AbstractSpecification {
tasks[3].status == Task.Status.IN_PROGRESS
}

when: "poll and complete the integration_task_2 task in the root workflow"
when: "poll and complete integration_task_2 in root and mid level workflow"
def rootJoinId = workflowExecutionService.getExecutionStatus(rootWorkflowId, true).getTaskByRefName("fanouttask_join").taskId
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def newMidLevelWorkflowId = workflowExecutionService.getExecutionStatus(rootWorkflowId, true).getTasks().get(1).subWorkflowId
// The root workflow has an integration_task_2. Its subworkflow also has an integration_task_2.
// We have NO guarantees which will be polled and completed first, so the assertions done in previous versions of this test were wrong.
await().atMost(10, TimeUnit.SECONDS).until {
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def rootWf = workflowExecutionService.getExecutionStatus(rootWorkflowId, true)
def midWf = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true)

rootWf.status == Workflow.WorkflowStatus.RUNNING &&
rootWf.tasks[2].taskType == 'integration_task_2' &&
rootWf.tasks[2].status == Task.Status.COMPLETED &&
midWf.status == Workflow.WorkflowStatus.RUNNING &&
midWf.tasks[2].taskType == 'integration_task_2' &&
midWf.tasks[2].status == Task.Status.COMPLETED
}

then: "verify that a new mid level workflow is created and is in RUNNING state"
newMidLevelWorkflowId != midLevelWorkflowId
Expand All @@ -251,9 +268,8 @@ class HierarchicalForkJoinSubworkflowRestartSpec extends AbstractSpecification {
tasks[3].status == Task.Status.IN_PROGRESS
}

when: "poll and complete the integration_task_2 task in the mid-level workflow"
when: "mid level workflow is in RUNNING state"
def midJoinId = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true).getTaskByRefName("fanouttask_join").taskId
workflowTestUtil.pollAndCompleteTask('integration_task_2', 'task2.integration.worker', ['op': 'task2.done'])
def newLeafWorkflowId = workflowExecutionService.getExecutionStatus(newMidLevelWorkflowId, true).getTasks().get(1).subWorkflowId

then: "verify that a new leaf workflow is created and is in RUNNING state"
Expand Down
Loading