Skip to content

Commit

Permalink
Refactor: return runID from startWorkflow instead of new testvars ins…
Browse files Browse the repository at this point in the history
…tance
  • Loading branch information
alexshtin committed Jan 13, 2025
1 parent 720505d commit d4bb8ba
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 131 deletions.
32 changes: 12 additions & 20 deletions tests/reset_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (t *resetTest) reset(eventId int64) string {
func (t *resetTest) run() {
t.totalSignals = 2
t.totalUpdates = 2
t.tv = t.WorkflowUpdateBaseSuite.startWorkflow(t.tv)
t.WorkflowUpdateBaseSuite.startWorkflow(t.tv)

poller := &testcore.TaskPoller{
Client: t.FrontendClient(),
Expand Down Expand Up @@ -686,8 +686,8 @@ func (s *ResetWorkflowTestSuite) testResetWorkflowSignalReapplyBuffer(
- depending on the reapply type, the buffered signal is applied post-reset or not
*/

tv = s.startWorkflow(tv)
s.Logger.Info("StartWorkflowExecution", tag.WorkflowRunID(tv.RunID()))
runID := s.startWorkflow(tv)
s.Logger.Info("StartWorkflowExecution", tag.WorkflowRunID(runID))

var resetRunID string
wtHandler := func(task *workflowservice.PollWorkflowTaskQueueResponse) ([]*commandpb.Command, error) {
Expand All @@ -700,31 +700,23 @@ func (s *ResetWorkflowTestSuite) testResetWorkflowSignalReapplyBuffer(
// (1) send Signal
_, err := s.FrontendClient().SignalWorkflowExecution(testcore.NewContext(),
&workflowservice.SignalWorkflowExecutionRequest{
RequestId: uuid.New(),
Namespace: s.Namespace().String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
SignalName: "random signal name",
Input: &commonpb.Payloads{Payloads: []*commonpb.Payload{{
Data: []byte("random data"),
}}},
Identity: tv.WorkerIdentity(),
RequestId: tv.Any().String(),
Namespace: s.Namespace().String(),
WorkflowExecution: tv.WorkflowExecution(),
SignalName: tv.Any().String(),
Input: tv.Any().Payloads(),
Identity: tv.WorkerIdentity(),
})
s.NoError(err)

// (2) send Reset
resp, err := s.FrontendClient().ResetWorkflowExecution(testcore.NewContext(),
&workflowservice.ResetWorkflowExecutionRequest{
Namespace: s.Namespace().String(),
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
Namespace: s.Namespace().String(),
WorkflowExecution: tv.WorkflowExecution(),
Reason: "reset execution from test",
WorkflowTaskFinishEventId: 3,
RequestId: uuid.New(),
RequestId: tv.Any().String(),
ResetReapplyType: reapplyType,
})
s.NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions tests/update_workflow_suite_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ func (s *WorkflowUpdateBaseSuite) waitUpdateAdmitted(tv *testvars.TestVars) {
}, 5*time.Second, 10*time.Millisecond, "update %s did not reach Admitted stage", tv.UpdateID())
}

func (s *WorkflowUpdateBaseSuite) startWorkflow(tv *testvars.TestVars) *testvars.TestVars {
func (s *WorkflowUpdateBaseSuite) startWorkflow(tv *testvars.TestVars) string {
s.T().Helper()
startResp, err := s.FrontendClient().StartWorkflowExecution(testcore.NewContext(), s.startWorkflowRequest(tv))
s.NoError(err)

return tv.WithRunID(startResp.GetRunId())
return startResp.GetRunId()
}

func (s *WorkflowUpdateBaseSuite) startWorkflowRequest(tv *testvars.TestVars) *workflowservice.StartWorkflowExecutionRequest {
Expand Down
Loading

0 comments on commit d4bb8ba

Please sign in to comment.