Skip to content

Commit

Permalink
polish tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Sep 23, 2024
1 parent ffde855 commit 8c47245
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
1 change: 1 addition & 0 deletions cmd/tools/genrpcserverinterceptors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func writeGrpcServerData(w io.Writer, grpcServerT reflect.Type, tmpl string) {
fatalIfErr(template.Must(template.New("code").Parse(tmpl)).Execute(w, sd))
}

//nolint:revive // cognitive complexity 37 (> max enabled 25)
func workflowTagGetters(requestT reflect.Type, depth int) requestData {
rd := requestData{}
if depth > maxRequestDepth {
Expand Down
59 changes: 30 additions & 29 deletions common/rpc/interceptor/logtags/workflow_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/rpc/interceptor/logtags"
"go.temporal.io/server/common/testing/testvars"
)

func TestExtract(t *testing.T) {
Expand All @@ -47,11 +48,11 @@ func TestExtract(t *testing.T) {
log.NewTestLogger(),
)

wid := "test_workflow_id"
rid := "test_run_id"
tv := testvars.New(t)
tv = tv.WithRunID(tv.Any().RunID())
taskToken := token.Task{
WorkflowId: wid,
RunId: rid,
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
}
taskTokenBytes, err := serializer.Serialize(&taskToken)
assert.NoError(t, err)
Expand All @@ -65,49 +66,49 @@ func TestExtract(t *testing.T) {
}{
{
name: "Frontend StartWorkflowExecutionRequest with only workflowID",
req: &workflowservice.StartWorkflowExecutionRequest{WorkflowId: wid},
req: &workflowservice.StartWorkflowExecutionRequest{WorkflowId: tv.WorkflowID()},
fullMethod: "/temporal.api.workflowservice.v1.WorkflowService/StartWorkflowExecution",
workflowID: wid,
workflowID: tv.WorkflowID(),
},
{
name: "Frontend RecordActivityTaskHeartbeatByIdRequest with workflowID and runID",
req: &workflowservice.RecordActivityTaskHeartbeatByIdRequest{WorkflowId: wid, RunId: rid},
req: &workflowservice.RecordActivityTaskHeartbeatByIdRequest{WorkflowId: tv.WorkflowID(), RunId: tv.RunID()},
fullMethod: "/temporal.api.workflowservice.v1.WorkflowService/RecordActivityTaskHeartbeatById",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Frontend GetWorkflowExecutionHistoryRequest with execution",
req: &workflowservice.GetWorkflowExecutionHistoryRequest{
Execution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
},
fullMethod: "/temporal.api.workflowservice.v1.WorkflowService/GetWorkflowExecutionHistory",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Frontend RequestCancelWorkflowExecutionRequest with workflow_execution",
req: &workflowservice.RequestCancelWorkflowExecutionRequest{
WorkflowExecution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
},
fullMethod: "/temporal.api.workflowservice.v1.WorkflowService/RequestCancelWorkflowExecution",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Frontend RespondActivityTaskCompletedRequest with task_token",
req: &workflowservice.RespondActivityTaskCompletedRequest{
TaskToken: taskTokenBytes,
},
fullMethod: "/temporal.api.workflowservice.v1.WorkflowService/RespondActivityTaskCompleted",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Frontend RespondQueryTaskCompletedRequest (task_token is ignored)",
Expand All @@ -121,14 +122,14 @@ func TestExtract(t *testing.T) {
req: &historyservice.DescribeWorkflowExecutionRequest{
Request: &workflowservice.DescribeWorkflowExecutionRequest{
Execution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
},
},
fullMethod: "/temporal.server.api.historyservice.v1.HistoryService/DescribeWorkflowExecution",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "History RespondWorkflowTaskCompletedRequest",
Expand All @@ -138,22 +139,22 @@ func TestExtract(t *testing.T) {
},
},
fullMethod: "/temporal.server.api.historyservice.v1.HistoryService/RespondWorkflowTaskCompleted",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Matching QueryWorkflowRequest",
req: &matchingservice.QueryWorkflowRequest{
QueryRequest: &workflowservice.QueryWorkflowRequest{
Execution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
WorkflowId: tv.WorkflowID(),
RunId: tv.RunID(),
},
},
},
fullMethod: "/temporal.server.api.matchingservice.v1.MatchingService/QueryWorkflow",
workflowID: wid,
runID: rid,
workflowID: tv.WorkflowID(),
runID: tv.RunID(),
},
{
name: "Matching RespondWorkflowTaskCompletedRequest",
Expand Down

0 comments on commit 8c47245

Please sign in to comment.