Skip to content

Commit

Permalink
add functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlydf committed Nov 26, 2024
1 parent 58cb978 commit 4c31b25
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
1 change: 1 addition & 0 deletions service/history/api/signalwithstartworkflow/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func ConvertToStartRequest(
WorkflowStartDelay: request.GetWorkflowStartDelay(),
UserMetadata: request.UserMetadata,
Links: request.GetLinks(),
VersioningOverride: request.GetVersioningOverride(),
}

return common.CreateHistoryStartWorkflowRequest(namespaceID.String(), req, nil, nil, now)
Expand Down
138 changes: 138 additions & 0 deletions tests/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,3 +908,141 @@ func (d *DeploymentSuite) TestUpdateWorkflowExecutionOptions_SetPinnedSetUnpinne
versioningInfo = descResp.GetWorkflowExecutionInfo().GetVersioningInfo()
d.True(proto.Equal(unpinnedOpts.GetVersioningOverride(), versioningInfo.GetVersioningOverride()))
}

func (d *DeploymentSuite) TestStartWorkflowExecution_WithPinnedOverride() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
override := &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_PINNED,
Deployment: &deploymentpb.Deployment{
SeriesName: "seriesName",
BuildId: "A",
},
}

resp, err := d.FrontendClient().StartWorkflowExecution(ctx, &workflowservice.StartWorkflowExecutionRequest{
Namespace: d.Namespace(),
WorkflowId: "test-workflow-id",
WorkflowType: &commonpb.WorkflowType{Name: "test-wf-type"},
TaskQueue: &taskqueuepb.TaskQueue{Name: "test-tq", Kind: enumspb.TASK_QUEUE_KIND_NORMAL},
Identity: "test-id",
RequestId: "test-request-id",
VersioningOverride: override,
})

d.NoError(err)
d.True(resp.GetStarted())

descResp, err := d.FrontendClient().DescribeWorkflowExecution(ctx, &workflowservice.DescribeWorkflowExecutionRequest{
Namespace: d.Namespace(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: "test-workflow-id",
RunId: resp.GetRunId(),
},
})
d.NoError(err)
d.True(proto.Equal(override, descResp.GetWorkflowExecutionInfo().GetVersioningInfo().GetVersioningOverride()))
}

func (d *DeploymentSuite) TestStartWorkflowExecution_WithUnpinnedOverride() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
override := &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE,
Deployment: nil,
}

resp, err := d.FrontendClient().StartWorkflowExecution(ctx, &workflowservice.StartWorkflowExecutionRequest{
Namespace: d.Namespace(),
WorkflowId: "test-workflow-id",
WorkflowType: &commonpb.WorkflowType{Name: "test-wf-type"},
TaskQueue: &taskqueuepb.TaskQueue{Name: "test-tq", Kind: enumspb.TASK_QUEUE_KIND_NORMAL},
Identity: "test-id",
RequestId: "test-request-id",
VersioningOverride: override,
})

d.NoError(err)
d.True(resp.GetStarted())

descResp, err := d.FrontendClient().DescribeWorkflowExecution(ctx, &workflowservice.DescribeWorkflowExecutionRequest{
Namespace: d.Namespace(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: "test-workflow-id",
RunId: resp.GetRunId(),
},
})
d.NoError(err)
d.True(proto.Equal(override, descResp.GetWorkflowExecutionInfo().GetVersioningInfo().GetVersioningOverride()))
}

func (d *DeploymentSuite) TestSignalWithStartWorkflowExecution_WithPinnedOverride() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
override := &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_PINNED,
Deployment: &deploymentpb.Deployment{
SeriesName: "seriesName",
BuildId: "A",
},
}

resp, err := d.FrontendClient().SignalWithStartWorkflowExecution(ctx, &workflowservice.SignalWithStartWorkflowExecutionRequest{
Namespace: d.Namespace(),
WorkflowId: "test-workflow-id",
WorkflowType: &commonpb.WorkflowType{Name: "test-wf-type"},
TaskQueue: &taskqueuepb.TaskQueue{Name: "test-tq", Kind: enumspb.TASK_QUEUE_KIND_NORMAL},
Identity: "test-id",
RequestId: "test-request-id",
SignalName: "test-signal",
SignalInput: nil,
VersioningOverride: override,
})

d.NoError(err)
d.True(resp.GetStarted())

descResp, err := d.FrontendClient().DescribeWorkflowExecution(ctx, &workflowservice.DescribeWorkflowExecutionRequest{
Namespace: d.Namespace(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: "test-workflow-id",
RunId: resp.GetRunId(),
},
})
d.NoError(err)
d.True(proto.Equal(override, descResp.GetWorkflowExecutionInfo().GetVersioningInfo().GetVersioningOverride()))
}

func (d *DeploymentSuite) TestSignalWithStartWorkflowExecution_WithUnpinnedOverride() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
override := &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE,
Deployment: nil,
}

resp, err := d.FrontendClient().SignalWithStartWorkflowExecution(ctx, &workflowservice.SignalWithStartWorkflowExecutionRequest{
Namespace: d.Namespace(),
WorkflowId: "test-workflow-id",
WorkflowType: &commonpb.WorkflowType{Name: "test-wf-type"},
TaskQueue: &taskqueuepb.TaskQueue{Name: "test-tq", Kind: enumspb.TASK_QUEUE_KIND_NORMAL},
Identity: "test-id",
RequestId: "test-request-id",
SignalName: "test-signal",
SignalInput: nil,
VersioningOverride: override,
})

d.NoError(err)
d.True(resp.GetStarted())

descResp, err := d.FrontendClient().DescribeWorkflowExecution(ctx, &workflowservice.DescribeWorkflowExecutionRequest{
Namespace: d.Namespace(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: "test-workflow-id",
RunId: resp.GetRunId(),
},
})
d.NoError(err)
d.True(proto.Equal(override, descResp.GetWorkflowExecutionInfo().GetVersioningInfo().GetVersioningOverride()))
}

0 comments on commit 4c31b25

Please sign in to comment.