Skip to content

Commit 1e10c2d

Browse files
committed
Add a Rakefile and fix the unit tests
1 parent 748de99 commit 1e10c2d

File tree

684 files changed

+70633
-69289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+70633
-69289
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Gemfile.lock
2+
deployment/

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ gem 'rubyzip'
1313
gem 'rake'
1414
gem 'archive-tar-minitar'
1515
gem 'logging'
16+
gem 'process_manager'
1617

1718
group :development do
1819
# this doesn't need to be a global or even a standard dependency

Rakefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'rake'
2+
require 'rake/testtask'
3+
require 'rspec/core/rake_task'
4+
require 'rubygems'
5+
6+
# Check Ruby syntax in bin/ and lib/
7+
8+
# Run all units tests in test/
9+
desc "Run unit tests in test/"
10+
Rake::TestTask.new(:test) do |t|
11+
t.libs << ['test', 'lib', 'test/helpers']
12+
13+
test_files = FileList.new("test/**/*_test.rb")
14+
t.test_files = test_files
15+
t.verbose = true
16+
end
17+
task :default => :test
18+
19+
# Run units tests in test/instance_agent/
20+
Rake::TestTask.new(:test_instance_agent) do |t|
21+
t.libs << ['test', 'lib', 'test/helpers']
22+
t.pattern = "test/instance_agent/**/*_test.rb"
23+
t.verbose = true
24+
end
25+
26+
# Clean up
27+
task :clean do
28+
rm_rf 'deployment'
29+
end

codedeploy_agent-1.1.0.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Gem::Specification.new do |spec|
1515
spec.add_dependency('rake', '~> 0.9')
1616
spec.add_dependency('logging', '~>1.8')
1717
spec.add_dependency('aws-sdk-core', '~>2.0')
18-
end
18+
end

lib/instance_agent.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# encoding: UTF-8
22

33
Gem.use_paths(nil, Gem.path << "/opt/codedeploy-agent/vendor")
4-
54
require 'core_ext'
65

76
require 'rubygems'

test/instance_agent/plugins/codedeploy/application_specification_test.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ module InstanceAgent
66
module Plugins
77
module CodeDeployPlugin
88
module ApplicationSpecification
9+
910
class ApplicationSpecificationTest < InstanceAgentTestCase
11+
def make_app_spec
12+
ApplicationSpecification.new(YAML.load(@app_spec_string), {:revision_id => @test_revision_id})
13+
end
14+
1015
context 'The Application Specification' do
1116
setup do
1217
@test_revision_id = 'bar'
1318
end
1419

1520
private
1621

17-
def make_app_spec
18-
ApplicationSpecification.new(YAML.load(@app_spec_string), {:revision_id => @test_revision_id})
19-
end
20-
2122
context "With missing version" do
2223
setup do
2324
@app_spec_string = <<-END
@@ -1710,4 +1711,4 @@ def make_app_spec
17101711
end
17111712
end
17121713
end
1713-
end
1714+
end

test/instance_agent/plugins/codedeploy/command_executor_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
require 'test_helper'
2+
require 'certificate_helper'
23
require 'stringio'
3-
require 'com/amazon/codedeploy/command/v20141006/host_command_instance'
44
require 'aws-sdk-core/s3'
55

66
class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
77

88
include InstanceAgent::Plugins::CodeDeployPlugin
9+
def generate_signed_message_for(map)
10+
message = @cert_helper.sign_message(map.to_json)
11+
spec = OpenStruct.new({ :payload => message })
12+
spec.format = "PKCS7/JSON"
13+
14+
return spec
15+
end
916

1017
context 'The CodeDeploy Plugin Command Executor' do
1118
setup do
@@ -33,13 +40,6 @@ class CodeDeployPluginCommandExecutorTest < InstanceAgentTestCase
3340
end
3441

3542
context "when executing a command" do
36-
def generate_signed_message_for(map)
37-
message = @cert_helper.sign_message(map.to_json)
38-
spec = OpenStruct.new({ :payload => message })
39-
spec.format = "PKCS7/JSON"
40-
41-
return spec
42-
end
4343

4444
setup do
4545
@cert_helper = CertificateHelper.new
@@ -62,7 +62,7 @@ def generate_signed_message_for(map)
6262
"S3Revision" => @s3Revision
6363
}
6464
})
65-
@command = Com::Amazon::Codedeploy::Command::V20141006::HostCommandInstance.new(
65+
@command = Aws::CodeDeployCommand::Types::HostCommandInstance.new(
6666
:host_command_identifier => "command-1",
6767
:deployment_execution_id => "test-execution")
6868
@root_dir = '/tmp/codedeploy/'

test/instance_agent/plugins/codedeploy/deployment_specification_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
require 'certificate_helper'
44

55
class DeploymentSpecificationTest < InstanceAgentTestCase
6-
context 'The Deployment Specification' do
7-
def generate_signed_message_for(map)
8-
message = @cert_helper.sign_message(map.to_json)
9-
spec = OpenStruct.new({ :payload => message })
10-
spec.format = "PKCS7/JSON"
116

12-
return spec
13-
end
7+
def generate_signed_message_for(map)
8+
message = @cert_helper.sign_message(map.to_json)
9+
spec = OpenStruct.new({ :payload => message })
10+
spec.format = "PKCS7/JSON"
11+
return spec
12+
end
1413

14+
context 'The Deployment Specification' do
1515
setup do
1616
@cert_helper = CertificateHelper.new
1717
@deployment_id = SecureRandom.uuid.to_s
@@ -37,8 +37,8 @@ def generate_signed_message_for(map)
3737

3838
@packed_message = generate_signed_message_for(@deployment_spec)
3939
InstanceAgent::Config.init
40-
end
41-
40+
end
41+
4242
context "with JSON format" do
4343
should "populate the deployment id" do
4444
parsed_deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(@packed_message)

test/instance_agent/plugins/codedeploy/hook_executor_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'test_helper'
22
require 'stringio'
33
require 'fileutils'
4-
require 'com/amazon/codedeploy/command/v20141006/host_command_instance'
54

65
class HookExecutorTest < InstanceAgentTestCase
76

test/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# encoding: UTF-8
2+
$:.unshift "lib"
3+
Gem.use_paths(nil, Gem.path << "vendor")
4+
25
require 'thread'
36
require 'rubygems'
47
require "bundler"
@@ -14,3 +17,4 @@
1417
# require local test helpers. If you need a helper write,
1518
# keep this pattern or you'll be punished hard
1619
require 'instance_agent_helper'
20+

0 commit comments

Comments
 (0)