Skip to content

Commit b754e20

Browse files
committed
broken cross-tq-can test
1 parent de0c67a commit b754e20

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

tests/versioning_3_test.go

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func NewVersioning3Suite(useV32 bool) *Versioning3Suite {
7575
func TestVersioning3FunctionalSuite(t *testing.T) {
7676
t.Parallel()
7777
suite.Run(t, NewVersioning3Suite(true))
78-
//suite.Run(t, NewVersioning3Suite(false))
78+
// suite.Run(t, NewVersioning3Suite(false))
7979
}
8080

8181
func (s *Versioning3Suite) SetupSuite() {
@@ -1510,23 +1510,31 @@ func (s *Versioning3Suite) testChildWorkflowInheritance_ExpectNoInherit(crossTq
15101510
s.verifyWorkflowVersioning(tv2Child, vbPinned, tv2Child.Deployment(), nil, nil)
15111511
}
15121512

1513-
func (s *Versioning3Suite) TestPinnedCaN() {
1514-
s.testCan(vbPinned)
1513+
func (s *Versioning3Suite) TestPinnedCaN_SameTQ() {
1514+
s.testCan(false, vbPinned, true)
15151515
}
15161516

1517-
func (s *Versioning3Suite) TestUnpinnedCaN() {
1518-
s.testCan(vbUnpinned)
1517+
func (s *Versioning3Suite) TestPinnedCaN_CrossTQ_Inherit() {
1518+
s.testCan(false, vbPinned, true)
1519+
}
1520+
1521+
func (s *Versioning3Suite) TestPinnedCaN_CrossTQ_NoInherit() {
1522+
s.testCan(false, vbPinned, false)
15191523
}
15201524

1521-
func (s *Versioning3Suite) testCan(behavior enumspb.VersioningBehavior) {
1522-
// CaN inherits version if pinned, goes to current version if unpinned.
1525+
func (s *Versioning3Suite) TestUnpinnedCaN() {
1526+
s.testCan(false, vbUnpinned, false)
1527+
}
15231528

1529+
func (s *Versioning3Suite) testCan(crossTq bool, behavior enumspb.VersioningBehavior, expectInherit bool) {
1530+
// CaN inherits version if pinned and if new task queue is in pinned version, goes to current version if unpinned.
15241531
tv1 := testvars.New(s).WithBuildIDNumber(1).WithWorkflowIDNumber(1)
15251532
tv2 := tv1.WithBuildIDNumber(2)
15261533
sdkBehavior := workflow.VersioningBehaviorAutoUpgrade
15271534
if behavior == vbPinned {
15281535
sdkBehavior = workflow.VersioningBehaviorPinned
15291536
}
1537+
canxTq := tv1.TaskQueue().GetName() + "_XTQ_CaN"
15301538

15311539
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
15321540
defer cancel()
@@ -1537,18 +1545,16 @@ func (s *Versioning3Suite) testCan(behavior enumspb.VersioningBehavior) {
15371545
wf1 := func(ctx workflow.Context, attempt int) (string, error) {
15381546
switch attempt {
15391547
case 0:
1540-
//if crossTq {
1541-
// newCtx = workflow.WithWorkflowTaskQueue(newCtx, canxTq)
1542-
//}
1548+
newCtx := ctx
1549+
if crossTq {
1550+
newCtx = workflow.WithWorkflowTaskQueue(newCtx, canxTq)
1551+
}
15431552
s.verifyWorkflowVersioning(tv1, vbUnspecified, nil, nil, tv1.DeploymentVersionTransition())
15441553
wfStarted <- struct{}{}
15451554
// wait for current version to change.
15461555
<-currentChanged
1547-
return "", workflow.NewContinueAsNewError(ctx, "wf", attempt+1)
1556+
return "", workflow.NewContinueAsNewError(newCtx, "wf", attempt+1)
15481557
case 1:
1549-
//if crossTq {
1550-
// newCtx = workflow.WithWorkflowTaskQueue(newCtx, canxTq)
1551-
//}
15521558
s.verifyWorkflowVersioning(tv1, vbPinned, tv1.Deployment(), nil, nil)
15531559
return "v1", nil
15541560
}
@@ -1566,6 +1572,19 @@ func (s *Versioning3Suite) testCan(behavior enumspb.VersioningBehavior) {
15661572
})
15671573
s.NoError(err)
15681574

1575+
if crossTq && expectInherit {
1576+
w1xtq := worker.New(sdkClient, canxTq, worker.Options{
1577+
DeploymentOptions: worker.DeploymentOptions{
1578+
Version: tv1.DeploymentVersionString(),
1579+
UseVersioning: true,
1580+
DefaultVersioningBehavior: workflow.VersioningBehaviorAutoUpgrade,
1581+
},
1582+
MaxConcurrentWorkflowTaskPollers: numPollers,
1583+
})
1584+
w1xtq.RegisterWorkflowWithOptions(wf1, workflow.RegisterOptions{Name: "wf", VersioningBehavior: workflow.VersioningBehaviorPinned})
1585+
s.NoError(w1xtq.Start())
1586+
defer w1xtq.Stop()
1587+
}
15691588
w1 := worker.New(sdkClient, tv1.TaskQueue().GetName(), worker.Options{
15701589
DeploymentOptions: worker.DeploymentOptions{
15711590
UseVersioning: true,
@@ -1612,7 +1631,7 @@ func (s *Versioning3Suite) testCan(behavior enumspb.VersioningBehavior) {
16121631

16131632
var out string
16141633
s.NoError(run.Get(ctx, &out))
1615-
if behavior == enumspb.VERSIONING_BEHAVIOR_PINNED {
1634+
if behavior == enumspb.VERSIONING_BEHAVIOR_PINNED && expectInherit {
16161635
s.Equal("v1", out)
16171636
} else {
16181637
s.Equal("v2", out)

0 commit comments

Comments
 (0)