@@ -47,6 +47,8 @@ def generate_signed_message_for(map)
4747 @deployment_group_name = "TestDeploymentGroup"
4848 @application_name = "TestApplicationName"
4949 @deployment_group_id = "foo"
50+ @deployment_creator = "User"
51+ @deployment_type = "IN_PLACE"
5052 @s3Revision = {
5153 "Bucket" => "mybucket" ,
5254 "Key" => "mykey" ,
@@ -57,6 +59,8 @@ def generate_signed_message_for(map)
5759 "DeploymentGroupId" => @deployment_group_id ,
5860 "ApplicationName" => @application_name ,
5961 "DeploymentGroupName" => @deployment_group_name ,
62+ "DeploymentCreator" => @deployment_creator ,
63+ "DeploymentType" => @deployment_type ,
6064 "Revision" => {
6165 "RevisionType" => "S3" ,
6266 "S3Revision" => @s3Revision
@@ -73,7 +77,8 @@ def generate_signed_message_for(map)
7377
7478 FileUtils . stubs ( :mkdir_p )
7579 File . stubs ( :directory? ) . with ( @deployment_root_dir ) . returns ( true )
76- @previous_install_file_location = File . join ( @deployment_instructions_dir , "#{ @deployment_group_id } _last_successful_install" )
80+ @last_successful_install_file_location = File . join ( @deployment_instructions_dir , "#{ @deployment_group_id } _last_successful_install" )
81+ @most_recent_install_file_location = File . join ( @deployment_instructions_dir , "#{ @deployment_group_id } _most_recent_install" )
7782 end
7883
7984 context "when executing an unknown command" do
@@ -130,10 +135,11 @@ def generate_signed_message_for(map)
130135 InstanceAgent ::Plugins ::CodeDeployPlugin ::ApplicationSpecification ::ApplicationSpecification . stubs ( :parse ) . returns ( @app_spec )
131136 @installer = stub ( "installer" , :install => nil )
132137 Installer . stubs ( :new ) . returns ( @installer )
133- File . stubs ( :exist? ) . with ( @previous_install_file_location ) . returns ( true )
138+ File . stubs ( :directory? ) . with ( @deployment_instructions_dir ) . returns ( true )
139+ File . stubs ( :exist? ) . with ( @last_successful_install_file_location ) . returns ( true )
134140 File . stubs ( :exist? ) . with ( @archive_root_dir ) . returns ( true )
135- File . stubs ( :open ) . with ( @previous_install_file_location , 'w+' )
136- File . stubs ( :open ) . with ( @previous_install_file_location )
141+ File . stubs ( :open ) . with ( @last_successful_install_file_location , 'w+' )
142+ File . stubs ( :open ) . with ( @last_successful_install_file_location )
137143
138144 @app_spec = mock ( "parsed application specification" )
139145 File .
@@ -143,12 +149,6 @@ def generate_signed_message_for(map)
143149 ApplicationSpecification ::ApplicationSpecification . stubs ( :parse ) . with ( "APP SPEC" ) . returns ( @app_spec )
144150 end
145151
146- should "idempotently create the instructions directory" do
147- FileUtils . expects ( :mkdir_p ) . with ( @deployment_instructions_dir )
148-
149- @command_executor . execute_command ( @command , @deployment_spec )
150- end
151-
152152 should "create an appropriate Installer" do
153153 Installer .
154154 expects ( :new ) .
@@ -167,7 +167,7 @@ def generate_signed_message_for(map)
167167
168168 should "write the archive root dir to the install instructions file" do
169169 mock_file = mock
170- File . expects ( :open ) . with ( @previous_install_file_location , 'w+' ) . yields ( mock_file )
170+ File . expects ( :open ) . with ( @last_successful_install_file_location , 'w+' ) . yields ( mock_file )
171171 mock_file . expects ( :write ) . with ( @deployment_root_dir )
172172
173173 @command_executor . execute_command ( @command , @deployment_spec )
@@ -355,6 +355,20 @@ def generate_signed_message_for(map)
355355 InstanceAgent ::LinuxUtil . expects ( :extract_tar ) . in_sequence ( call_sequence )
356356 @command_executor . execute_command ( @command , @deployment_spec )
357357 end
358+
359+ should "idempotently create the instructions directory" do
360+ FileUtils . expects ( :mkdir_p ) . with ( @deployment_instructions_dir )
361+
362+ @command_executor . execute_command ( @command , @deployment_spec )
363+ end
364+
365+ should "write the archive root dir to the install instructions file" do
366+ mock_file = mock
367+ File . expects ( :open ) . with ( @most_recent_install_file_location , 'w+' ) . yields ( mock_file )
368+ mock_file . expects ( :write ) . with ( @deployment_root_dir )
369+
370+ @command_executor . execute_command ( @command , @deployment_spec )
371+ end
358372 end
359373
360374 context "I have an empty app spec (for script mapping)" do
@@ -366,8 +380,11 @@ def generate_signed_message_for(map)
366380 :deployment_id => @deployment_id ,
367381 :deployment_group_name => @deployment_group_name ,
368382 :deployment_group_id => @deployment_group_id ,
383+ :deployment_creator => @deployment_creator ,
384+ :deployment_type => @deployment_type ,
369385 :deployment_root_dir => @deployment_root_dir ,
370386 :last_successful_deployment_dir => nil ,
387+ :most_recent_deployment_dir => nil ,
371388 :app_spec_path => 'appspec.yml' }
372389 @mock_hook_executor = mock
373390 end
@@ -505,7 +522,10 @@ def generate_signed_message_for(map)
505522 :deployment_id => @deployment_id ,
506523 :deployment_group_name => @deployment_group_name ,
507524 :deployment_group_id => @deployment_group_id ,
525+ :deployment_creator => @deployment_creator ,
526+ :deployment_type => @deployment_type ,
508527 :last_successful_deployment_dir => nil ,
528+ :most_recent_deployment_dir => nil ,
509529 :app_spec_path => 'appspec.yml' }
510530 @hook_executor_constructor_hash_1 = hook_executor_constructor_hash . merge ( { :lifecycle_event => "lifecycle_event_1" } )
511531 @hook_executor_constructor_hash_2 = hook_executor_constructor_hash . merge ( { :lifecycle_event => "lifecycle_event_2" } )
@@ -522,12 +542,11 @@ def generate_signed_message_for(map)
522542
523543 context "when the first script is forced to fail" do
524544 setup do
525- HookExecutor . stubs ( :new ) . with ( @hook_executor_constructor_hash_1 ) . raises ( "failed to create hook caommand" )
526-
545+ HookExecutor . stubs ( :new ) . with ( @hook_executor_constructor_hash_1 ) . raises ( "failed to create hook command" )
527546 end
528547
529- should "calls lifecycle event 1 and fails but not 2" do
530- assert_raised_with_message ( 'failed to create hook caommand ' ) do
548+ should "calls lifecycle event 1 and fails but not lifecycle event 2" do
549+ assert_raised_with_message ( 'failed to create hook command ' ) do
531550 @command_executor . execute_command ( @command , @deployment_spec )
532551 end
533552 HookExecutor . expects ( :new ) . with ( @hook_executor_constructor_hash_2 ) . never
0 commit comments