automan 2.3.5 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -5
- data/automan.gemspec +3 -3
- data/lib/automan.rb +0 -1
- data/lib/automan/base.rb +3 -7
- data/lib/automan/beanstalk/deployer.rb +1 -1
- data/lib/automan/beanstalk/package.rb +1 -1
- data/lib/automan/beanstalk/router.rb +1 -1
- data/lib/automan/cli/snapper.rb +23 -3
- data/lib/automan/cli/stacker.rb +0 -19
- data/lib/automan/cloudformation/launcher.rb +3 -6
- data/lib/automan/cloudformation/replacer.rb +1 -1
- data/lib/automan/cloudformation/terminator.rb +1 -1
- data/lib/automan/ec2/image.rb +3 -3
- data/lib/automan/mixins/aws_caller.rb +7 -21
- data/lib/automan/rds/snapshot.rb +25 -35
- data/lib/automan/s3/downloader.rb +1 -10
- data/lib/automan/version.rb +1 -1
- data/spec/beanstalk/application_spec.rb +17 -17
- data/spec/beanstalk/configuration_spec.rb +24 -24
- data/spec/beanstalk/deployer_spec.rb +65 -65
- data/spec/beanstalk/router_spec.rb +19 -18
- data/spec/beanstalk/terminator_spec.rb +16 -16
- data/spec/beanstalk/uploader_spec.rb +13 -13
- data/spec/beanstalk/version_spec.rb +10 -8
- data/spec/cloudformation/launcher_spec.rb +65 -63
- data/spec/cloudformation/replacer_spec.rb +10 -10
- data/spec/cloudformation/terminator_spec.rb +23 -23
- data/spec/cloudformation/uploader_spec.rb +13 -13
- data/spec/ec2/image_spec.rb +55 -55
- data/spec/ec2/instance_spec.rb +17 -17
- data/spec/mixins/aws_caller_spec.rb +9 -9
- data/spec/mixins/utils_spec.rb +28 -27
- data/spec/rds/snapshot_spec.rb +46 -44
- metadata +9 -22
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -5
- data/lib/automan/elasticache/router.rb +0 -79
- data/spec/elasticache/router_spec.rb +0 -29
- data/templates/stacker/.env.example +0 -14
- data/templates/stacker/.gitignore +0 -2
- data/templates/stacker/.ruby-gemset.tt +0 -1
- data/templates/stacker/.ruby-version +0 -1
- data/templates/stacker/Gemfile +0 -4
- data/templates/stacker/bin/%app_name%.tt +0 -62
- data/templates/stacker/bin/launch_%app_name%.sh.tt +0 -12
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'automan'
|
2
2
|
|
3
3
|
describe Automan::Cloudformation::Uploader do
|
4
|
-
subject() do
|
4
|
+
subject(:u) do
|
5
5
|
AWS.stub!
|
6
6
|
u = Automan::Cloudformation::Uploader.new
|
7
7
|
u.logger = Logger.new('/dev/null')
|
8
|
-
|
8
|
+
u.stub(:templates).and_return(%w[a b c])
|
9
9
|
u
|
10
10
|
end
|
11
11
|
|
@@ -16,35 +16,35 @@ describe Automan::Cloudformation::Uploader do
|
|
16
16
|
|
17
17
|
describe '#all_templates_valid?' do
|
18
18
|
it "raises error if there are no templates" do
|
19
|
-
|
19
|
+
u.stub(:templates).and_return([])
|
20
20
|
expect {
|
21
|
-
|
21
|
+
u.all_templates_valid?
|
22
22
|
}.to raise_error Automan::Cloudformation::NoTemplatesError
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns true if templates are valid' do
|
26
|
-
|
27
|
-
|
26
|
+
u.should_receive(:template_valid?).exactly(3).times.and_return(true)
|
27
|
+
u.all_templates_valid?.should be_true
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'returns false if any templates are invalid' do
|
31
|
-
|
32
|
-
|
31
|
+
u.stub(:template_valid?).and_return(false)
|
32
|
+
u.all_templates_valid?.should be_false
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#upload_templates' do
|
37
37
|
it 'raises error if any template fails validation' do
|
38
|
-
|
38
|
+
u.stub(:all_templates_valid?).and_return(false)
|
39
39
|
expect {
|
40
|
-
|
40
|
+
u.upload_templates
|
41
41
|
}.to raise_error(Automan::Cloudformation::InvalidTemplateError)
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'uploads files if all are valid' do
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
u.stub(:all_templates_valid?).and_return(true)
|
46
|
+
u.should_receive(:upload_file).exactly(3).times
|
47
|
+
u.upload_templates
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/ec2/image_spec.rb
CHANGED
@@ -2,37 +2,37 @@ require 'automan'
|
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
describe Automan::Ec2::Image do
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
5
|
+
it { should respond_to :ec2 }
|
6
|
+
it { should respond_to :create }
|
7
|
+
it { should respond_to :prune }
|
8
|
+
it { should respond_to :default_image_name }
|
9
|
+
it { should respond_to :image_snapshot_exists? }
|
10
|
+
it { should respond_to :image_snapshot }
|
11
|
+
it { should respond_to :delete_snapshots }
|
12
|
+
it { should respond_to :is_more_than_month_old? }
|
13
13
|
|
14
14
|
describe '#default_image_name' do
|
15
|
-
subject() do
|
15
|
+
subject(:s) do
|
16
16
|
AWS.stub!
|
17
17
|
s = Automan::Ec2::Image.new
|
18
18
|
s.logger = Logger.new('/dev/null')
|
19
|
-
|
19
|
+
s.stub(:name).and_return('skee-lo')
|
20
20
|
s
|
21
21
|
end
|
22
22
|
|
23
23
|
it "never returns nil" do
|
24
|
-
|
24
|
+
s.default_image_name().should_not be_nil
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns name dash iso8601 string" do
|
28
|
-
name =
|
29
|
-
|
28
|
+
name = s.default_image_name()
|
29
|
+
name.should match /^skee-lo-(\d{4})-(\d{2})-(\d{2})T(\d{2})-(\d{2})-(\d{2})[+-](\d{2})-(\d{2})/
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#image_snapshot' do
|
35
|
-
subject() do
|
35
|
+
subject(:s) do
|
36
36
|
AWS.stub!
|
37
37
|
s = Automan::Ec2::Image.new
|
38
38
|
s.logger = Logger.new('/dev/null')
|
@@ -41,31 +41,31 @@ describe Automan::Ec2::Image do
|
|
41
41
|
|
42
42
|
it "returns id if the snapshot exists" do
|
43
43
|
fake_ami = double("ami")
|
44
|
-
|
45
|
-
|
44
|
+
fake_ami.stub(:block_devices) { [ { ebs: {snapshot_id: 'foo' } } ] }
|
45
|
+
s.image_snapshot(fake_ami).should eq('foo')
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns nil if the snapshot is nil" do
|
49
49
|
fake_ami = double("ami")
|
50
|
-
|
51
|
-
|
50
|
+
fake_ami.stub(:block_devices) { [ { ebs: {snapshot_id: nil } } ] }
|
51
|
+
s.image_snapshot(fake_ami).should be_nil
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns nil if the ebs is nil" do
|
55
55
|
fake_ami = double("ami")
|
56
|
-
|
57
|
-
|
56
|
+
fake_ami.stub(:block_devices) { [ { ebs: nil } ] }
|
57
|
+
s.image_snapshot(fake_ami).should be_nil
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns nil if the device is nil" do
|
61
61
|
fake_ami = double("ami")
|
62
|
-
|
63
|
-
|
62
|
+
fake_ami.stub(:block_devices) { [ nil ] }
|
63
|
+
s.image_snapshot(fake_ami).should be_nil
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#delete_snapshots' do
|
68
|
-
subject() do
|
68
|
+
subject(:s) do
|
69
69
|
AWS.stub!
|
70
70
|
s = Automan::Ec2::Image.new
|
71
71
|
s.logger = Logger.new('/dev/null')
|
@@ -74,67 +74,67 @@ describe Automan::Ec2::Image do
|
|
74
74
|
|
75
75
|
it 'does not delete snapshots with status != :completed' do
|
76
76
|
snapshot = double(:snapshot)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
snapshot.stub(:status).and_return(:foo)
|
78
|
+
snapshot.stub(:id)
|
79
|
+
snapshot.should_not_receive(:delete)
|
80
|
+
s.delete_snapshots( [ snapshot ])
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'deletes snapshots with status == :completed' do
|
84
84
|
snapshot = double(:snapshot)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
snapshot.stub(:status).and_return(:completed)
|
86
|
+
snapshot.stub(:id)
|
87
|
+
snapshot.should_receive(:delete)
|
88
|
+
s.delete_snapshots( [ snapshot ])
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe '#deregister_images' do
|
93
|
-
subject() do
|
93
|
+
subject(:s) do
|
94
94
|
AWS.stub!
|
95
95
|
s = Automan::Ec2::Image.new
|
96
96
|
s.logger = Logger.new('/dev/null')
|
97
|
-
|
97
|
+
s.stub(:image_snapshot).and_return('foo')
|
98
98
|
s
|
99
99
|
end
|
100
100
|
|
101
101
|
before(:each) do
|
102
102
|
@image = double(:image)
|
103
|
-
|
104
|
-
|
103
|
+
@image.stub(:id)
|
104
|
+
s.stub(:my_images).and_return( [ @image ] )
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'does not deregister images with state != :available' do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
@image.stub(:state).and_return(:foo)
|
109
|
+
@image.stub(:tags).and_return( {'CanPrune' => 'yes'} )
|
110
|
+
@image.should_not_receive(:delete)
|
111
|
+
s.deregister_images( [ 'foo' ] )
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'does not deregister images w/o prunable tag' do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
@image.stub(:state).and_return(:available)
|
116
|
+
@image.stub(:tags).and_return( Hash.new )
|
117
|
+
@image.should_not_receive(:delete)
|
118
|
+
s.deregister_images( [ 'foo' ] )
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'does not deregister images whose snapshots are not in the list' do
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
@image.stub(:state).and_return(:available)
|
123
|
+
@image.stub(:tags).and_return( {'CanPrune' => 'yes'} )
|
124
|
+
@image.should_not_receive(:delete)
|
125
|
+
s.deregister_images( [ 'bar' ] )
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'deletes available, prunable images on the list' do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
@image.stub(:state).and_return(:available)
|
130
|
+
@image.stub(:tags).and_return( {'CanPrune' => 'yes'} )
|
131
|
+
@image.should_receive(:delete)
|
132
|
+
s.deregister_images( [ 'foo' ] )
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe '#is_more_than_month_old?' do
|
137
|
-
subject() do
|
137
|
+
subject(:s) do
|
138
138
|
AWS.stub!
|
139
139
|
s = Automan::Ec2::Image.new
|
140
140
|
s.logger = Logger.new('/dev/null')
|
@@ -142,17 +142,17 @@ describe Automan::Ec2::Image do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'returns false if argument is not a Time object' do
|
145
|
-
|
145
|
+
s.is_more_than_month_old?(Object.new).should be_false
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'returns true if time is more than 30 days in the past' do
|
149
149
|
days_of_yore = Time.now - (60*60*24*30)
|
150
|
-
|
150
|
+
s.is_more_than_month_old?(days_of_yore).should be_true
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'returns false if time is in the last 30 days' do
|
154
154
|
just_yesterday = Time.now - (60*60*24)
|
155
|
-
|
155
|
+
s.is_more_than_month_old?(just_yesterday).should be_false
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/spec/ec2/instance_spec.rb
CHANGED
@@ -2,14 +2,14 @@ require "automan"
|
|
2
2
|
|
3
3
|
describe Automan::Ec2::Instance do
|
4
4
|
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
5
|
+
it { should respond_to :windows_password }
|
6
|
+
it { should respond_to :password_data }
|
7
|
+
it { should respond_to :decrypt_password }
|
8
|
+
it { should respond_to :windows_name }
|
9
|
+
it { should respond_to :show_env }
|
10
10
|
|
11
11
|
describe '#windows_password' do
|
12
|
-
subject() do
|
12
|
+
subject(:i) do
|
13
13
|
AWS.stub!
|
14
14
|
i = Automan::Ec2::Instance.new
|
15
15
|
i.logger = Logger.new('/dev/null')
|
@@ -17,24 +17,24 @@ describe Automan::Ec2::Instance do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns nil if password could not be found" do
|
20
|
-
|
21
|
-
|
20
|
+
i.stub(:password_data).and_return nil
|
21
|
+
i.windows_password('foo','bar').should be_nil
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns nil if the aws request fails" do
|
25
|
-
|
26
|
-
|
25
|
+
i.stub(:password_data).and_raise Automan::Ec2::RequestFailedError
|
26
|
+
i.windows_password('foo','bar').should be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns nil if the decrypt fails" do
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
i.stub(:password_data).and_return 'foo'
|
31
|
+
i.stub(:decrypt_password).and_return nil
|
32
|
+
i.windows_password('foo','bar').should be_nil
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#windows_name' do
|
37
|
-
subject() do
|
37
|
+
subject(:i) do
|
38
38
|
AWS.stub!
|
39
39
|
i = Automan::Ec2::Instance.new
|
40
40
|
i.logger = Logger.new('/dev/null')
|
@@ -42,15 +42,15 @@ describe Automan::Ec2::Instance do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "returns nil if ip_address is nil" do
|
45
|
-
|
45
|
+
i.windows_name(nil).should be_nil
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns nil if ip_address is empty" do
|
49
|
-
|
49
|
+
i.windows_name("").should be_nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it "converts ip_address to ip-xxxxxxxx" do
|
53
|
-
|
53
|
+
i.windows_name('54.56.78.90').should eq 'ip-36384e5a'
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -1,39 +1,39 @@
|
|
1
1
|
require 'automan/mixins/aws_caller'
|
2
2
|
|
3
3
|
describe Automan::Mixins::AwsCaller do
|
4
|
-
|
4
|
+
let(:s) { (Class.new { include Automan::Mixins::AwsCaller }).new }
|
5
5
|
|
6
6
|
services = [
|
7
7
|
:s3, :cfn, :as, :eb, :r53, :elb, :rds, :ec2
|
8
8
|
]
|
9
9
|
|
10
10
|
services.each do |svc|
|
11
|
-
it {
|
11
|
+
it { s.should respond_to svc }
|
12
12
|
end
|
13
13
|
|
14
|
-
it {
|
14
|
+
it { s.should respond_to :parse_s3_path }
|
15
15
|
|
16
16
|
describe '#parse_s3_path' do
|
17
17
|
it "parses s3 path into bucket and key" do
|
18
|
-
bucket, key =
|
19
|
-
|
20
|
-
|
18
|
+
bucket, key = s.parse_s3_path('s3://foo/bar/baz')
|
19
|
+
bucket.should eq('foo')
|
20
|
+
key.should eq ('bar/baz')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "raises error if it doesn't start with s3://" do
|
24
24
|
expect {
|
25
|
-
|
25
|
+
s.parse_s3_path 'foo'
|
26
26
|
}.to raise_error ArgumentError
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#looks_like_s3_path?' do
|
31
31
|
it 'returns true if it begins with "s3://"' do
|
32
|
-
|
32
|
+
s.looks_like_s3_path?('s3://foo').should be_true
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns false if it does not start with "s3://"' do
|
36
|
-
|
36
|
+
s.looks_like_s3_path?('foobar').should be_false
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/spec/mixins/utils_spec.rb
CHANGED
@@ -1,43 +1,44 @@
|
|
1
1
|
require 'automan/mixins/utils'
|
2
2
|
|
3
3
|
describe Automan::Mixins::Utils do
|
4
|
-
|
4
|
+
let(:s) { (Class.new { include Automan::Mixins::Utils }).new }
|
5
5
|
|
6
6
|
it "adds String#underscore" do
|
7
|
-
|
7
|
+
s = String.new
|
8
|
+
s.should respond_to :underscore
|
8
9
|
end
|
9
10
|
|
10
11
|
describe "String#underscore" do
|
11
12
|
it "underscore's like a boss" do
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
"Namespace".underscore.should eq "namespace"
|
14
|
+
"OptionName".underscore.should eq "option_name"
|
15
|
+
"Value".underscore.should eq "value"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
it {
|
19
|
+
it { s.should respond_to :region_from_az }
|
19
20
|
|
20
21
|
it "returns az properly" do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
s.region_from_az("us-east-1a").should eq 'us-east-1'
|
23
|
+
s.region_from_az("us-east-1b").should eq 'us-east-1'
|
24
|
+
s.region_from_az("us-east-1c").should eq 'us-east-1'
|
25
|
+
s.region_from_az("us-east-1d").should eq 'us-east-1'
|
26
|
+
s.region_from_az("ap-northeast-1a").should eq 'ap-northeast-1'
|
27
|
+
s.region_from_az("ap-northeast-1b").should eq 'ap-northeast-1'
|
28
|
+
s.region_from_az("ap-northeast-1c").should eq 'ap-northeast-1'
|
29
|
+
s.region_from_az("sa-east-1a").should eq 'sa-east-1'
|
30
|
+
s.region_from_az("sa-east-1b").should eq 'sa-east-1'
|
31
|
+
s.region_from_az("ap-southeast-1a").should eq 'ap-southeast-1'
|
32
|
+
s.region_from_az("ap-southeast-1b").should eq 'ap-southeast-1'
|
33
|
+
s.region_from_az("ap-southeast-2a").should eq 'ap-southeast-2'
|
34
|
+
s.region_from_az("ap-southeast-2b").should eq 'ap-southeast-2'
|
35
|
+
s.region_from_az("us-west-2a").should eq 'us-west-2'
|
36
|
+
s.region_from_az("us-west-2b").should eq 'us-west-2'
|
37
|
+
s.region_from_az("us-west-2c").should eq 'us-west-2'
|
38
|
+
s.region_from_az("us-west-1a").should eq 'us-west-1'
|
39
|
+
s.region_from_az("us-west-1c").should eq 'us-west-1'
|
40
|
+
s.region_from_az("eu-west-1a").should eq 'eu-west-1'
|
41
|
+
s.region_from_az("eu-west-1b").should eq 'eu-west-1'
|
42
|
+
s.region_from_az("eu-west-1c").should eq 'eu-west-1'
|
42
43
|
end
|
43
44
|
end
|