Skip to content

Commit

Permalink
add test and missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng committed Dec 3, 2024
1 parent 5608f3f commit 24258b1
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/common/auth/service_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions internal/common/isolationgroup/service_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
4 changes: 4 additions & 0 deletions internal/compatibility/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions internal/compatibility/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
1 change: 1 addition & 0 deletions internal/compatibility/proto/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func DiagnoseWorkflowExecutionRequest(t *shared.DiagnoseWorkflowExecutionRequest
return &apiv1.DiagnoseWorkflowExecutionRequest{
Domain: t.GetDomain(),
WorkflowExecution: WorkflowExecution(t.GetWorkflowExecution()),
Identity: t.GetIdentity(),
}
}

Expand Down
10 changes: 10 additions & 0 deletions internal/compatibility/proto/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions internal/compatibility/testdata/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions internal/compatibility/thrift/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 24258b1

Please sign in to comment.