Skip to content

Commit 42a0024

Browse files
authored
Fix flaky test TestTransitionDuringTransientTask (#9356)
## What changed? Fix flaky test ## Why? Flake is no good. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks None
1 parent 38ffe62 commit 42a0024

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/versioning_3_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ func (s *Versioning3Suite) testDoubleTransition(unversionedSrc bool, signal bool
15251525
s.updateTaskQueueDeploymentData(tv2, true, 0, false, 0, tqTypeWf, tqTypeAct)
15261526
}
15271527
// poll activity from v2 worker, this should start a transition but should not immediately start the activity.
1528-
go s.idlePollActivity(tv2, true, time.Minute, "v2 worker should not receive the activity")
1528+
go s.idlePollActivity(context.Background(), tv2, true, time.Minute, "v2 worker should not receive the activity")
15291529

15301530
s.EventuallyWithT(func(t *assert.CollectT) {
15311531
dwf, err := s.FrontendClient().DescribeWorkflowExecution(
@@ -1850,7 +1850,7 @@ func (s *Versioning3Suite) testTransitionFromActivity(sticky bool) {
18501850
time.Sleep(time.Millisecond * 200) //nolint:forbidigo
18511851

18521852
// Pollers of d1 are there, but should not get any task
1853-
go s.idlePollActivity(tv1, true, ver3MinPollTime, "activities should not go to the old deployment")
1853+
go s.idlePollActivity(ctx, tv1, true, ver3MinPollTime, "activities should not go to the old deployment")
18541854

18551855
go func() {
18561856
for i := 2; i <= 4; i++ {
@@ -4020,6 +4020,7 @@ func (s *Versioning3Suite) idlePollUnversionedActivity(
40204020
}
40214021

40224022
func (s *Versioning3Suite) idlePollActivity(
4023+
ctx context.Context,
40234024
tv *testvars.TestVars,
40244025
versioned bool,
40254026
timeout time.Duration,
@@ -4035,11 +4036,13 @@ func (s *Versioning3Suite) idlePollActivity(
40354036
func(task *workflowservice.PollActivityTaskQueueResponse) (*workflowservice.RespondActivityTaskCompletedRequest, error) {
40364037
if task != nil {
40374038
s.Logger.Error(fmt.Sprintf("Unexpected activity task received, ID: %s", task.ActivityId))
4038-
s.Fail(unexpectedTaskMessage)
4039+
a := s.Assert()
4040+
a.Fail(unexpectedTaskMessage)
40394041
}
40404042
return nil, nil
40414043
},
40424044
taskpoller.WithTimeout(timeout),
4045+
taskpoller.WithContext(ctx),
40434046
)
40444047
}
40454048

@@ -4515,7 +4518,7 @@ func (s *Versioning3Suite) TestActivityTQLags_DependentActivityCompletesOnTheNew
45154518

45164519
// Start an idle activity poller on v0. This poller should not receive any activity tasks
45174520
//nolint:testifylint
4518-
go s.idlePollActivity(tv0, true, ver3MinPollTime, "activity should not go to the old deployment")
4521+
go s.idlePollActivity(ctx, tv0, true, ver3MinPollTime, "activity should not go to the old deployment")
45194522

45204523
// Start a poller on v1
45214524
activityTaskCh := make(chan struct{}, 1)
@@ -5555,8 +5558,12 @@ func (s *Versioning3Suite) testTransitionDuringTransientTask(withSignal bool) {
55555558
// Create test vars for v1
55565559
tv1 := testvars.New(s).WithBuildIDNumber(1)
55575560

5558-
s.idlePollWorkflow(ctx, tv1, true, ver3MinPollTime, "should not get any tasks yet")
5559-
s.idlePollActivity(tv1, true, ver3MinPollTime, "should not get any tasks yet")
5561+
// We need to keep pollers until the task queues are properly registered
5562+
pollCtx, pollCtxCancel := context.WithTimeout(ctx, 60*time.Second)
5563+
go s.idlePollWorkflow(pollCtx, tv1, true, ver3MinPollTime, "should not get any tasks yet")
5564+
go s.idlePollActivity(pollCtx, tv1, true, ver3MinPollTime, "should not get any tasks yet")
5565+
s.waitForDeploymentDataPropagation(tv1, versionStatusInactive, false, tqTypeWf, tqTypeAct)
5566+
pollCtxCancel()
55605567

55615568
// Start the workflow
55625569
execution := &commonpb.WorkflowExecution{
@@ -5606,7 +5613,7 @@ func (s *Versioning3Suite) testTransitionDuringTransientTask(withSignal bool) {
56065613
}
56075614

56085615
// Poll the second activity to cause transition to v1.
5609-
s.idlePollActivity(tv1, true, ver3MinPollTime, "should not get the activity because it started a transition")
5616+
s.idlePollActivity(ctx, tv1, true, ver3MinPollTime, "should not get the activity because it started a transition")
56105617
s.verifyWorkflowVersioning(s.Assertions, tv1, vbUnspecified, nil, nil, tv1.DeploymentVersionTransition())
56115618

56125619
// Print workflow describe and history

0 commit comments

Comments
 (0)