aws-codedeploy-agent 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/aws-codedeploy-agent.gemspec +5 -5
  2. data/certs/host-agent-deployment-signer-ca-chain.pem +30 -0
  3. data/conf/codedeployagent.yml +0 -1
  4. data/lib/instance_agent.rb +1 -13
  5. data/lib/instance_agent/agent/base.rb +38 -12
  6. data/lib/instance_agent/agent/plugin.rb +21 -0
  7. data/lib/instance_agent/config.rb +2 -1
  8. data/lib/instance_agent/platform/linux_util.rb +4 -0
  9. data/lib/instance_agent/plugins/codedeploy/application_specification/ace_info.rb +133 -0
  10. data/lib/instance_agent/plugins/codedeploy/application_specification/acl_info.rb +163 -0
  11. data/lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb +143 -0
  12. data/lib/instance_agent/plugins/codedeploy/application_specification/context_info.rb +23 -0
  13. data/lib/instance_agent/plugins/codedeploy/application_specification/file_info.rb +23 -0
  14. data/lib/instance_agent/plugins/codedeploy/application_specification/linux_permission_info.rb +121 -0
  15. data/lib/instance_agent/plugins/codedeploy/application_specification/mode_info.rb +66 -0
  16. data/lib/instance_agent/plugins/codedeploy/application_specification/range_info.rb +134 -0
  17. data/lib/instance_agent/plugins/codedeploy/application_specification/script_info.rb +27 -0
  18. data/lib/instance_agent/plugins/codedeploy/codedeploy_control.rb +100 -0
  19. data/lib/instance_agent/plugins/codedeploy/command_executor.rb +359 -0
  20. data/lib/instance_agent/plugins/codedeploy/command_poller.rb +178 -0
  21. data/lib/instance_agent/plugins/codedeploy/deployment_specification.rb +161 -0
  22. data/lib/instance_agent/plugins/codedeploy/hook_executor.rb +226 -0
  23. data/lib/instance_agent/plugins/codedeploy/install_instruction.rb +389 -0
  24. data/lib/instance_agent/plugins/codedeploy/installer.rb +147 -0
  25. data/lib/instance_agent/plugins/codedeploy/onpremise_config.rb +42 -0
  26. data/lib/instance_agent/plugins/codedeploy/register_plugin.rb +17 -0
  27. data/lib/instance_agent/runner/child.rb +20 -5
  28. data/lib/instance_agent/runner/master.rb +2 -15
  29. data/lib/instance_metadata.rb +2 -2
  30. data/test/certificate_helper.rb +1 -1
  31. data/test/helpers/instance_agent_helper.rb +1 -0
  32. data/test/instance_agent/agent/base_test.rb +16 -3
  33. data/test/instance_agent/config_test.rb +2 -1
  34. data/test/instance_agent/plugins/codedeploy/application_specification_test.rb +1713 -0
  35. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/codedeploy_control_test.rb +1 -1
  36. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/command_executor_test.rb +32 -9
  37. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/command_poller_test.rb +13 -14
  38. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/deployment_specification_test.rb +98 -25
  39. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/hook_executor_test.rb +83 -15
  40. data/test/instance_agent/plugins/codedeploy/install_instruction_test.rb +568 -0
  41. data/test/instance_agent/{codedeploy_plugin → plugins/codedeploy}/installer_test.rb +12 -9
  42. data/test/instance_agent/plugins/codedeploy/onpremise_config_test.rb +72 -0
  43. data/test/instance_agent/runner/child_test.rb +1 -1
  44. data/vendor/gems/.codedeploy-commands-1.0.0.created.rid +1 -1
  45. data/vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_control_endpoint.rb +4 -0
  46. data/vendor/gems/jmespath-1.0.1/lib/jmespath.rb +41 -0
  47. data/vendor/gems/jmespath-1.0.1/lib/jmespath/caching_parser.rb +30 -0
  48. data/vendor/gems/jmespath-1.0.1/lib/jmespath/errors.rb +17 -0
  49. data/vendor/gems/jmespath-1.0.1/lib/jmespath/expr_node.rb +15 -0
  50. data/vendor/gems/jmespath-1.0.1/lib/jmespath/lexer.rb +116 -0
  51. data/vendor/gems/jmespath-1.0.1/lib/jmespath/parser.rb +347 -0
  52. data/vendor/gems/jmespath-1.0.1/lib/jmespath/runtime.rb +71 -0
  53. data/vendor/gems/jmespath-1.0.1/lib/jmespath/token.rb +41 -0
  54. data/vendor/gems/jmespath-1.0.1/lib/jmespath/token_stream.rb +60 -0
  55. data/vendor/gems/jmespath-1.0.1/lib/jmespath/tree_interpreter.rb +523 -0
  56. data/vendor/gems/jmespath-1.0.1/lib/jmespath/version.rb +3 -0
  57. data/vendor/gems/process_manager/lib/process_manager/master.rb +16 -5
  58. data/vendor/specifications/{aws-sdk-core-2.0.5.gemspec → aws-sdk-core-2.0.42.gemspec} +9 -11
  59. data/vendor/specifications/builder-3.2.2.gemspec +1 -1
  60. data/vendor/specifications/codedeploy-commands-1.0.0.gemspec +7 -6
  61. data/vendor/specifications/gli-2.5.6.gemspec +1 -1
  62. data/vendor/specifications/jmespath-1.0.1.gemspec +29 -0
  63. data/vendor/specifications/little-plugger-1.1.3.gemspec +1 -1
  64. data/vendor/specifications/logging-1.8.1.gemspec +1 -1
  65. data/vendor/specifications/multi_json-1.7.7.gemspec +1 -1
  66. data/vendor/specifications/multi_json-1.8.4.gemspec +1 -1
  67. data/vendor/specifications/multi_xml-0.5.5.gemspec +1 -1
  68. data/vendor/specifications/process_manager-0.0.13.gemspec +1 -1
  69. data/vendor/specifications/simple_pid-0.2.1.gemspec +1 -1
  70. metadata +76 -63
  71. data/lib/instance_agent/codedeploy_plugin/application_specification/ace_info.rb +0 -133
  72. data/lib/instance_agent/codedeploy_plugin/application_specification/acl_info.rb +0 -163
  73. data/lib/instance_agent/codedeploy_plugin/application_specification/application_specification.rb +0 -142
  74. data/lib/instance_agent/codedeploy_plugin/application_specification/context_info.rb +0 -23
  75. data/lib/instance_agent/codedeploy_plugin/application_specification/file_info.rb +0 -23
  76. data/lib/instance_agent/codedeploy_plugin/application_specification/linux_permission_info.rb +0 -121
  77. data/lib/instance_agent/codedeploy_plugin/application_specification/mode_info.rb +0 -66
  78. data/lib/instance_agent/codedeploy_plugin/application_specification/range_info.rb +0 -134
  79. data/lib/instance_agent/codedeploy_plugin/application_specification/script_info.rb +0 -27
  80. data/lib/instance_agent/codedeploy_plugin/codedeploy_control.rb +0 -72
  81. data/lib/instance_agent/codedeploy_plugin/command_executor.rb +0 -357
  82. data/lib/instance_agent/codedeploy_plugin/command_poller.rb +0 -170
  83. data/lib/instance_agent/codedeploy_plugin/deployment_specification.rb +0 -150
  84. data/lib/instance_agent/codedeploy_plugin/hook_executor.rb +0 -206
  85. data/lib/instance_agent/codedeploy_plugin/install_instruction.rb +0 -374
  86. data/lib/instance_agent/codedeploy_plugin/installer.rb +0 -143
  87. data/lib/instance_agent/codedeploy_plugin/request_helper.rb +0 -28
  88. data/test/instance_agent/codedeploy_plugin/application_specification_test.rb +0 -1710
  89. data/test/instance_agent/codedeploy_plugin/install_instruction_test.rb +0 -566
  90. data/test/instance_agent/codedeploy_plugin/request_helper_test.rb +0 -37
  91. data/vendor/specifications/jamespath-0.5.1.gemspec +0 -35
@@ -2,7 +2,7 @@ require 'instance_metadata'
2
2
 
3
3
  class CodeDeployControlTest < InstanceAgentTestCase
4
4
 
5
- include InstanceAgent::CodeDeployPlugin
5
+ include InstanceAgent::Plugins::CodeDeployPlugin
6
6
 
7
7
  context "The CodeDeploy interface client" do
8
8
 
@@ -1,12 +1,11 @@
1
1
  require 'test_helper'
2
2
  require 'stringio'
3
- require 'instance_agent/codedeploy_plugin/installer'
4
3
  require 'com/amazon/codedeploy/command/v20141006/host_command_instance'
5
4
  require 'aws-sdk-core/s3'
6
5
 
7
6
  class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
8
7
 
9
- include InstanceAgent::CodeDeployPlugin
8
+ include InstanceAgent::Plugins::CodeDeployPlugin
10
9
 
11
10
  context 'The CodeDeploy Plugin Command Executor' do
12
11
  setup do
@@ -20,7 +19,7 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
20
19
  "AfterELBAdd"=>["AfterELBAdd"],
21
20
  "ValidateService"=>["ValidateService"]}
22
21
  @deploy_control_client = mock
23
- @command_executor = InstanceAgent::CodeDeployPlugin::CommandExecutor.new({
22
+ @command_executor = InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor.new({
24
23
  :deploy_control_client => @deploy_control_client,
25
24
  :hook_mapping => @test_hook_mapping})
26
25
  @aws_region = 'us-east-1'
@@ -45,6 +44,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
45
44
  setup do
46
45
  @cert_helper = CertificateHelper.new
47
46
  @deployment_id = SecureRandom.uuid
47
+ @deployment_group_name = "TestDeploymentGroup"
48
+ @application_name = "TestApplicationName"
48
49
  @deployment_group_id = "foo"
49
50
  @s3Revision = {
50
51
  "Bucket" => "mybucket",
@@ -54,6 +55,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
54
55
  @deployment_spec = generate_signed_message_for({
55
56
  "DeploymentId" => @deployment_id.to_s,
56
57
  "DeploymentGroupId" => @deployment_group_id,
58
+ "ApplicationName" => @application_name,
59
+ "DeploymentGroupName" => @deployment_group_name,
57
60
  "Revision" => {
58
61
  "RevisionType" => "S3",
59
62
  "S3Revision" => @s3Revision
@@ -83,13 +86,13 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
83
86
  FileUtils.unstub(:mkdir_p)
84
87
  FileUtils.expects(:mkdir_p).never
85
88
 
86
- assert_raised_with_message('Unsupported command type: unknown-command.', InstanceAgent::CodeDeployPlugin::CommandExecutor::InvalidCommandNameFailure) do
89
+ assert_raised_with_message('Unsupported command type: unknown-command.', InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor::InvalidCommandNameFailure) do
87
90
  @command_executor.execute_command(@command, @deployment_spec)
88
91
  end
89
92
  end
90
93
 
91
94
  should "throw an exception" do
92
- assert_raised_with_message('Unsupported command type: unknown-command.', InstanceAgent::CodeDeployPlugin::CommandExecutor::InvalidCommandNameFailure) do
95
+ assert_raised_with_message('Unsupported command type: unknown-command.', InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor::InvalidCommandNameFailure) do
93
96
  @command_executor.execute_command(@command, @deployment_spec)
94
97
  end
95
98
  end
@@ -124,7 +127,7 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
124
127
 
125
128
  setup do
126
129
  @command.command_name = "Install"
127
- InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ApplicationSpecification.stubs(:parse).returns(@app_spec)
130
+ InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ApplicationSpecification.stubs(:parse).returns(@app_spec)
128
131
  @installer = stub("installer", :install => nil)
129
132
  Installer.stubs(:new).returns(@installer)
130
133
  File.stubs(:exist?).with(@previous_install_file_location).returns(true)
@@ -197,6 +200,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
197
200
  @deployment_spec = generate_signed_message_for({
198
201
  "DeploymentId" => @deployment_id.to_s,
199
202
  "DeploymentGroupId" => @deployment_group_id.to_s,
203
+ "ApplicationName" => @application_name,
204
+ "DeploymentGroupName" => @deployment_group_name,
200
205
  "Revision" => {
201
206
  "RevisionType" => "S3",
202
207
  "S3Revision" => {
@@ -224,6 +229,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
224
229
  @deployment_spec = generate_signed_message_for({
225
230
  "DeploymentId" => @deployment_id.to_s,
226
231
  "DeploymentGroupId" => @deployment_group_id.to_s,
232
+ "ApplicationName" => @application_name,
233
+ "DeploymentGroupName" => @deployment_group_name,
227
234
  "Revision" => {
228
235
  "RevisionType" => "S3",
229
236
  "S3Revision" => {
@@ -242,6 +249,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
242
249
  @deployment_spec = generate_signed_message_for({
243
250
  "DeploymentId" => @deployment_id.to_s,
244
251
  "DeploymentGroupId" => @deployment_group_id.to_s,
252
+ "ApplicationName" => @application_name,
253
+ "DeploymentGroupName" => @deployment_group_name,
245
254
  "Revision" => {
246
255
  "RevisionType" => "S3",
247
256
  "S3Revision" => {
@@ -260,6 +269,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
260
269
  @deployment_spec = generate_signed_message_for({
261
270
  "DeploymentId" => @deployment_id.to_s,
262
271
  "DeploymentGroupId" => @deployment_group_id.to_s,
272
+ "ApplicationName" => @application_name,
273
+ "DeploymentGroupName" => @deployment_group_name,
263
274
  "Revision" => {
264
275
  "RevisionType" => "S3",
265
276
  "S3Revision" => {
@@ -277,6 +288,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
277
288
  @deployment_spec = generate_signed_message_for({
278
289
  "DeploymentId" => @deployment_id.to_s,
279
290
  "DeploymentGroupId" => @deployment_group_id.to_s,
291
+ "ApplicationName" => @application_name,
292
+ "DeploymentGroupName" => @deployment_group_name,
280
293
  "Revision" => {
281
294
  "RevisionType" => "S3",
282
295
  "S3Revision" => {
@@ -294,6 +307,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
294
307
  @deployment_spec = generate_signed_message_for({
295
308
  "DeploymentId" => @deployment_id.to_s,
296
309
  "DeploymentGroupId" => @deployment_group_id.to_s,
310
+ "ApplicationName" => @application_name,
311
+ "DeploymentGroupName" => @deployment_group_name,
297
312
  "Revision" => {
298
313
  "RevisionType" => "S3",
299
314
  "S3Revision" => {
@@ -311,6 +326,8 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
311
326
  @deployment_spec = generate_signed_message_for({
312
327
  "DeploymentId" => @deployment_id.to_s,
313
328
  "DeploymentGroupId" => @deployment_group_id.to_s,
329
+ "ApplicationName" => @application_name,
330
+ "DeploymentGroupName" => @deployment_group_name,
314
331
  "Revision" => {
315
332
  "RevisionType" => "S3",
316
333
  "S3Revision" => {
@@ -342,9 +359,12 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
342
359
  context "I have an empty app spec (for script mapping)" do
343
360
  setup do
344
361
  File.stubs(:read).with(File.join(@archive_root_dir, 'appspec.yml')).returns(nil)
345
- InstanceAgent::CodeDeployPlugin::ApplicationSpecification::ApplicationSpecification.stubs(:parse).returns(nil)
362
+ InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ApplicationSpecification.stubs(:parse).returns(nil)
346
363
  @hook_executor_constructor_hash = {
347
- :deployment_root_dir => @deployment_root_dir,
364
+ :application_name => @application_name,
365
+ :deployment_id => @deployment_id,
366
+ :deployment_group_name => @deployment_group_name,
367
+ :deployment_root_dir => @deployment_root_dir,
348
368
  :last_successful_deployment_dir => nil,
349
369
  :app_spec_path => 'appspec.yml'}
350
370
  @mock_hook_executor = mock
@@ -474,11 +494,14 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
474
494
  @command.command_name = "test_command"
475
495
  @test_hook_mapping = { "test_command" => ["lifecycle_event_1","lifecycle_event_2"]}
476
496
  @deploy_control_client = mock
477
- @command_executor = InstanceAgent::CodeDeployPlugin::CommandExecutor.new({
497
+ @command_executor = InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor.new({
478
498
  :deploy_control_client => @deploy_control_client,
479
499
  :hook_mapping => @test_hook_mapping})
480
500
  hook_executor_constructor_hash = {
481
501
  :deployment_root_dir => @deployment_root_dir,
502
+ :application_name => @application_name,
503
+ :deployment_id => @deployment_id,
504
+ :deployment_group_name => @deployment_group_name,
482
505
  :last_successful_deployment_dir => nil,
483
506
  :app_spec_path => 'appspec.yml'}
484
507
  @hook_executor_constructor_hash_1 = hook_executor_constructor_hash.merge({:lifecycle_event => "lifecycle_event_1"})
@@ -4,12 +4,12 @@ require 'json'
4
4
  class CommandPollerTest < InstanceAgentTestCase
5
5
 
6
6
  def gather_diagnostics_from_error(error)
7
- {'error_code' => InstanceAgent::CodeDeployPlugin::ScriptError::UNKNOWN_ERROR_CODE, 'script_name' => "", 'message' => error.message, 'log' => ""}.to_json
7
+ {'error_code' => InstanceAgent::Plugins::CodeDeployPlugin::ScriptError::UNKNOWN_ERROR_CODE, 'script_name' => "", 'message' => error.message, 'log' => ""}.to_json
8
8
  end
9
9
 
10
10
  def gather_diagnostics(script_output)
11
11
  script_output ||= ""
12
- {'error_code' => InstanceAgent::CodeDeployPlugin::ScriptError::SUCCEEDED_CODE, 'script_name' => "", 'message' => "Succeeded", 'log' => script_output}.to_json
12
+ {'error_code' => InstanceAgent::Plugins::CodeDeployPlugin::ScriptError::SUCCEEDED_CODE, 'script_name' => "", 'message' => "Succeeded", 'log' => script_output}.to_json
13
13
  end
14
14
 
15
15
  context 'The command poller' do
@@ -27,25 +27,25 @@ class CommandPollerTest < InstanceAgentTestCase
27
27
  InstanceMetadata.stubs(:region).returns(@aws_region)
28
28
  InstanceMetadata.stubs(:host_identifier).returns(@host_identifier)
29
29
 
30
- InstanceAgent::CodeDeployPlugin::CodeDeployControl.stubs(:new).
30
+ InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl.stubs(:new).
31
31
  returns(@deploy_control_api)
32
32
  @deploy_control_api.stubs(:get_client).
33
33
  returns(@deploy_control_client)
34
34
 
35
- InstanceAgent::CodeDeployPlugin::CommandExecutor.stubs(:new).
35
+ InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor.stubs(:new).
36
36
  returns(@executor)
37
37
 
38
- @poller = InstanceAgent::CodeDeployPlugin::CommandPoller.new
38
+ @poller = InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller.new
39
39
  end
40
40
 
41
41
  context 'on initializing' do
42
42
 
43
43
  should 'construct a client using the configured region' do
44
- InstanceAgent::CodeDeployPlugin::CodeDeployControl.expects(:new).
44
+ InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl.expects(:new).
45
45
  with(has_entries(:region => @aws_region)).
46
46
  returns(@deploy_control_api)
47
47
 
48
- InstanceAgent::CodeDeployPlugin::CommandPoller.new
48
+ InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller.new
49
49
  end
50
50
 
51
51
  should 'construct an CodeDeploy command executor' do
@@ -58,12 +58,11 @@ class CommandPollerTest < InstanceAgentTestCase
58
58
  "BeforeELBAdd"=>["BeforeELBAdd"],
59
59
  "AfterELBAdd"=>["AfterELBAdd"],
60
60
  "ValidateService"=>["ValidateService"]}
61
- InstanceAgent::CodeDeployPlugin::CommandExecutor.expects(:new).
62
- with(:deploy_control_client => @deploy_control_client,
63
- :hook_mapping => test_hook_mapping).
61
+ InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor.expects(:new).
62
+ with(:hook_mapping => test_hook_mapping).
64
63
  returns(@executor)
65
64
 
66
- InstanceAgent::CodeDeployPlugin::CommandPoller.new
65
+ InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller.new
67
66
  end
68
67
 
69
68
  end
@@ -420,10 +419,10 @@ class CommandPollerTest < InstanceAgentTestCase
420
419
 
421
420
  should 'allow script errors from execute_command to propagate diagnostic information to caller' do
422
421
  begin
423
- script_log = InstanceAgent::CodeDeployPlugin::ScriptLog.new
422
+ script_log = InstanceAgent::Plugins::CodeDeployPlugin::ScriptLog.new
424
423
  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
424
+ raise InstanceAgent::Plugins::CodeDeployPlugin::ScriptError.new(InstanceAgent::Plugins::CodeDeployPlugin::ScriptError::SCRIPT_FAILED_CODE, "file_location", script_log), 'message'
425
+ rescue InstanceAgent::Plugins::CodeDeployPlugin::ScriptError => e
427
426
  script_error = e
428
427
  end
429
428
 
@@ -16,6 +16,8 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
16
16
  @cert_helper = CertificateHelper.new
17
17
  @deployment_id = SecureRandom.uuid.to_s
18
18
  @deployment_group_id = SecureRandom.uuid.to_s
19
+ @deployment_group_name = "TestDeploymentGroup"
20
+ @application_name = "TestApplication"
19
21
  @s3Revision = {
20
22
  "Bucket" => "mybucket",
21
23
  "Key" => "mykey",
@@ -26,37 +28,46 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
26
28
  "S3Revision" => @s3Revision
27
29
  }
28
30
  @deployment_spec = {
31
+ "ApplicationName" => @application_name,
29
32
  "DeploymentId" => @deployment_id,
33
+ "DeploymentGroupName" => @deployment_group_name,
30
34
  "DeploymentGroupId" => @deployment_group_id,
31
35
  "Revision" => @revision
32
36
  }
37
+
33
38
  @packed_message = generate_signed_message_for(@deployment_spec)
34
39
  InstanceAgent::Config.init
35
40
  end
36
41
 
37
42
  context "with JSON format" do
38
43
  should "populate the deployment id" do
39
- parsed_deployment_spec = InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
44
+ parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
40
45
  assert_equal @deployment_id, parsed_deployment_spec.deployment_id
41
46
  assert_equal @s3Revision, parsed_deployment_spec.revision
47
+ assert_equal @deployment_group_name, parsed_deployment_spec.deployment_group_name
48
+ assert_equal @application_name, parsed_deployment_spec.application_name
42
49
  end
43
50
  end
44
51
 
45
52
  context "with arn deployment id" do
46
53
  setup do
47
54
  @deployment_spec = {
55
+ "ApplicationName" => @application_name,
48
56
  "DeploymentId" => "arn:aws:codedeploy:region:account:deployment/#{@deployment_id}",
49
57
  "DeploymentGroupId" => @deployment_group_id,
58
+ "DeploymentGroupName" => @deployment_group_name,
50
59
  "Revision" => @revision
51
60
  }
52
61
  @packed_message = generate_signed_message_for(@deployment_spec)
53
62
  end
54
63
 
55
64
  should "populate the Bundle" do
56
- parsed_deployment_spec = InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
65
+ parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
57
66
  assert_equal @deployment_id, parsed_deployment_spec.deployment_id
58
67
  assert_equal @deployment_group_id, parsed_deployment_spec.deployment_group_id
59
68
  assert_equal @s3Revision, parsed_deployment_spec.revision
69
+ assert_equal @deployment_group_name, parsed_deployment_spec.deployment_group_name
70
+ assert_equal @application_name, parsed_deployment_spec.application_name
60
71
  end
61
72
  end
62
73
 
@@ -67,7 +78,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
67
78
 
68
79
  should "raise an exception" do
69
80
  assert_raised_with_message("Unsupported DeploymentSpecification format: XML") do
70
- parsed_deployment_spec = InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
81
+ parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
71
82
  end
72
83
  end
73
84
  end
@@ -79,10 +90,12 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
79
90
  end
80
91
 
81
92
  should "populate the Bundle" do
82
- parsed_deployment_spec = InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
93
+ parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
83
94
  assert_equal @deployment_id, parsed_deployment_spec.deployment_id
84
95
  assert_equal @deployment_group_id, parsed_deployment_spec.deployment_group_id
85
96
  assert_equal @s3Revision, parsed_deployment_spec.revision
97
+ assert_equal @deployment_group_name, parsed_deployment_spec.deployment_group_name
98
+ assert_equal @application_name, parsed_deployment_spec.application_name
86
99
  end
87
100
  end
88
101
 
@@ -93,7 +106,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
93
106
 
94
107
  should "raise an exception" do
95
108
  assert_raised_with_message("Unsupported DeploymentSpecification format: ") do
96
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
109
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
97
110
  end
98
111
  end
99
112
  end
@@ -105,7 +118,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
105
118
 
106
119
  should "raise a runtime exception" do
107
120
  assert_raised_with_message("Provided deployment spec was nil") do
108
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
121
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
109
122
  end
110
123
  end
111
124
  end
@@ -118,7 +131,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
118
131
 
119
132
  should "raise a runtime exception" do
120
133
  assert_raised_with_message("Deployment Spec has no DeploymentId") do
121
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
134
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
122
135
  end
123
136
  end
124
137
  end
@@ -131,7 +144,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
131
144
 
132
145
  should "raise a runtime exception" do
133
146
  assert_raised_with_message("Deployment Spec has no DeploymentId") do
134
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
147
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
135
148
  end
136
149
  end
137
150
  end
@@ -144,7 +157,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
144
157
 
145
158
  should "raise a runtime exception" do
146
159
  assert_raised_with_message("Deployment Spec has no DeploymentId") do
147
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
160
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
148
161
  end
149
162
  end
150
163
  end
@@ -157,7 +170,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
157
170
 
158
171
  should "raise a runtime exception" do
159
172
  assert_raised_with_message("Deployment Spec has no DeploymentGroupId") do
160
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
173
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
161
174
  end
162
175
  end
163
176
  end
@@ -170,7 +183,59 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
170
183
 
171
184
  should "raise a runtime exception" do
172
185
  assert_raised_with_message("Deployment Spec has no DeploymentGroupId") do
173
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
186
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
187
+ end
188
+ end
189
+ end
190
+
191
+ context "with no deployment group name" do
192
+ setup do
193
+ @deployment_spec.delete("DeploymentGroupName")
194
+ @packed_message = generate_signed_message_for(@deployment_spec)
195
+ end
196
+
197
+ should "raise a runtime exception" do
198
+ assert_raised_with_message("Deployment Spec has no DeploymentGroupName") do
199
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
200
+ end
201
+ end
202
+ end
203
+
204
+ context "with null deployment group name" do
205
+ setup do
206
+ @deployment_spec["DeploymentGroupName"] = nil
207
+ @packed_message = generate_signed_message_for(@deployment_spec)
208
+ end
209
+
210
+ should "raise a runtime exception" do
211
+ assert_raised_with_message("Deployment Spec has no DeploymentGroupName") do
212
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
213
+ end
214
+ end
215
+ end
216
+
217
+ context "with no application name" do
218
+ setup do
219
+ @deployment_spec.delete("ApplicationName")
220
+ @packed_message = generate_signed_message_for(@deployment_spec)
221
+ end
222
+
223
+ should "raise a runtime exception" do
224
+ assert_raised_with_message("Deployment Spec has no ApplicationName") do
225
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
226
+ end
227
+ end
228
+ end
229
+
230
+ context "with null application name" do
231
+ setup do
232
+ @deployment_spec["ApplicationName"] = nil
233
+ @packed_message = generate_signed_message_for(@deployment_spec)
234
+ end
235
+
236
+ should "raise a runtime exception" do
237
+ assert_raised_with_message("Deployment Spec has no ApplicationName") do
238
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
174
239
  end
175
240
  end
176
241
  end
@@ -183,7 +248,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
183
248
 
184
249
  should "raise a runtime exception" do
185
250
  assert_raised_with_message("Deployment Spec has no DeploymentGroupId") do
186
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
251
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
187
252
  end
188
253
  end
189
254
  end
@@ -196,7 +261,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
196
261
 
197
262
  should "raise a runtime exception" do
198
263
  assert_raised_with_message('Must specify a revison') do
199
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
264
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
200
265
  end
201
266
  end
202
267
  end
@@ -209,7 +274,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
209
274
 
210
275
  should "raise a runtime exception" do
211
276
  assert_raised_with_message('Must specify a revison') do
212
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
277
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
213
278
  end
214
279
  end
215
280
  end
@@ -222,14 +287,14 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
222
287
 
223
288
  should "raise a runtime exception" do
224
289
  assert_raised_with_message("Must specify a revision source") do
225
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
290
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
226
291
  end
227
292
  end
228
293
  end
229
294
 
230
295
  context "with S3 Revision" do
231
296
  should "parse correctly" do
232
- parsed_deployment_spec = InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
297
+ parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
233
298
  assert_equal @s3Revision, parsed_deployment_spec.revision
234
299
  end
235
300
 
@@ -245,12 +310,14 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
245
310
  @deployment_spec = {
246
311
  "DeploymentId" => @deployment_id,
247
312
  "DeploymentGroupId" => @deployment_group_id,
248
- "Revision" => @revision
313
+ "Revision" => @revision,
314
+ "DeploymentGroupName" => @deployment_group_name,
315
+ "ApplicationName" => @application_name
249
316
  }
250
317
  @packed_message = generate_signed_message_for(@deployment_spec)
251
318
 
252
319
  assert_raised_with_message("S3Revision in Deployment Spec must specify Bucket, Key and BundleType") do
253
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
320
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
254
321
  end
255
322
  end
256
323
 
@@ -266,12 +333,14 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
266
333
  @deployment_spec = {
267
334
  "DeploymentId" => @deployment_id,
268
335
  "DeploymentGroupId" => @deployment_group_id,
269
- "Revision" => @revision
336
+ "Revision" => @revision,
337
+ "DeploymentGroupName" => @deployment_group_name,
338
+ "ApplicationName" => @application_name
270
339
  }
271
340
  @packed_message = generate_signed_message_for(@deployment_spec)
272
341
 
273
342
  assert_raised_with_message("S3Revision in Deployment Spec must specify Bucket, Key and BundleType") do
274
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
343
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
275
344
  end
276
345
  end
277
346
 
@@ -287,12 +356,14 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
287
356
  @deployment_spec = {
288
357
  "DeploymentId" => @deployment_id,
289
358
  "DeploymentGroupId" => @deployment_group_id,
290
- "Revision" => @revision
359
+ "Revision" => @revision,
360
+ "DeploymentGroupName" => @deployment_group_name,
361
+ "ApplicationName" => @application_name
291
362
  }
292
363
  @packed_message = generate_signed_message_for(@deployment_spec)
293
364
 
294
365
  assert_raised_with_message("S3Revision in Deployment Spec must specify Bucket, Key and BundleType") do
295
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
366
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
296
367
  end
297
368
  end
298
369
 
@@ -309,12 +380,14 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
309
380
  @deployment_spec = {
310
381
  "DeploymentId" => @deployment_id,
311
382
  "DeploymentGroupId" => @deployment_group_id,
312
- "Revision" => @revision
383
+ "Revision" => @revision,
384
+ "DeploymentGroupName" => @deployment_group_name,
385
+ "ApplicationName" => @application_name
313
386
  }
314
387
  @packed_message = generate_signed_message_for(@deployment_spec)
315
388
 
316
389
  assert_raised_with_message("BundleType in S3Revision must be tar, tgz or zip") do
317
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
390
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
318
391
  end
319
392
  end
320
393
 
@@ -323,7 +396,7 @@ class DeploymentSpecificationTest < InstanceAgentTestCase
323
396
 
324
397
  assert_raised_with_message("Could not parse the PKCS7: nested asn1 error") do
325
398
  begin
326
- InstanceAgent::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
399
+ InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)
327
400
  rescue ArgumentError => e
328
401
  raise e.message
329
402
  end