automan 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/automan.gemspec +3 -3
- 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 +18 -18
- data/spec/beanstalk/terminator_spec.rb +16 -16
- data/spec/beanstalk/uploader_spec.rb +13 -13
- data/spec/beanstalk/version_spec.rb +8 -9
- data/spec/cloudformation/launcher_spec.rb +63 -65
- 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 +27 -28
- data/spec/rds/snapshot_spec.rb +43 -45
- data/templates/stacker/.ruby-version +1 -0
- data/templates/stacker/bin/{launch_%app_name%.sh → launch_%app_name%.sh.tt} +2 -2
- metadata +12 -10
- data/.rvmrc +0 -1
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'automan'
|
2
2
|
|
3
3
|
describe Automan::Cloudformation::Terminator do
|
4
|
-
it {
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
4
|
+
it { is_expected.to respond_to :name }
|
5
|
+
it { is_expected.to respond_to :terminate }
|
6
|
+
it { is_expected.to respond_to :stack_exists? }
|
7
|
+
it { is_expected.to respond_to :stack_deleted? }
|
8
|
+
it { is_expected.to respond_to :delete_stack }
|
9
|
+
it { is_expected.to respond_to :wait_for_completion }
|
10
10
|
|
11
11
|
describe '#terminate' do
|
12
|
-
subject(
|
12
|
+
subject() do
|
13
13
|
AWS.stub!
|
14
14
|
t = Automan::Cloudformation::Terminator.new
|
15
15
|
t.logger = Logger.new('/dev/null')
|
@@ -17,20 +17,20 @@ describe Automan::Cloudformation::Terminator do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should call #delete_stack if the stack exists' do
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
allow(subject).to receive(:stack_exists?).and_return(true)
|
21
|
+
expect(subject).to receive :delete_stack
|
22
|
+
subject.terminate
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should not call #delete_stack if the stack does not exist' do
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
allow(subject).to receive(:stack_exists?).and_return(false)
|
27
|
+
expect(subject).to_not receive :delete_stack
|
28
|
+
subject.terminate
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#stack_deleted?' do
|
33
|
-
subject(
|
33
|
+
subject() do
|
34
34
|
AWS.stub!
|
35
35
|
t = Automan::Cloudformation::Terminator.new
|
36
36
|
t.logger = Logger.new('/dev/null')
|
@@ -38,26 +38,26 @@ describe Automan::Cloudformation::Terminator do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns true if the stack does not exist' do
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
allow(subject).to receive(:stack_exists?).and_return(false)
|
42
|
+
allow(subject).to receive(:stack_status).and_raise StandardError
|
43
|
+
expect(subject.stack_deleted?('foo')).to be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns true when status is DELETE_COMPLETE' do
|
47
|
-
|
48
|
-
|
47
|
+
allow(subject).to receive(:stack_status).and_return('DELETE_COMPLETE')
|
48
|
+
expect(subject.stack_deleted?('foo')).to be_truthy
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'raises an error when the delete fails' do
|
52
|
-
|
52
|
+
allow(subject).to receive(:stack_status).and_return('DELETE_FAILED')
|
53
53
|
expect {
|
54
|
-
|
54
|
+
subject.stack_deleted?('foo')
|
55
55
|
}.to raise_error Automan::Cloudformation::StackDeletionError
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'returns false for any other status' do
|
59
|
-
|
60
|
-
|
59
|
+
allow(subject).to receive(:stack_status).and_return('foo')
|
60
|
+
expect(subject.stack_deleted?('foo')).to be_falsey
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'automan'
|
2
2
|
|
3
3
|
describe Automan::Cloudformation::Uploader do
|
4
|
-
subject(
|
4
|
+
subject() do
|
5
5
|
AWS.stub!
|
6
6
|
u = Automan::Cloudformation::Uploader.new
|
7
7
|
u.logger = Logger.new('/dev/null')
|
8
|
-
u.
|
8
|
+
allow(u).to receive(: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
|
+
allow(subject).to receive(:templates).and_return([])
|
20
20
|
expect {
|
21
|
-
|
21
|
+
subject.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
|
+
expect(subject).to receive(:template_valid?).exactly(3).times.and_return(true)
|
27
|
+
expect(subject.all_templates_valid?).to be_truthy
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'returns false if any templates are invalid' do
|
31
|
-
|
32
|
-
|
31
|
+
allow(subject).to receive(:template_valid?).and_return(false)
|
32
|
+
expect(subject.all_templates_valid?).to be_falsey
|
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
|
+
allow(subject).to receive(:all_templates_valid?).and_return(false)
|
39
39
|
expect {
|
40
|
-
|
40
|
+
subject.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
|
+
allow(subject).to receive(:all_templates_valid?).and_return(true)
|
46
|
+
expect(subject).to receive(:upload_file).exactly(3).times
|
47
|
+
subject.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 { is_expected.to respond_to :ec2 }
|
6
|
+
it { is_expected.to respond_to :create }
|
7
|
+
it { is_expected.to respond_to :prune }
|
8
|
+
it { is_expected.to respond_to :default_image_name }
|
9
|
+
it { is_expected.to respond_to :image_snapshot_exists? }
|
10
|
+
it { is_expected.to respond_to :image_snapshot }
|
11
|
+
it { is_expected.to respond_to :delete_snapshots }
|
12
|
+
it { is_expected.to respond_to :is_more_than_month_old? }
|
13
13
|
|
14
14
|
describe '#default_image_name' do
|
15
|
-
subject(
|
15
|
+
subject() do
|
16
16
|
AWS.stub!
|
17
17
|
s = Automan::Ec2::Image.new
|
18
18
|
s.logger = Logger.new('/dev/null')
|
19
|
-
s.
|
19
|
+
allow(s).to receive(:name).and_return('skee-lo')
|
20
20
|
s
|
21
21
|
end
|
22
22
|
|
23
23
|
it "never returns nil" do
|
24
|
-
|
24
|
+
expect(subject.default_image_name()).to_not be_nil
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns name dash iso8601 string" do
|
28
|
-
name =
|
29
|
-
name.
|
28
|
+
name = subject.default_image_name()
|
29
|
+
expect(name).to match /^skee-lo-(\d{4})-(\d{2})-(\d{2})T(\d{2})(\d{2})(\d{2})Z/
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#image_snapshot' do
|
35
|
-
subject(
|
35
|
+
subject() 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
|
-
fake_ami.
|
45
|
-
|
44
|
+
allow(fake_ami).to receive(:block_devices) { [ { ebs: {snapshot_id: 'foo' } } ] }
|
45
|
+
expect(subject.image_snapshot(fake_ami)).to 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
|
-
fake_ami.
|
51
|
-
|
50
|
+
allow(fake_ami).to receive(:block_devices) { [ { ebs: {snapshot_id: nil } } ] }
|
51
|
+
expect(subject.image_snapshot(fake_ami)).to 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
|
-
fake_ami.
|
57
|
-
|
56
|
+
allow(fake_ami).to receive(:block_devices) { [ { ebs: nil } ] }
|
57
|
+
expect(subject.image_snapshot(fake_ami)).to 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
|
-
fake_ami.
|
63
|
-
|
62
|
+
allow(fake_ami).to receive(:block_devices) { [ nil ] }
|
63
|
+
expect(subject.image_snapshot(fake_ami)).to be_nil
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#delete_snapshots' do
|
68
|
-
subject(
|
68
|
+
subject() 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
|
-
snapshot.
|
78
|
-
snapshot.
|
79
|
-
snapshot.
|
80
|
-
|
77
|
+
allow(snapshot).to receive(:status).and_return(:foo)
|
78
|
+
allow(snapshot).to receive(:id)
|
79
|
+
expect(snapshot).to_not receive(:delete)
|
80
|
+
subject.delete_snapshots( [ snapshot ])
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'deletes snapshots with status == :completed' do
|
84
84
|
snapshot = double(:snapshot)
|
85
|
-
snapshot.
|
86
|
-
snapshot.
|
87
|
-
snapshot.
|
88
|
-
|
85
|
+
allow(snapshot).to receive(:status).and_return(:completed)
|
86
|
+
allow(snapshot).to receive(:id)
|
87
|
+
expect(snapshot).to receive(:delete)
|
88
|
+
subject.delete_snapshots( [ snapshot ])
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe '#deregister_images' do
|
93
|
-
subject(
|
93
|
+
subject() do
|
94
94
|
AWS.stub!
|
95
95
|
s = Automan::Ec2::Image.new
|
96
96
|
s.logger = Logger.new('/dev/null')
|
97
|
-
s.
|
97
|
+
allow(s).to receive(:image_snapshot).and_return('foo')
|
98
98
|
s
|
99
99
|
end
|
100
100
|
|
101
101
|
before(:each) do
|
102
102
|
@image = double(:image)
|
103
|
-
@image.
|
104
|
-
|
103
|
+
allow(@image).to receive(:id)
|
104
|
+
allow(subject).to receive(:my_images).and_return( [ @image ] )
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'does not deregister images with state != :available' do
|
108
|
-
@image.
|
109
|
-
@image.
|
110
|
-
@image.
|
111
|
-
|
108
|
+
allow(@image).to receive(:state).and_return(:foo)
|
109
|
+
allow(@image).to receive(:tags).and_return( {'CanPrune' => 'yes'} )
|
110
|
+
expect(@image).to_not receive(:delete)
|
111
|
+
subject.deregister_images( [ 'foo' ] )
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'does not deregister images w/o prunable tag' do
|
115
|
-
@image.
|
116
|
-
@image.
|
117
|
-
@image.
|
118
|
-
|
115
|
+
allow(@image).to receive(:state).and_return(:available)
|
116
|
+
allow(@image).to receive(:tags).and_return( Hash.new )
|
117
|
+
expect(@image).to_not receive(:delete)
|
118
|
+
subject.deregister_images( [ 'foo' ] )
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'does not deregister images whose snapshots are not in the list' do
|
122
|
-
@image.
|
123
|
-
@image.
|
124
|
-
@image.
|
125
|
-
|
122
|
+
allow(@image).to receive(:state).and_return(:available)
|
123
|
+
allow(@image).to receive(:tags).and_return( {'CanPrune' => 'yes'} )
|
124
|
+
expect(@image).to_not receive(:delete)
|
125
|
+
subject.deregister_images( [ 'bar' ] )
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'deletes available, prunable images on the list' do
|
129
|
-
@image.
|
130
|
-
@image.
|
131
|
-
@image.
|
132
|
-
|
129
|
+
allow(@image).to receive(:state).and_return(:available)
|
130
|
+
allow(@image).to receive(:tags).and_return( {'CanPrune' => 'yes'} )
|
131
|
+
expect(@image).to receive(:delete)
|
132
|
+
subject.deregister_images( [ 'foo' ] )
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe '#is_more_than_month_old?' do
|
137
|
-
subject(
|
137
|
+
subject() 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
|
+
expect(subject.is_more_than_month_old?(Object.new)).to be_falsey
|
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
|
+
expect(subject.is_more_than_month_old?(days_of_yore)).to be_truthy
|
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
|
+
expect(subject.is_more_than_month_old?(just_yesterday)).to be_falsey
|
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 { is_expected.to respond_to :windows_password }
|
6
|
+
it { is_expected.to respond_to :password_data }
|
7
|
+
it { is_expected.to respond_to :decrypt_password }
|
8
|
+
it { is_expected.to respond_to :windows_name }
|
9
|
+
it { is_expected.to respond_to :show_env }
|
10
10
|
|
11
11
|
describe '#windows_password' do
|
12
|
-
subject(
|
12
|
+
subject() 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
|
+
allow(subject).to receive(:password_data).and_return nil
|
21
|
+
expect(subject.windows_password('foo','bar')).to be_nil
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns nil if the aws request fails" do
|
25
|
-
|
26
|
-
|
25
|
+
allow(subject).to receive(:password_data).and_raise Automan::Ec2::RequestFailedError
|
26
|
+
expect(subject.windows_password('foo','bar')).to be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns nil if the decrypt fails" do
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
allow(subject).to receive(:password_data).and_return 'foo'
|
31
|
+
allow(subject).to receive(:decrypt_password).and_return nil
|
32
|
+
expect(subject.windows_password('foo','bar')).to be_nil
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#windows_name' do
|
37
|
-
subject(
|
37
|
+
subject() 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
|
+
expect(subject.windows_name(nil)).to be_nil
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns nil if ip_address is empty" do
|
49
|
-
|
49
|
+
expect(subject.windows_name("")).to be_nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it "converts ip_address to ip-xxxxxxxx" do
|
53
|
-
|
53
|
+
expect(subject.windows_name('54.56.78.90')).to 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
|
+
subject() { (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 { is_expected.to respond_to svc }
|
12
12
|
end
|
13
13
|
|
14
|
-
it {
|
14
|
+
it { is_expected.to 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
|
-
bucket.
|
20
|
-
key.
|
18
|
+
bucket, key = subject.parse_s3_path('s3://foo/bar/baz')
|
19
|
+
expect(bucket).to eq('foo')
|
20
|
+
expect(key).to 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
|
+
subject.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
|
+
expect(subject.looks_like_s3_path?('s3://foo')).to be_truthy
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns false if it does not start with "s3://"' do
|
36
|
-
|
36
|
+
expect(subject.looks_like_s3_path?('foobar')).to be_falsey
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|