@@ -650,6 +650,39 @@ def execute(_attempt)
650650 end
651651 end
652652
653+ class CanRampingVersionWorkflowV1 < Temporalio ::Workflow ::Definition
654+ workflow_name :ContinueAsNewWithRampingVersion
655+ workflow_versioning_behavior Temporalio ::VersioningBehavior ::PINNED
656+
657+ def initialize
658+ @continue_as_new = false
659+ end
660+
661+ def execute ( attempt )
662+ return 'v1.0' if attempt . positive?
663+
664+ Temporalio ::Workflow . wait_condition { @continue_as_new }
665+ raise Temporalio ::Workflow ::ContinueAsNewError . new (
666+ attempt + 1 ,
667+ initial_versioning_behavior : Temporalio ::ContinueAsNewVersioningBehavior ::USE_RAMPING_VERSION
668+ )
669+ end
670+
671+ workflow_signal
672+ def do_continue_as_new
673+ @continue_as_new = true
674+ end
675+ end
676+
677+ class CanRampingVersionWorkflowV2 < Temporalio ::Workflow ::Definition
678+ workflow_name :ContinueAsNewWithRampingVersion
679+ workflow_versioning_behavior Temporalio ::VersioningBehavior ::PINNED
680+
681+ def execute ( _attempt )
682+ 'v2.0'
683+ end
684+ end
685+
653686 def test_continue_as_new_with_version_upgrade
654687 deployment_name = "deployment-can-upgrade-#{ SecureRandom . uuid } "
655688 worker_v1 = Temporalio ::WorkerDeploymentVersion . new (
@@ -715,6 +748,64 @@ def test_continue_as_new_with_version_upgrade
715748 end
716749 end
717750
751+ def test_continue_as_new_with_ramping_version
752+ deployment_name = "deployment-can-ramping-#{ SecureRandom . uuid } "
753+ worker_v1 = Temporalio ::WorkerDeploymentVersion . new (
754+ deployment_name : deployment_name , build_id : '1.0'
755+ )
756+ worker_v2 = Temporalio ::WorkerDeploymentVersion . new (
757+ deployment_name : deployment_name , build_id : '2.0'
758+ )
759+
760+ task_queue = "tq-#{ SecureRandom . uuid } "
761+
762+ worker1 = Temporalio ::Worker . new (
763+ client : env . client ,
764+ task_queue : task_queue ,
765+ workflows : [ CanRampingVersionWorkflowV1 ] ,
766+ deployment_options : Temporalio ::Worker ::DeploymentOptions . new (
767+ version : worker_v1 ,
768+ use_worker_versioning : true
769+ )
770+ )
771+
772+ worker2 = Temporalio ::Worker . new (
773+ client : env . client ,
774+ task_queue : task_queue ,
775+ workflows : [ CanRampingVersionWorkflowV2 ] ,
776+ deployment_options : Temporalio ::Worker ::DeploymentOptions . new (
777+ version : worker_v2 ,
778+ use_worker_versioning : true
779+ )
780+ )
781+
782+ Temporalio ::Worker . run_all ( worker1 , worker2 ) do
783+ describe_resp = wait_until_worker_deployment_visible ( env . client , worker_v1 )
784+ current_resp = set_current_deployment_version ( env . client , describe_resp . conflict_token , worker_v1 )
785+ wait_for_worker_deployment_routing_config_propagation ( env . client , deployment_name , worker_v1 . build_id )
786+
787+ handle = env . client . start_workflow (
788+ 'ContinueAsNewWithRampingVersion' ,
789+ 0 ,
790+ id : "test-can-ramping-version-#{ SecureRandom . uuid } " ,
791+ task_queue : task_queue
792+ )
793+ wait_for_workflow_running_on_version ( handle , worker_v1 . build_id )
794+
795+ wait_until_worker_deployment_visible ( env . client , worker_v2 )
796+ set_ramping_version ( env . client , current_resp . conflict_token , worker_v2 , 0.0 )
797+ wait_for_worker_deployment_routing_config_propagation (
798+ env . client ,
799+ deployment_name ,
800+ worker_v1 . build_id ,
801+ worker_v2 . build_id
802+ )
803+
804+ handle . signal ( CanRampingVersionWorkflowV1 . do_continue_as_new )
805+ assert_equal 'v2.0' , handle . result
806+ end
807+ end
808+
718809 def wait_for_workflow_running_on_version ( handle , expected_build_id )
719810 assert_eventually do
720811 desc = handle . describe
0 commit comments