diff --git a/internal/common/auth/service_wrapper_test.go b/internal/common/auth/service_wrapper_test.go index 840f0dddd..6126e3186 100644 --- a/internal/common/auth/service_wrapper_test.go +++ b/internal/common/auth/service_wrapper_test.go @@ -140,6 +140,22 @@ func (s *serviceWrapperSuite) TestDescribeWorkflowExecutionInvalidToken() { s.EqualError(err, "error") } +func (s *serviceWrapperSuite) TestDiagnoseWorkflowExecutionValidToken() { + s.Service.EXPECT().DiagnoseWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) + sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider) + ctx, _ := thrift.NewContext(time.Minute) + _, err := sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{}) + s.NoError(err) +} + +func (s *serviceWrapperSuite) TestDiagnoseWorkflowExecutionInvalidToken() { + s.AuthProvider = newJWTAuthIncorrect() + sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider) + ctx, _ := thrift.NewContext(time.Minute) + _, err := sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{}) + s.EqualError(err, "error") +} + func (s *serviceWrapperSuite) TestGetWorkflowExecutionHistoryValidToken() { s.Service.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider) diff --git a/internal/common/isolationgroup/service_wrapper_test.go b/internal/common/isolationgroup/service_wrapper_test.go index d299268eb..8866c3fea 100644 --- a/internal/common/isolationgroup/service_wrapper_test.go +++ b/internal/common/isolationgroup/service_wrapper_test.go @@ -86,6 +86,15 @@ func TestAPICalls(t *testing.T) { }, expectedResponse: &shared.DescribeWorkflowExecutionResponse{}, }, + "DiagnoseWorkflowExecution": { + action: func(ctx context.Context, sw workflowserviceclient.Interface) (interface{}, error) { + return sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{}) + }, + affordance: func(m *workflowservicetest.MockClient) { + m.EXPECT().DiagnoseWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(&shared.DiagnoseWorkflowExecutionResponse{}, nil) + }, + expectedResponse: &shared.DiagnoseWorkflowExecutionResponse{}, + }, "ListOpenWorkflowExecutions": { action: func(ctx context.Context, sw workflowserviceclient.Interface) (interface{}, error) { return sw.ListOpenWorkflowExecutions(ctx, &shared.ListOpenWorkflowExecutionsRequest{}) diff --git a/internal/compatibility/adapter.go b/internal/compatibility/adapter.go index 24a5db6de..62cbe2e71 100644 --- a/internal/compatibility/adapter.go +++ b/internal/compatibility/adapter.go @@ -333,6 +333,10 @@ func (a workflowAPIthriftAdapter) DescribeWorkflowExecution(ctx context.Context, response, err := a.service.DescribeWorkflowExecution(ctx, thrift.DescribeWorkflowExecutionRequest(request), opts...) return proto.DescribeWorkflowExecutionResponse(response), proto.Error(err) } +func (a workflowAPIthriftAdapter) DiagnoseWorkflowExecution(ctx context.Context, request *apiv1.DiagnoseWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.DiagnoseWorkflowExecutionResponse, error) { + response, err := a.service.DiagnoseWorkflowExecution(ctx, thrift.DiagnoseWorkflowExecutionRequest(request), opts...) + return proto.DiagnoseWorkflowExecutionResponse(response), proto.Error(err) +} func (a workflowAPIthriftAdapter) QueryWorkflow(ctx context.Context, request *apiv1.QueryWorkflowRequest, opts ...yarpc.CallOption) (*apiv1.QueryWorkflowResponse, error) { response, err := a.service.QueryWorkflow(ctx, thrift.QueryWorkflowRequest(request), opts...) return proto.QueryWorkflowResponse(response), proto.Error(err) diff --git a/internal/compatibility/api_test.go b/internal/compatibility/api_test.go index 161408ac8..38a5cb2fe 100644 --- a/internal/compatibility/api_test.go +++ b/internal/compatibility/api_test.go @@ -217,6 +217,16 @@ func TestDescribeWorkflowExecutionResponse(t *testing.T) { assert.Equal(t, item, proto.DescribeWorkflowExecutionResponse(thrift.DescribeWorkflowExecutionResponse(item))) } } +func TestDiagnoseWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.DiagnoseWorkflowExecutionRequest{nil, {}, &testdata.DiagnoseWorkflowExecutionRequest} { + assert.Equal(t, item, proto.DiagnoseWorkflowExecutionRequest(thrift.DiagnoseWorkflowExecutionRequest(item))) + } +} +func TestDiagnoseWorkflowExecutionResponse(t *testing.T) { + for _, item := range []*apiv1.DiagnoseWorkflowExecutionResponse{nil, {}, &testdata.DiagnoseWorkflowExecutionResponse} { + assert.Equal(t, item, proto.DiagnoseWorkflowExecutionResponse(thrift.DiagnoseWorkflowExecutionResponse(item))) + } +} func TestExternalWorkflowExecutionCancelRequestedEventAttributes(t *testing.T) { for _, item := range []*apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{nil, {}, &testdata.ExternalWorkflowExecutionCancelRequestedEventAttributes} { assert.Equal(t, item, proto.ExternalWorkflowExecutionCancelRequestedEventAttributes(thrift.ExternalWorkflowExecutionCancelRequestedEventAttributes(item))) diff --git a/internal/compatibility/proto/request.go b/internal/compatibility/proto/request.go index 75c35fe84..495fb8a0e 100644 --- a/internal/compatibility/proto/request.go +++ b/internal/compatibility/proto/request.go @@ -88,6 +88,7 @@ func DiagnoseWorkflowExecutionRequest(t *shared.DiagnoseWorkflowExecutionRequest return &apiv1.DiagnoseWorkflowExecutionRequest{ Domain: t.GetDomain(), WorkflowExecution: WorkflowExecution(t.GetWorkflowExecution()), + Identity: t.GetIdentity(), } } diff --git a/internal/compatibility/proto/response.go b/internal/compatibility/proto/response.go index c57e473a9..64698e4d9 100644 --- a/internal/compatibility/proto/response.go +++ b/internal/compatibility/proto/response.go @@ -89,6 +89,16 @@ func DescribeWorkflowExecutionResponse(t *shared.DescribeWorkflowExecutionRespon } } +func DiagnoseWorkflowExecutionResponse(t *shared.DiagnoseWorkflowExecutionResponse) *apiv1.DiagnoseWorkflowExecutionResponse { + if t == nil { + return nil + } + return &apiv1.DiagnoseWorkflowExecutionResponse{ + Domain: t.GetDomain(), + DiagnosticWorkflowExecution: WorkflowExecution(t.DiagnosticWorkflowExecution), + } +} + func GetClusterInfoResponse(t *shared.ClusterInfo) *apiv1.GetClusterInfoResponse { if t == nil { return nil diff --git a/internal/compatibility/testdata/service.go b/internal/compatibility/testdata/service.go index df1534cc8..39658e0a2 100644 --- a/internal/compatibility/testdata/service.go +++ b/internal/compatibility/testdata/service.go @@ -382,6 +382,15 @@ var ( PendingChildren: PendingChildExecutionInfoArray, PendingDecision: &PendingDecisionInfo, } + DiagnoseWorkflowExecutionRequest = apiv1.DiagnoseWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Identity: Identity, + } + DiagnoseWorkflowExecutionResponse = apiv1.DiagnoseWorkflowExecutionResponse{ + Domain: DomainName, + DiagnosticWorkflowExecution: &WorkflowExecution, + } QueryWorkflowRequest = apiv1.QueryWorkflowRequest{ Domain: DomainName, WorkflowExecution: &WorkflowExecution, diff --git a/internal/compatibility/thrift/request.go b/internal/compatibility/thrift/request.go index 460504a06..a15de3949 100644 --- a/internal/compatibility/thrift/request.go +++ b/internal/compatibility/thrift/request.go @@ -82,6 +82,17 @@ func DescribeWorkflowExecutionRequest(t *apiv1.DescribeWorkflowExecutionRequest) } } +func DiagnoseWorkflowExecutionRequest(t *apiv1.DiagnoseWorkflowExecutionRequest) *shared.DiagnoseWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.DiagnoseWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Identity: &t.Identity, + } +} + func GetWorkflowExecutionHistoryRequest(t *apiv1.GetWorkflowExecutionHistoryRequest) *shared.GetWorkflowExecutionHistoryRequest { if t == nil { return nil