mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What Used the `depguard` linter to prevent importing the package and modified all uses of it. Also fixed a bug in the membership code where we were not updating the next page token: https://github.com/temporalio/temporal/pull/8541/files#diff-985dd64ffa4c6bfe0248b982dc47439b725862baa3e1f2c559b7ff522bf21969R350 ## Why? From the package README in GitHub: > This package now leverages the github.com/google/uuid package (which is based off an earlier version of this package). Also, there's no point in having two uuid implementations in the codebase. ## Test Added the invalid import and confirmed it works: ``` ../service/frontend/admin_handler_test.go:13:2: import 'github.com/pborman/uuid' is not allowed from list 'main': Importing github.com/pborman/uuid is disallowed; use github.com/google/uuid instead (depguard) _ "github.com/pborman/uuid" ```
136 lines
4.8 KiB
Go
136 lines
4.8 KiB
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/suite"
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
sdkpb "go.temporal.io/api/sdk/v1"
|
|
updatepb "go.temporal.io/api/update/v1"
|
|
"go.temporal.io/api/workflowservice/v1"
|
|
"go.temporal.io/server/common/testing/testvars"
|
|
"go.temporal.io/server/tests/testcore"
|
|
)
|
|
|
|
type UserMetadataSuite struct {
|
|
testcore.FunctionalTestBase
|
|
}
|
|
|
|
func TestUserMetadataSuite(t *testing.T) {
|
|
t.Parallel()
|
|
suite.Run(t, new(UserMetadataSuite))
|
|
}
|
|
|
|
func (s *UserMetadataSuite) TestUserMetadata() {
|
|
getDescribeWorkflowExecutionInfo := func(client workflowservice.WorkflowServiceClient, namespace string, workflowID string, runID string) (*workflowservice.DescribeWorkflowExecutionResponse, error) {
|
|
return client.DescribeWorkflowExecution(testcore.NewContext(), &workflowservice.DescribeWorkflowExecutionRequest{
|
|
Namespace: namespace,
|
|
Execution: &commonpb.WorkflowExecution{
|
|
WorkflowId: workflowID,
|
|
RunId: runID,
|
|
},
|
|
})
|
|
}
|
|
prepareTestUserMetadata := func() *sdkpb.UserMetadata {
|
|
return &sdkpb.UserMetadata{
|
|
Summary: &commonpb.Payload{
|
|
Metadata: map[string][]byte{"test_summary_key": []byte(`test_summary_val`)},
|
|
Data: []byte(`Test summary Data`),
|
|
},
|
|
Details: &commonpb.Payload{
|
|
Metadata: map[string][]byte{"test_details_key": []byte(`test_details_val`)},
|
|
Data: []byte(`Test Details Data`),
|
|
},
|
|
}
|
|
}
|
|
|
|
s.Run("StartWorkflowExecution records UserMetadata", func() {
|
|
tv := testvars.New(s.T())
|
|
metadata := prepareTestUserMetadata()
|
|
request := &workflowservice.StartWorkflowExecutionRequest{
|
|
RequestId: uuid.NewString(),
|
|
Namespace: s.Namespace().String(),
|
|
WorkflowId: tv.WorkflowID(),
|
|
WorkflowType: tv.WorkflowType(),
|
|
TaskQueue: tv.TaskQueue(),
|
|
UserMetadata: metadata,
|
|
}
|
|
|
|
we, err := s.FrontendClient().StartWorkflowExecution(testcore.NewContext(), request)
|
|
s.NoError(err)
|
|
|
|
// Verify that the UserMetadata associated with the start event is returned in the describe response.
|
|
describeInfo, err := getDescribeWorkflowExecutionInfo(s.FrontendClient(), s.Namespace().String(), tv.WorkflowID(), we.RunId)
|
|
s.NoError(err)
|
|
s.EqualExportedValues(metadata, describeInfo.ExecutionConfig.UserMetadata)
|
|
})
|
|
|
|
s.Run("SignalWithStartWorkflowExecution records UserMetadata", func() {
|
|
tv := testvars.New(s.T())
|
|
metadata := prepareTestUserMetadata()
|
|
request := &workflowservice.SignalWithStartWorkflowExecutionRequest{
|
|
RequestId: uuid.NewString(),
|
|
Namespace: s.Namespace().String(),
|
|
WorkflowId: tv.WorkflowID(),
|
|
WorkflowType: tv.WorkflowType(),
|
|
TaskQueue: tv.TaskQueue(),
|
|
SignalName: "TEST-SIGNAL",
|
|
UserMetadata: metadata,
|
|
}
|
|
|
|
we, err := s.FrontendClient().SignalWithStartWorkflowExecution(testcore.NewContext(), request)
|
|
s.NoError(err)
|
|
|
|
// Verify that the UserMetadata associated with the start event is returned in the describe response.
|
|
describeInfo, err := getDescribeWorkflowExecutionInfo(s.FrontendClient(), s.Namespace().String(), tv.WorkflowID(), we.RunId)
|
|
s.NoError(err)
|
|
s.EqualExportedValues(metadata, describeInfo.ExecutionConfig.UserMetadata)
|
|
})
|
|
|
|
s.Run("ExecuteMultiOperation records UserMetadata", func() {
|
|
tv := testvars.New(s.T())
|
|
metadata := prepareTestUserMetadata()
|
|
startWorkflowRequest := &workflowservice.StartWorkflowExecutionRequest{
|
|
RequestId: uuid.NewString(),
|
|
Namespace: s.Namespace().String(),
|
|
WorkflowId: tv.WorkflowID(),
|
|
WorkflowType: tv.WorkflowType(),
|
|
TaskQueue: tv.TaskQueue(),
|
|
UserMetadata: metadata,
|
|
}
|
|
updateWorkflowRequest := &workflowservice.UpdateWorkflowExecutionRequest{
|
|
Namespace: s.Namespace().String(),
|
|
WorkflowExecution: &commonpb.WorkflowExecution{WorkflowId: tv.WorkflowID()},
|
|
Request: &updatepb.Request{
|
|
Meta: &updatepb.Meta{UpdateId: "UPDATE_ID"},
|
|
Input: &updatepb.Input{Name: "NAME"},
|
|
},
|
|
}
|
|
request := &workflowservice.ExecuteMultiOperationRequest{
|
|
Namespace: s.Namespace().String(),
|
|
Operations: []*workflowservice.ExecuteMultiOperationRequest_Operation{
|
|
{ // start workflow operation
|
|
Operation: &workflowservice.ExecuteMultiOperationRequest_Operation_StartWorkflow{
|
|
StartWorkflow: startWorkflowRequest,
|
|
},
|
|
},
|
|
{ // update workflow operation
|
|
Operation: &workflowservice.ExecuteMultiOperationRequest_Operation_UpdateWorkflow{
|
|
UpdateWorkflow: updateWorkflowRequest,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
_, err := s.FrontendClient().ExecuteMultiOperation(testcore.NewContext(), request)
|
|
s.NoError(err)
|
|
|
|
// Verify that the UserMetadata associated with the start event is returned in the describe response.
|
|
describeInfo, err := getDescribeWorkflowExecutionInfo(s.FrontendClient(), s.Namespace().String(), tv.WorkflowID(), "")
|
|
s.NoError(err)
|
|
s.EqualExportedValues(metadata, describeInfo.ExecutionConfig.UserMetadata)
|
|
})
|
|
|
|
}
|