Skip to content

Commit

Permalink
test child workflow inherit
Browse files Browse the repository at this point in the history
  • Loading branch information
carlydf committed Nov 30, 2024
1 parent b34617b commit d64a51b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
13 changes: 0 additions & 13 deletions common/testing/testvars/test_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package testvars

import (
deploymentpb "go.temporal.io/api/deployment/v1"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -213,18 +212,6 @@ func (tv *TestVars) WithTaskQueue(taskQueue string, key ...string) *TestVars {
return tv.cloneSet("task_queue", key, taskQueue)
}

func (tv *TestVars) WithBuildId(buildId string, key ...string) *TestVars {
return tv.cloneSet("build_id", key, buildId)
}

func (tv *TestVars) Deployment(key ...string) *deploymentpb.Deployment {
//revive:disable-next-line:unchecked-type-assertion
return &deploymentpb.Deployment{
SeriesName: tv.DeploymentSeries(key...),
BuildId: tv.BuildId(key...),
}
}

func (tv *TestVars) StickyTaskQueue(key ...string) *taskqueuepb.TaskQueue {
return &taskqueuepb.TaskQueue{
Name: tv.getOrCreate("sticky_task_queue", key).(string),
Expand Down
31 changes: 19 additions & 12 deletions tests/child_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ type ChildWorkflowSuite struct {

func (s *ChildWorkflowSuite) SetupSuite() {
dynamicConfigOverrides := map[dynamicconfig.Key]any{
dynamicconfig.FrontendEnableDeployments.Key(): true,
dynamicconfig.WorkerEnableDeployment.Key(): true,
dynamicconfig.EnableDeployments.Key(): true,
dynamicconfig.FrontendEnableWorkerVersioningWorkflowAPIs.Key(): true,
dynamicconfig.MatchingForwarderMaxChildrenPerNode.Key(): partitionTreeDegree,

Expand All @@ -84,10 +83,6 @@ func (s *ChildWorkflowSuite) TearDownSuite() {
s.FunctionalTestBase.TearDownSuite()
}

//func (s *ChildWorkflowSuite) SetupTest() {
// s.FunctionalTestBase.SetupTest()
//}

func TestChildWorkflowSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(ChildWorkflowSuite))
Expand Down Expand Up @@ -414,12 +409,16 @@ func (s *ChildWorkflowSuite) testChildWorkflowExecution(override *workflowpb.Ver
s.Nil(parentStartedEventAttrs.GetRootWorkflowExecution())

// Process ChildExecution Started event and Process Child Execution and complete it
_, err = pollerParent.PollAndHandleWorkflowTask(parentTV, wtHandlerParent)
_, err = pollerParent.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(parentTV, wtHandlerParent)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)

// Process Child workflow to start grandchild execution
_, err = pollerChild.PollAndHandleWorkflowTask(childTV, wtHandlerChild)
_, err = pollerChild.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(childTV, wtHandlerChild)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)
s.NotNil(childStartedEventFromParent)
Expand Down Expand Up @@ -458,12 +457,16 @@ func (s *ChildWorkflowSuite) testChildWorkflowExecution(override *workflowpb.Ver
s.checkDescribeWorkflowAfterOverride(&commonpb.WorkflowExecution{WorkflowId: childID, RunId: childRunID}, override)

// Process GrandchildExecution Started event and Process Grandchild Execution and complete it
_, err = pollerChild.PollAndHandleWorkflowTask(childTV, wtHandlerChild)
_, err = pollerChild.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(childTV, wtHandlerChild)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)

// Process Grandchild workflow
_, err = pollerGrandchild.PollAndHandleWorkflowTask(grandchildTV, wtHandlerGrandchild)
_, err = pollerGrandchild.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(grandchildTV, wtHandlerGrandchild)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)
s.True(grandchildComplete)
Expand All @@ -482,13 +485,17 @@ func (s *ChildWorkflowSuite) testChildWorkflowExecution(override *workflowpb.Ver
s.ProtoEqual(override, grandchildStartedEventAttrs.GetVersioningOverride())

// Process GrandchildExecution completed event and complete child execution
_, err = pollerChild.PollAndHandleWorkflowTask(childTV, wtHandlerChild)
_, err = pollerChild.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(childTV, wtHandlerChild)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)
s.True(childComplete)

// Process ChildExecution completed event and complete parent execution
_, err = pollerParent.PollAndHandleWorkflowTask(parentTV, wtHandlerParent)
_, err = pollerParent.PollWorkflowTask(
&workflowservice.PollWorkflowTaskQueueRequest{WorkerVersionCapabilities: versionCap},
).HandleTask(parentTV, wtHandlerParent)
s.Logger.Info("PollAndHandleWorkflowTask", tag.Error(err))
s.NoError(err)
s.NotNil(childCompletedEventFromParent)
Expand Down

0 comments on commit d64a51b

Please sign in to comment.