@@ -16,6 +16,7 @@ import (
1616 enumspb "go.temporal.io/api/enums/v1"
1717 "go.temporal.io/api/workflowservice/v1"
1818
19+ "go.temporal.io/sdk/activity"
1920 "go.temporal.io/sdk/client"
2021 "go.temporal.io/sdk/worker"
2122 "go.temporal.io/sdk/workflow"
@@ -236,6 +237,60 @@ func (ts *WorkerDeploymentTestSuite) TestBuildIDChangesOverWorkflowLifetime() {
236237 ts .Equal ("2.0" , lastBuildID )
237238}
238239
240+ func (ts * WorkerDeploymentTestSuite ) TestBuildIDWithSession () {
241+
242+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
243+ defer cancel ()
244+
245+ deploymentName := "deploy-test-" + uuid .NewString ()
246+ v1 := worker.WorkerDeploymentVersion {
247+ DeploymentName : deploymentName ,
248+ BuildID : "1.0" ,
249+ }
250+
251+ worker := worker .New (ts .client , ts .taskQueueName , worker.Options {
252+ EnableSessionWorker : true ,
253+ DeploymentOptions : worker.DeploymentOptions {
254+ UseVersioning : true ,
255+ Version : v1 ,
256+ },
257+ })
258+
259+ worker .RegisterWorkflowWithOptions (ts .workflows .BasicSession , workflow.RegisterOptions {
260+ Name : "SessionBuildIDWorkflow" ,
261+ VersioningBehavior : workflow .VersioningBehaviorAutoUpgrade ,
262+ })
263+
264+ activities2 := & Activities2 {}
265+ result := & Activities {activities2 : activities2 }
266+ activities2 .impl = result
267+ worker .RegisterActivityWithOptions (activities2 , activity.RegisterOptions {Name : "Prefix_" , DisableAlreadyRegisteredCheck : true })
268+
269+ ts .NoError (worker .Start ())
270+ defer worker .Stop ()
271+
272+ dHandle := ts .client .WorkerDeploymentClient ().GetHandle (deploymentName )
273+
274+ ts .waitForWorkerDeployment (ctx , dHandle )
275+
276+ response1 , err := dHandle .Describe (ctx , client.WorkerDeploymentDescribeOptions {})
277+ ts .NoError (err )
278+
279+ ts .waitForWorkerDeploymentVersion (ctx , dHandle , v1 )
280+
281+ _ , err = dHandle .SetCurrentVersion (ctx , client.WorkerDeploymentSetCurrentVersionOptions {
282+ BuildID : v1 .BuildID ,
283+ ConflictToken : response1 .ConflictToken ,
284+ })
285+ ts .NoError (err )
286+
287+ // start workflow1 with 1.0, BasicSession, auto-upgrade
288+ wfHandle , err := ts .client .ExecuteWorkflow (ctx , ts .startWorkflowOptions ("evolving-wf-1" ), "SessionBuildIDWorkflow" )
289+ ts .NoError (err )
290+
291+ ts .NoError (wfHandle .Get (ctx , nil ))
292+ }
293+
239294func (ts * WorkerDeploymentTestSuite ) TestPinnedBehaviorThreeWorkers () {
240295 if os .Getenv ("DISABLE_SERVER_1_27_TESTS" ) != "" {
241296 ts .T ().Skip ("temporal server 1.27+ required" )
0 commit comments