Skip to content

Commit

Permalink
Replace ListWorkflow with DescribeWorkflowExecution in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed Sep 7, 2022
1 parent 06d2e6d commit 713ef57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
2 changes: 2 additions & 0 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,8 @@ func (wc *workflowEnvironmentInterceptor) UpsertSearchAttributes(ctx Context, at
// "Key2": true,
// "Key3": "seattle",
// }
//
// This is only supported with Temporal Server 1.18+
func UpsertMemo(ctx Context, memo map[string]interface{}) error {
i := getWorkflowOutboundInterceptor(ctx)
return i.UpsertMemo(ctx, memo)
Expand Down
36 changes: 6 additions & 30 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2561,20 +2561,12 @@ func (ts *IntegrationTestSuite) TestUpsertMemoFromNil() {
time.Sleep(2 * time.Second)

// Query ES for memo
var nextPageToken []byte
resp, err := ts.client.ListWorkflow(ctx, &workflowservice.ListWorkflowExecutionsRequest{
Namespace: ts.config.Namespace,
PageSize: 10,
NextPageToken: nextPageToken,
Query: fmt.Sprintf("WorkflowId = '%s'", wfid),
})
resp, err := ts.client.DescribeWorkflowExecution(ctx, wfid, "")
ts.NoError(err)
ts.NotNil(resp)

ts.Greater(len(resp.Executions), 0)
wfExecutionInfo := resp.Executions[0]
// workflow execution info matches memo in ES and correct
ts.Equal(wfExecutionInfo.Memo, memo)
ts.Equal(resp.WorkflowExecutionInfo.Memo, memo)
ts.Equal(expectedMemo, memo)
}

Expand Down Expand Up @@ -2622,20 +2614,12 @@ func (ts *IntegrationTestSuite) TestUpsertMemoFromEmptyMap() {
time.Sleep(2 * time.Second)

// Query ES for memo
var nextPageToken []byte
resp, err := ts.client.ListWorkflow(ctx, &workflowservice.ListWorkflowExecutionsRequest{
Namespace: ts.config.Namespace,
PageSize: 10,
NextPageToken: nextPageToken,
Query: fmt.Sprintf("WorkflowId = '%s'", wfid),
})
resp, err := ts.client.DescribeWorkflowExecution(ctx, wfid, "")
ts.NoError(err)
ts.NotNil(resp)

ts.Greater(len(resp.Executions), 0)
wfExecutionInfo := resp.Executions[0]
// workflow execution info matches memo in ES and correct
ts.Equal(wfExecutionInfo.Memo, memo)
ts.Equal(resp.WorkflowExecutionInfo.Memo, memo)
ts.Equal(expectedMemo, memo)
}

Expand Down Expand Up @@ -2686,20 +2670,12 @@ func (ts *IntegrationTestSuite) TestUpsertMemoWithExistingMemo() {
time.Sleep(2 * time.Second)

// Query ES for memo
var nextPageToken []byte
resp, err := ts.client.ListWorkflow(ctx, &workflowservice.ListWorkflowExecutionsRequest{
Namespace: ts.config.Namespace,
PageSize: 10,
NextPageToken: nextPageToken,
Query: fmt.Sprintf("WorkflowId = '%s'", wfid),
})
resp, err := ts.client.DescribeWorkflowExecution(ctx, wfid, "")
ts.NoError(err)
ts.NotNil(resp)

ts.Greater(len(resp.Executions), 0)
wfExecutionInfo := resp.Executions[0]
// workflow execution info matches memo in ES and correct
ts.Equal(wfExecutionInfo.Memo, memo)
ts.Equal(resp.WorkflowExecutionInfo.Memo, memo)
ts.Equal(expectedMemo, memo)
}

Expand Down
2 changes: 2 additions & 0 deletions workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ func UpsertSearchAttributes(ctx Context, attributes map[string]interface{}) erro
// "Key2": true,
// "Key3": "seattle",
// }
//
// This is only supported with Temporal Server 1.18+
func UpsertMemo(ctx Context, memo map[string]interface{}) error {
return internal.UpsertMemo(ctx, memo)
}
Expand Down

0 comments on commit 713ef57

Please sign in to comment.