aws-codedeploy-agent 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGES.md +3 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE +177 -0
  5. data/NOTICE +2 -0
  6. data/README.md +16 -0
  7. data/aws-codedeploy-agent.gemspec +39 -0
  8. data/bin/codedeploy-agent +78 -0
  9. data/bin/codedeploy-install +15 -0
  10. data/bin/codedeploy-uninstall +13 -0
  11. data/certs/host-agent-deployment-signer-ca-chain.pem +76 -0
  12. data/conf/codedeployagent.yml +9 -0
  13. data/init.d/codedeploy-agent +61 -0
  14. data/lib/core_ext.rb +71 -0
  15. data/lib/instance_agent.rb +35 -0
  16. data/lib/instance_agent/agent/base.rb +34 -0
  17. data/lib/instance_agent/codedeploy_plugin/application_specification/ace_info.rb +133 -0
  18. data/lib/instance_agent/codedeploy_plugin/application_specification/acl_info.rb +163 -0
  19. data/lib/instance_agent/codedeploy_plugin/application_specification/application_specification.rb +142 -0
  20. data/lib/instance_agent/codedeploy_plugin/application_specification/context_info.rb +23 -0
  21. data/lib/instance_agent/codedeploy_plugin/application_specification/file_info.rb +23 -0
  22. data/lib/instance_agent/codedeploy_plugin/application_specification/linux_permission_info.rb +121 -0
  23. data/lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb +66 -0
  24. data/lib/instance_agent/codedeploy_plugin/application_specification/range_info.rb +134 -0
  25. data/lib/instance_agent/codedeploy_plugin/application_specification/script_info.rb +27 -0
  26. data/lib/instance_agent/codedeploy_plugin/codedeploy_control.rb +72 -0
  27. data/lib/instance_agent/codedeploy_plugin/command_executor.rb +357 -0
  28. data/lib/instance_agent/codedeploy_plugin/command_poller.rb +146 -0
  29. data/lib/instance_agent/codedeploy_plugin/deployment_specification.rb +150 -0
  30. data/lib/instance_agent/codedeploy_plugin/hook_executor.rb +206 -0
  31. data/lib/instance_agent/codedeploy_plugin/install_instruction.rb +374 -0
  32. data/lib/instance_agent/codedeploy_plugin/installer.rb +143 -0
  33. data/lib/instance_agent/codedeploy_plugin/request_helper.rb +28 -0
  34. data/lib/instance_agent/config.rb +43 -0
  35. data/lib/instance_agent/log.rb +3 -0
  36. data/lib/instance_agent/platform.rb +17 -0
  37. data/lib/instance_agent/platform/linux_util.rb +57 -0
  38. data/lib/instance_agent/runner/child.rb +57 -0
  39. data/lib/instance_agent/runner/master.rb +103 -0
  40. data/lib/instance_metadata.rb +47 -0
  41. data/test/certificate_helper.rb +120 -0
  42. data/test/helpers/instance_agent_helper.rb +25 -0
  43. data/test/instance_agent/agent/base_test.rb +49 -0
  44. data/test/instance_agent/codedeploy_plugin/application_specification_test.rb +1710 -0
  45. data/test/instance_agent/codedeploy_plugin/codedeploy_control_test.rb +51 -0
  46. data/test/instance_agent/codedeploy_plugin/command_executor_test.rb +513 -0
  47. data/test/instance_agent/codedeploy_plugin/command_poller_test.rb +459 -0
  48. data/test/instance_agent/codedeploy_plugin/deployment_specification_test.rb +335 -0
  49. data/test/instance_agent/codedeploy_plugin/hook_executor_test.rb +250 -0
  50. data/test/instance_agent/codedeploy_plugin/install_instruction_test.rb +566 -0
  51. data/test/instance_agent/codedeploy_plugin/installer_test.rb +519 -0
  52. data/test/instance_agent/codedeploy_plugin/request_helper_test.rb +37 -0
  53. data/test/instance_agent/config_test.rb +64 -0
  54. data/test/instance_agent/runner/child_test.rb +87 -0
  55. data/test/instance_metadata_test.rb +97 -0
  56. data/test/test_helper.rb +16 -0
  57. data/vendor/gems/.codedeploy-commands-1.0.0.created.rid +1 -0
  58. data/vendor/gems/codedeploy-commands/apis/CodeDeployCommand.api.json +372 -0
  59. data/vendor/gems/codedeploy-commands/codedeploy-commands-1.0.0.gemspec +28 -0
  60. data/vendor/gems/codedeploy-commands/lib/aws/codedeploy_commands.rb +18 -0
  61. data/vendor/gems/codedeploy-commands/lib/aws/plugins/certificate_authority.rb +12 -0
  62. data/vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_control_endpoint.rb +22 -0
  63. data/vendor/gems/process_manager/README.md +1 -0
  64. data/vendor/gems/process_manager/lib/blank.rb +153 -0
  65. data/vendor/gems/process_manager/lib/core_ext.rb +73 -0
  66. data/vendor/gems/process_manager/lib/process_manager.rb +49 -0
  67. data/vendor/gems/process_manager/lib/process_manager/child.rb +119 -0
  68. data/vendor/gems/process_manager/lib/process_manager/config.rb +112 -0
  69. data/vendor/gems/process_manager/lib/process_manager/log.rb +107 -0
  70. data/vendor/gems/process_manager/lib/process_manager/master.rb +322 -0
  71. data/vendor/gems/process_manager/process_manager-0.0.13.gemspec +42 -0
  72. data/vendor/specifications/aws-sdk-core-2.0.5.gemspec +39 -0
  73. data/vendor/specifications/builder-3.2.2.gemspec +29 -0
  74. data/vendor/specifications/codedeploy-commands-1.0.0.gemspec +28 -0
  75. data/vendor/specifications/gli-2.5.6.gemspec +51 -0
  76. data/vendor/specifications/jamespath-0.5.1.gemspec +35 -0
  77. data/vendor/specifications/little-plugger-1.1.3.gemspec +32 -0
  78. data/vendor/specifications/logging-1.8.1.gemspec +44 -0
  79. data/vendor/specifications/multi_json-1.7.7.gemspec +30 -0
  80. data/vendor/specifications/multi_json-1.8.4.gemspec +30 -0
  81. data/vendor/specifications/multi_xml-0.5.5.gemspec +30 -0
  82. data/vendor/specifications/process_manager-0.0.13.gemspec +42 -0
  83. data/vendor/specifications/simple_pid-0.2.1.gemspec +28 -0
  84. metadata +377 -0
@@ -0,0 +1,459 @@
1
+ require 'test_helper'
2
+ require 'json'
3
+
4
+ class CommandPollerTest < InstanceAgentTestCase
5
+
6
+ def gather_diagnostics_from_error(error)
7
+ {'error_code' => InstanceAgent::CodeDeployPlugin::ScriptError::UNKNOWN_ERROR_CODE, 'script_name' => "", 'message' => error.message, 'log' => ""}.to_json
8
+ end
9
+
10
+ def gather_diagnostics(script_output)
11
+ script_output ||= ""
12
+ {'error_code' => InstanceAgent::CodeDeployPlugin::ScriptError::SUCCEEDED_CODE, 'script_name' => "", 'message' => "Succeeded", 'log' => script_output}.to_json
13
+ end
14
+
15
+ context 'The command poller' do
16
+
17
+ setup do
18
+ @host_identifier = "i-123"
19
+ @aws_region = 'us-east-1'
20
+ @deploy_control_endpoint = "my-deploy-control.amazon.com"
21
+ @deploy_control_client = mock()
22
+ @deploy_control_api = mock()
23
+ @executor = stub(:execute_command => "test this is not returned",
24
+ :deployment_system => "CodeDeploy")
25
+
26
+ ENV['AWS_REGION'] = nil
27
+ InstanceMetadata.stubs(:region).returns(@aws_region)
28
+ InstanceMetadata.stubs(:host_identifier).returns(@host_identifier)
29
+
30
+ InstanceAgent::CodeDeployPlugin::CodeDeployControl.stubs(:new).
31
+ returns(@deploy_control_api)
32
+ @deploy_control_api.stubs(:get_client).
33
+ returns(@deploy_control_client)
34
+
35
+ InstanceAgent::CodeDeployPlugin::CommandExecutor.stubs(:new).
36
+ returns(@executor)
37
+
38
+ @poller = InstanceAgent::CodeDeployPlugin::CommandPoller.new
39
+ end
40
+
41
+ context 'on initializing' do
42
+
43
+ should 'construct a client using the configured region' do
44
+ InstanceAgent::CodeDeployPlugin::CodeDeployControl.expects(:new).
45
+ with(has_entries(:region => @aws_region)).
46
+ returns(@deploy_control_api)
47
+
48
+ InstanceAgent::CodeDeployPlugin::CommandPoller.new
49
+ end
50
+
51
+ should 'construct an CodeDeploy command executor' do
52
+ test_hook_mapping = { "BeforeELBRemove"=>["BeforeELBRemove"],
53
+ "AfterELBRemove"=>["AfterELBRemove"],
54
+ "ApplicationStop"=>["ApplicationStop"],
55
+ "BeforeInstall"=>["BeforeInstall"],
56
+ "AfterInstall"=>["AfterInstall"],
57
+ "ApplicationStart"=>["ApplicationStart"],
58
+ "BeforeELBAdd"=>["BeforeELBAdd"],
59
+ "AfterELBAdd"=>["AfterELBAdd"],
60
+ "ValidateService"=>["ValidateService"]}
61
+ InstanceAgent::CodeDeployPlugin::CommandExecutor.expects(:new).
62
+ with(:deploy_control_client => @deploy_control_client,
63
+ :hook_mapping => test_hook_mapping).
64
+ returns(@executor)
65
+
66
+ InstanceAgent::CodeDeployPlugin::CommandPoller.new
67
+ end
68
+
69
+ end
70
+
71
+ context 'on perform' do
72
+
73
+ setup do
74
+ @command = stub(
75
+ :host_command_identifier => "my-host-command-identifier",
76
+ :command_name => "DownloadBundle",
77
+ :host_identifier => @host_identifier,
78
+ :deployment_execution_id => "command-deployment-execution-id")
79
+ @poll_host_command_output = stub(:host_command => @command)
80
+ @poll_host_command_acknowledgement_output = stub(:command_status => "InProgress")
81
+ @deployment_specification = stub(:generic_envelope => '{"some":"json"}')
82
+ @get_deploy_specification_output = stub(
83
+ :deployment_system => "CodeDeploy",
84
+ :deployment_specification => @deployment_specification)
85
+
86
+ @poll_host_command_state = states('poll_host_command_state').
87
+ starts_as('setup')
88
+ @deploy_control_client.stubs(:poll_host_command).
89
+ returns(@poll_host_command_output).
90
+ when(@poll_host_command_state.is('setup'))
91
+
92
+ @put_host_command_acknowledgement_state = states('put_host_command_acknowledgement_state').
93
+ starts_as('setup')
94
+ @deploy_control_client.stubs(:put_host_command_acknowledgement).
95
+ returns(@poll_host_command_acknowledgement_output).
96
+ when(@put_host_command_acknowledgement_state.is('setup'))
97
+
98
+ @get_deployment_specification_state = states('get_deployment_specification_state').
99
+ starts_as('setup')
100
+ @deploy_control_client.stubs(:get_deployment_specification).
101
+ returns(@get_deploy_specification_output).
102
+ when(@get_deployment_specification_state.is('setup'))
103
+
104
+ @execute_command_state = states('execute_command_state').
105
+ starts_as('setup')
106
+ @executor.stubs(:execute_command).
107
+ when(@execute_command_state.is('setup'))
108
+
109
+ @put_host_command_complete_state = states('put_host_command_complete_state').
110
+ starts_as('setup')
111
+ @deploy_control_client.stubs(:put_host_command_complete).
112
+ when(@put_host_command_complete_state.is('setup'))
113
+ end
114
+
115
+ should 'call PollHostCommand with the current host name' do
116
+ @deploy_control_client.expects(:poll_host_command).
117
+ with(:host_identifier => @host_identifier).
118
+ returns(@poll_host_command_output)
119
+
120
+ @poller.perform
121
+ end
122
+
123
+ should 'return when no command is given by PollHostCommand' do
124
+ @deploy_control_client.expects(:poll_host_command).
125
+ with(:host_identifier => @host_identifier).
126
+ returns(stub(:host_command => nil))
127
+
128
+ @put_host_command_acknowledgement_state.become('never')
129
+ @deploy_control_client.expects(:put_host_command_acknowledgement).never.
130
+ when(@put_host_command_acknowledgement_state.is('never'))
131
+ @get_deployment_specification_state.become('never')
132
+ @deploy_control_client.expects(:get_deployment_specification).never.
133
+ when(@get_deployment_specification_state.is('never'))
134
+ @put_host_command_complete_state.become('never')
135
+ @deploy_control_client.expects(:put_host_command_complete).never.
136
+ when(@put_host_command_complete_state.is('never'))
137
+
138
+ @poller.perform
139
+ end
140
+
141
+ should 'raise expection when a different host identifier given by PollHostCommand' do
142
+ command = stub(
143
+ :host_command_identifier => "my-host-command-identifier",
144
+ :command_name => "DownloadBundle",
145
+ :host_identifier => "different-host-identifier",
146
+ :deployment_execution_id => "command-deployment-execution-id")
147
+
148
+ poll_host_command_output = stub(:host_command => command)
149
+
150
+ @deploy_control_client.expects(:poll_host_command).
151
+ with(:host_identifier => @host_identifier).
152
+ returns(poll_host_command_output)
153
+
154
+ @put_host_command_acknowledgement_state.become('never')
155
+ @deploy_control_client.expects(:put_host_command_acknowledgement).never.
156
+ when(@put_host_command_acknowledgement_state.is('never'))
157
+ @get_deployment_specification_state.become('never')
158
+ @deploy_control_client.expects(:get_deployment_specification).never.
159
+ when(@get_deployment_specification_state.is('never'))
160
+ @put_host_command_complete_state.become('never')
161
+ @deploy_control_client.expects(:put_host_command_complete).never.
162
+ when(@put_host_command_complete_state.is('never'))
163
+
164
+ assert_raise do
165
+ @poller.perform
166
+ end
167
+ end
168
+
169
+ should 'Accept a host name that is a substring of the actual host name' do
170
+ command = stub(
171
+ :host_command_identifier => "my-host-command-identifier",
172
+ :command_name => "DownloadBundle",
173
+ :host_identifier => @host_identifier[0],
174
+ :deployment_execution_id => "command-deployment-execution-id")
175
+
176
+ poll_host_command_output = stub(:host_command => command)
177
+
178
+ @deploy_control_client.expects(:poll_host_command).
179
+ with(:host_identifier => @host_identifier).
180
+ returns(poll_host_command_output)
181
+
182
+ @poller.perform
183
+ end
184
+
185
+ should 'raise exception when no command name is given by PollHostCommand' do
186
+ command = stub(
187
+ :host_command_identifier => "my-host-command-identifier",
188
+ :command_name => nil,
189
+ :host_identifier => @host_identifier,
190
+ :deployment_execution_id => "command-deployment-execution-id")
191
+
192
+ poll_host_command_output = stub(:host_command => command)
193
+
194
+ @deploy_control_client.expects(:poll_host_command).
195
+ with(:host_identifier => @host_identifier).
196
+ returns(poll_host_command_output)
197
+
198
+ @put_host_command_acknowledgement_state.become('never')
199
+ @deploy_control_client.expects(:put_host_command_acknowledgement).never.
200
+ when(@put_host_command_acknowledgement_state.is('never'))
201
+ @get_deployment_specification_state.become('never')
202
+ @deploy_control_client.expects(:get_deployment_specification).never.
203
+ when(@get_deployment_specification_state.is('never'))
204
+ @put_host_command_complete_state.become('never')
205
+ @deploy_control_client.expects(:put_host_command_complete).never.
206
+ when(@put_host_command_complete_state.is('never'))
207
+
208
+ assert_raise do
209
+ @poller.perform
210
+ end
211
+ end
212
+
213
+ should 'raise exception when empty command name is given by PollHostCommand' do
214
+ command = stub(
215
+ :host_command_identifier => "my-host-command-identifier",
216
+ :command_name => "",
217
+ :host_identifier => @host_identifier,
218
+ :deployment_execution_id => "command-deployment-execution-id")
219
+
220
+ poll_host_command_output = stub(:host_command => command)
221
+
222
+ @deploy_control_client.expects(:poll_host_command).
223
+ with(:host_identifier => @host_identifier).
224
+ returns(poll_host_command_output)
225
+
226
+ @put_host_command_acknowledgement_state.become('never')
227
+ @deploy_control_client.expects(:put_host_command_acknowledgement).never.
228
+ when(@put_host_command_acknowledgement_state.is('never'))
229
+ @get_deployment_specification_state.become('never')
230
+ @deploy_control_client.expects(:get_deployment_specification).never.
231
+ when(@get_deployment_specification_state.is('never'))
232
+ @put_host_command_complete_state.become('never')
233
+ @deploy_control_client.expects(:put_host_command_complete).never.
234
+ when(@put_host_command_complete_state.is('never'))
235
+
236
+ assert_raise do
237
+ @poller.perform
238
+ end
239
+ end
240
+
241
+ should 'allow exceptions from PollHostCommand to propagate to caller' do
242
+ @deploy_control_client.stubs(:poll_host_command).
243
+ raises("some error")
244
+
245
+ assert_raise "some error" do
246
+ @poller.perform
247
+ end
248
+ end
249
+
250
+ should 'call PollHostCommandAcknowledgement with host_command_identifier returned by PollHostCommand' do
251
+ @deploy_control_client.expects(:put_host_command_acknowledgement).
252
+ with(:diagnostics => nil,
253
+ :host_command_identifier => @command.host_command_identifier).
254
+ returns(@poll_host_command_acknowledgement_output)
255
+
256
+ @poller.perform
257
+ end
258
+
259
+ should 'return when Succeeded command status is given by PollHostCommandAcknowledgement' do
260
+ @deploy_control_client.expects(:put_host_command_acknowledgement).
261
+ with(:diagnostics => nil,
262
+ :host_command_identifier => @command.host_command_identifier).
263
+ returns(stub(:command_status => "Succeeded"))
264
+
265
+ @get_deployment_specification_state.become('never')
266
+ @deploy_control_client.expects(:get_deployment_specification).never.
267
+ when(@get_deployment_specification_state.is('never'))
268
+ @put_host_command_complete_state.become('never')
269
+ @deploy_control_client.expects(:put_host_command_complete).never.
270
+ when(@put_host_command_complete_state.is('never'))
271
+
272
+ @poller.perform
273
+ end
274
+
275
+ should 'return when Failed command status is given by PollHostCommandAcknowledgement' do
276
+ @deploy_control_client.expects(:put_host_command_acknowledgement).
277
+ with(:diagnostics => nil,
278
+ :host_command_identifier => @command.host_command_identifier).
279
+ returns(stub(:command_status => "Failed"))
280
+
281
+ @get_deployment_specification_state.become('never')
282
+ @deploy_control_client.expects(:get_deployment_specification).never.
283
+ when(@get_deployment_specification_state.is('never'))
284
+ @put_host_command_complete_state.become('never')
285
+ @deploy_control_client.expects(:put_host_command_complete).never.
286
+ when(@put_host_command_complete_state.is('never'))
287
+
288
+ @poller.perform
289
+ end
290
+
291
+ should 'call GetDeploymentSpecification with the host ID and execution ID of the command' do
292
+ @deploy_control_client.expects(:get_deployment_specification).
293
+ with(:deployment_execution_id => @command.deployment_execution_id,
294
+ :host_identifier => @host_identifier).
295
+ returns(@get_deploy_specification_output)
296
+
297
+ @poller.perform
298
+ end
299
+
300
+ should 'allow exceptions from GetDeploymentSpecification to propagate to caller' do
301
+ @deploy_control_client.expects(:get_deployment_specification).
302
+ raises("some error")
303
+
304
+ assert_raise "some error" do
305
+ @poller.perform
306
+ end
307
+ end
308
+
309
+ context 'when an empty deployment system is given by GetDeploymentSpecification' do
310
+
311
+ setup do
312
+ @get_deploy_specification_output.stubs(:deployment_system).
313
+ returns("")
314
+ end
315
+
316
+ should 'not dispatch the command to the command executor' do
317
+ @execute_command_state.become('never')
318
+ @executor.expects(:execute_command).never.
319
+ when(@execute_command_state.is('never'))
320
+
321
+ assert_raise do
322
+ @poller.perform
323
+ end
324
+ end
325
+
326
+ should 'call put_host_command_complete with a status of Failed' do
327
+
328
+ @deploy_control_client.expects(:put_host_command_complete).
329
+ with(:command_status => "Failed",
330
+ :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_error(RuntimeError.new("Deployment System mismatch: CodeDeploy != "))},
331
+ :host_command_identifier => @command.host_command_identifier)
332
+
333
+ assert_raise do
334
+ @poller.perform
335
+ end
336
+ end
337
+
338
+ end
339
+
340
+ context 'when the wrong deployment system is given by GetDeploymentSpecification' do
341
+
342
+ setup do
343
+ @get_deploy_specification_output.stubs(:deployment_system).
344
+ returns("WackyDeployer")
345
+ end
346
+
347
+ should 'not dispatch the command to the command executor' do
348
+ @execute_command_state.become('never')
349
+ @executor.expects(:execute_command).never.
350
+ when(@execute_command_state.is('never'))
351
+
352
+ assert_raise do
353
+ @poller.perform
354
+ end
355
+ end
356
+
357
+ should 'call put_host_command_complete with a status of Failed' do
358
+ @deploy_control_client.expects(:put_host_command_complete).
359
+ with(:command_status => "Failed",
360
+ :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_error(RuntimeError.new("Deployment System mismatch: CodeDeploy != WackyDeployer"))},
361
+ :host_command_identifier => @command.host_command_identifier)
362
+
363
+ assert_raise do
364
+ @poller.perform
365
+ end
366
+ end
367
+
368
+ end
369
+
370
+ context 'when no deployment specification is given by GetDeploymentSpecification' do
371
+
372
+ setup do
373
+ @get_deploy_specification_output.stubs(:deployment_specification).
374
+ returns(nil)
375
+ end
376
+
377
+ should 'not dispatch the command to the command executor' do
378
+ @execute_command_state.become('never')
379
+ @executor.expects(:execute_command).never.
380
+ when(@execute_command_state.is('never'))
381
+
382
+ assert_raise do
383
+ @poller.perform
384
+ end
385
+ end
386
+
387
+ should 'call PutHostCommandComplete with a status of Failed' do
388
+ @deploy_control_client.expects(:put_host_command_complete).
389
+ with(:command_status => "Failed",
390
+ :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_error(RuntimeError.new("Deployment Specification missing"))},
391
+ :host_command_identifier => @command.host_command_identifier)
392
+
393
+ assert_raise do
394
+ @poller.perform
395
+ end
396
+ end
397
+
398
+ end
399
+
400
+ should 'dispatch the command to the command executor' do
401
+ @executor.expects(:execute_command).
402
+ with(@command, @deployment_specification.generic_envelope)
403
+
404
+ @poller.perform
405
+ end
406
+
407
+ should 'allow exceptions from execute_command to propagate to caller' do
408
+ @executor.expects(:execute_command).
409
+ raises("some error")
410
+
411
+ @deploy_control_client.expects(:put_host_command_complete).
412
+ with(:command_status => "Failed",
413
+ :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_error(RuntimeError.new("some error"))},
414
+ :host_command_identifier => @command.host_command_identifier)
415
+
416
+ assert_raise "some error" do
417
+ @poller.perform
418
+ end
419
+ end
420
+
421
+ should 'allow script errors from execute_command to propagate diagnostic information to caller' do
422
+ begin
423
+ script_log = InstanceAgent::CodeDeployPlugin::ScriptLog.new
424
+ script_log.append_to_log("log entries")
425
+ raise InstanceAgent::CodeDeployPlugin::ScriptError.new(InstanceAgent::CodeDeployPlugin::ScriptError::SCRIPT_FAILED_CODE, "file_location", script_log), 'message'
426
+ rescue InstanceAgent::CodeDeployPlugin::ScriptError => e
427
+ script_error = e
428
+ end
429
+
430
+ @executor.expects(:execute_command).
431
+ raises(script_error)
432
+
433
+ @deploy_control_client.expects(:put_host_command_complete).
434
+ with(:command_status => "Failed",
435
+ :diagnostics => {:format => "JSON", :payload => script_error.to_json},
436
+ :host_command_identifier => @command.host_command_identifier)
437
+
438
+ assert_raise script_error do
439
+ @poller.perform
440
+ end
441
+ end
442
+
443
+ should 'complete the command when the command executor successfully processes the command' do
444
+ @executor.expects(:execute_command).
445
+ with(@command, @deployment_specification.generic_envelope)
446
+
447
+ @deploy_control_client.expects(:put_host_command_complete).
448
+ with(:command_status => "Succeeded",
449
+ :diagnostics => {:format => "JSON", :payload => gather_diagnostics("")},
450
+ :host_command_identifier => @command.host_command_identifier)
451
+
452
+ @poller.perform
453
+ end
454
+
455
+ end
456
+
457
+ end
458
+
459
+ end