Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/temporalcli/commands.workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *TemporalWorkflowUpdateOptionsCommand) run(cctx *CommandContext, args []
}

if c.VersioningOverrideBehavior.Value == "pinned" {
if c.VersioningOverrideDeploymentName == "" && c.VersioningOverrideBuildId == "" {
if c.VersioningOverrideDeploymentName == "" || c.VersioningOverrideBuildId == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message and the command help text make me think that requiring both flags was the intention all along.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we definitely should not allow deployment name without a build id, which is what the && condition allows

return fmt.Errorf("missing deployment name and/or build id with 'pinned' behavior")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.temporal.io/api/enums/v1"
"go.temporal.io/api/workflowservice/v1"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/worker"
"go.temporal.io/sdk/workflow"
)

Expand Down Expand Up @@ -104,13 +106,14 @@ func (s *SharedServerSuite) TestWorkflow_ResetWithWorkflowUpdateOptions_Single_P
wfExecutions++
return "result", nil
})
testTaskQueue := s.Worker().Options.TaskQueue

// Start the workflow
searchAttr := "keyword-" + uuid.NewString()
run, err := s.Client.ExecuteWorkflow(
s.Context,
client.StartWorkflowOptions{
TaskQueue: s.Worker().Options.TaskQueue,
TaskQueue: testTaskQueue,
SearchAttributes: map[string]any{"CustomKeywordField": searchAttr},
},
DevWorkflow,
Expand All @@ -124,6 +127,34 @@ func (s *SharedServerSuite) TestWorkflow_ResetWithWorkflowUpdateOptions_Single_P
// Reset with pinned versioning behavior and properly formatted version
pinnedDeploymentName := "test-deployment"
pinnedBuildId := "v1.0"

// Start a versioned worker polling v1.0 to create the version
w1 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Version: worker.WorkerDeploymentVersion{
DeploymentName: pinnedDeploymentName,
BuildID: pinnedBuildId,
},
DefaultVersioningBehavior: workflow.VersioningBehaviorPinned,
},
},
TaskQueue: testTaskQueue,
})
defer w1.Stop()

// Wait for the version to exist
s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
"worker", "deployment", "describe-version",
"--address", s.Address(),
"--deployment-name", pinnedDeploymentName,
"--build-id", pinnedBuildId,
)
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

res := s.Execute(
"workflow", "reset", "with-workflow-update-options",
"--address", s.Address(),
Expand Down Expand Up @@ -209,13 +240,14 @@ func (s *SharedServerSuite) TestWorkflow_ResetBatchWithWorkflowUpdateOptions_Pin
wfExecutions++
return "result", nil
})
testTaskQueue := s.Worker().Options.TaskQueue

// Start the workflow
searchAttr := "keyword-" + uuid.NewString()
run, err := s.Client.ExecuteWorkflow(
s.Context,
client.StartWorkflowOptions{
TaskQueue: s.Worker().Options.TaskQueue,
TaskQueue: testTaskQueue,
SearchAttributes: map[string]any{"CustomKeywordField": searchAttr},
},
DevWorkflow,
Expand All @@ -229,6 +261,33 @@ func (s *SharedServerSuite) TestWorkflow_ResetBatchWithWorkflowUpdateOptions_Pin
// Reset batch with pinned versioning behavior and properly formatted version
pinnedDeploymentName := "batch-deployment"
pinnedBuildId := "v1.0"
// Start a versioned worker polling v1.0 to create the version
w1 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Version: worker.WorkerDeploymentVersion{
DeploymentName: pinnedDeploymentName,
BuildID: pinnedBuildId,
},
DefaultVersioningBehavior: workflow.VersioningBehaviorPinned,
},
},
TaskQueue: testTaskQueue,
})
defer w1.Stop()

// Wait for the version to exist
s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
"worker", "deployment", "describe-version",
"--address", s.Address(),
"--deployment-name", pinnedDeploymentName,
"--build-id", pinnedBuildId,
)
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

s.CommandHarness.Stdin.WriteString("y\n")
res := s.Execute(
"workflow", "reset", "with-workflow-update-options",
Expand Down
74 changes: 62 additions & 12 deletions internal/temporalcli/commands.workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,9 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() {
}

func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Override() {
buildId1 := uuid.NewString()
buildId2 := "bid2-" + uuid.NewString()
buildId1 := "id1-" + uuid.NewString()
buildId2 := "id2-" + uuid.NewString()
testTaskQueue := uuid.NewString()
deploymentName := uuid.NewString()
version1 := worker.WorkerDeploymentVersion{
DeploymentName: deploymentName,
Expand All @@ -485,7 +486,7 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid
ctx.Done().Receive(ctx, nil)
return ctx.Err()
}
w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
w1 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Expand All @@ -494,8 +495,22 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid
},
},
Workflows: []any{waitingWorkflow},
TaskQueue: testTaskQueue,
})
defer w.Stop()
defer w1.Stop()

w2 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Version: version2,
DefaultVersioningBehavior: workflow.VersioningBehaviorPinned,
},
},
Workflows: []any{waitingWorkflow},
TaskQueue: testTaskQueue,
})
defer w2.Stop()

s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
Expand All @@ -516,6 +531,16 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
"worker", "deployment", "describe-version",
"--address", s.Address(),
"--deployment-name", version2.DeploymentName,
"--build-id", version2.BuildID,
)
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

res := s.Execute(
"worker", "deployment", "set-current-version",
"--address", s.Address(),
Expand All @@ -533,7 +558,7 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid
run, err := s.Client.ExecuteWorkflow(
s.Context,
client.StartWorkflowOptions{
TaskQueue: w.Options.TaskQueue,
TaskQueue: w1.Options.TaskQueue,
SearchAttributes: map[string]any{"CustomKeywordField": searchAttr},
},
waitingWorkflow,
Expand Down Expand Up @@ -609,8 +634,9 @@ func (s *SharedServerSuite) TestWorkflow_Batch_Update_Options_Versioning_Overrid
}

func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
buildId1 := uuid.NewString()
buildId2 := uuid.NewString()
buildId1 := "id1-" + uuid.NewString()
buildId2 := "id2-" + uuid.NewString()
testTaskQueue := uuid.NewString()
buildId3 := "id3-" + uuid.NewString()
deploymentName := uuid.NewString()
version1 := worker.WorkerDeploymentVersion{
Expand All @@ -627,7 +653,7 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
ctx.Done().Receive(ctx, nil)
return ctx.Err()
}
w := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
w1 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Expand All @@ -636,8 +662,22 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
},
},
Workflows: []any{waitingWorkflow},
TaskQueue: testTaskQueue,
})
defer w.Stop()
defer w1.Stop()

w2 := s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{
Worker: worker.Options{
DeploymentOptions: worker.DeploymentOptions{
UseVersioning: true,
Version: version2,
DefaultVersioningBehavior: workflow.VersioningBehaviorPinned,
},
},
Workflows: []any{waitingWorkflow},
TaskQueue: testTaskQueue,
})
defer w2.Stop()

s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
Expand All @@ -658,6 +698,16 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

s.EventuallyWithT(func(t *assert.CollectT) {
res := s.Execute(
"worker", "deployment", "describe-version",
"--address", s.Address(),
"--deployment-name", version2.DeploymentName,
"--build-id", version2.BuildID,
)
assert.NoError(t, res.Err)
}, 30*time.Second, 100*time.Millisecond)

res := s.Execute(
"worker", "deployment", "set-current-version",
"--address", s.Address(),
Expand All @@ -670,7 +720,7 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
// Start the workflow and wait until the operation is started.
run, err := s.Client.ExecuteWorkflow(
s.Context,
client.StartWorkflowOptions{TaskQueue: w.Options.TaskQueue},
client.StartWorkflowOptions{TaskQueue: w1.Options.TaskQueue},
waitingWorkflow,
)
s.NoError(err)
Expand Down Expand Up @@ -716,7 +766,7 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
"--versioning-override-behavior", "pinned",
"--versioning-override-build-id", buildId3,
)
s.NoError(res.Err)
s.ErrorContains(res.Err, "missing deployment name and/or build id with 'pinned' behavior")

res = s.Execute(
"workflow", "describe",
Expand All @@ -726,7 +776,7 @@ func (s *SharedServerSuite) TestWorkflow_Update_Options_Versioning_Override() {
s.NoError(res.Err)

s.ContainsOnSameLine(res.Stdout.String(), "OverrideBehavior", "Pinned")
s.ContainsOnSameLine(res.Stdout.String(), "OverridePinnedVersionBuildId", buildId3)
s.ContainsOnSameLine(res.Stdout.String(), "OverridePinnedVersionBuildId", buildId2)

// remove override
res = s.Execute(
Expand Down