automan 2.3.6 → 2.3.7
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/.travis.yml +5 -0
- data/Rakefile +5 -0
- data/automan.gemspec +3 -3
- data/lib/automan/base.rb +7 -3
- 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 +29 -29
- data/lib/automan/cli/stacker.rb +19 -0
- data/lib/automan/cloudformation/launcher.rb +6 -3
- 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/elasticache/router.rb +79 -0
- data/lib/automan/mixins/aws_caller.rb +21 -7
- data/lib/automan/rds/snapshot.rb +35 -14
- data/lib/automan/s3/downloader.rb +10 -1
- data/lib/automan/version.rb +1 -1
- data/lib/automan.rb +1 -0
- 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 -19
- data/spec/beanstalk/terminator_spec.rb +16 -16
- data/spec/beanstalk/uploader_spec.rb +13 -13
- data/spec/beanstalk/version_spec.rb +8 -10
- 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/elasticache/router_spec.rb +29 -0
- data/spec/mixins/aws_caller_spec.rb +9 -9
- data/spec/mixins/utils_spec.rb +27 -28
- data/spec/rds/snapshot_spec.rb +44 -46
- data/templates/stacker/.env.example +14 -0
- data/templates/stacker/.gitignore +2 -0
- data/templates/stacker/.ruby-gemset.tt +1 -0
- data/templates/stacker/.ruby-version +1 -0
- data/templates/stacker/Gemfile +4 -0
- data/templates/stacker/bin/%app_name%.tt +62 -0
- data/templates/stacker/bin/launch_%app_name%.sh.tt +12 -0
- metadata +20 -7
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
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'automan'
|
2
|
+
|
3
|
+
describe Automan::ElastiCache::Router do
|
4
|
+
it { is_expected.to respond_to :run }
|
5
|
+
it { is_expected.to respond_to :environment }
|
6
|
+
it { is_expected.to respond_to :hosted_zone_name }
|
7
|
+
it { is_expected.to respond_to :redis_host }
|
8
|
+
|
9
|
+
describe '#run' do
|
10
|
+
subject() do
|
11
|
+
AWS.stub!
|
12
|
+
r = Automan::ElastiCache::Router.new
|
13
|
+
r.ec = AWS::ElastiCache::Client.new
|
14
|
+
r.environment = 'foo'
|
15
|
+
r.hosted_zone_name = 'foo.com'
|
16
|
+
r.redis_host = 'redis.foo.com'
|
17
|
+
r.logger = Logger.new('/dev/null')
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises error if it never finds a name" do
|
22
|
+
allow(subject).to receive(:node_name_from_elasticache_environment).and_return(nil)
|
23
|
+
expect {
|
24
|
+
subject.run
|
25
|
+
}.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -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
|
data/spec/mixins/utils_spec.rb
CHANGED
@@ -1,44 +1,43 @@
|
|
1
1
|
require 'automan/mixins/utils'
|
2
2
|
|
3
3
|
describe Automan::Mixins::Utils do
|
4
|
-
|
4
|
+
subject() { (Class.new { include Automan::Mixins::Utils }).new }
|
5
5
|
|
6
6
|
it "adds String#underscore" do
|
7
|
-
|
8
|
-
s.should respond_to :underscore
|
7
|
+
expect(String.new).to respond_to :underscore
|
9
8
|
end
|
10
9
|
|
11
10
|
describe "String#underscore" do
|
12
11
|
it "underscore's like a boss" do
|
13
|
-
"Namespace".underscore.
|
14
|
-
"OptionName".underscore.
|
15
|
-
"Value".underscore.
|
12
|
+
expect("Namespace".underscore).to eq "namespace"
|
13
|
+
expect("OptionName".underscore).to eq "option_name"
|
14
|
+
expect("Value".underscore).to eq "value"
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
it {
|
18
|
+
it { is_expected.to respond_to :region_from_az }
|
20
19
|
|
21
20
|
it "returns az properly" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
expect(subject.region_from_az("us-east-1a")).to eq 'us-east-1'
|
22
|
+
expect(subject.region_from_az("us-east-1b")).to eq 'us-east-1'
|
23
|
+
expect(subject.region_from_az("us-east-1c")).to eq 'us-east-1'
|
24
|
+
expect(subject.region_from_az("us-east-1d")).to eq 'us-east-1'
|
25
|
+
expect(subject.region_from_az("ap-northeast-1a")).to eq 'ap-northeast-1'
|
26
|
+
expect(subject.region_from_az("ap-northeast-1b")).to eq 'ap-northeast-1'
|
27
|
+
expect(subject.region_from_az("ap-northeast-1c")).to eq 'ap-northeast-1'
|
28
|
+
expect(subject.region_from_az("sa-east-1a")).to eq 'sa-east-1'
|
29
|
+
expect(subject.region_from_az("sa-east-1b")).to eq 'sa-east-1'
|
30
|
+
expect(subject.region_from_az("ap-southeast-1a")).to eq 'ap-southeast-1'
|
31
|
+
expect(subject.region_from_az("ap-southeast-1b")).to eq 'ap-southeast-1'
|
32
|
+
expect(subject.region_from_az("ap-southeast-2a")).to eq 'ap-southeast-2'
|
33
|
+
expect(subject.region_from_az("ap-southeast-2b")).to eq 'ap-southeast-2'
|
34
|
+
expect(subject.region_from_az("us-west-2a")).to eq 'us-west-2'
|
35
|
+
expect(subject.region_from_az("us-west-2b")).to eq 'us-west-2'
|
36
|
+
expect(subject.region_from_az("us-west-2c")).to eq 'us-west-2'
|
37
|
+
expect(subject.region_from_az("us-west-1a")).to eq 'us-west-1'
|
38
|
+
expect(subject.region_from_az("us-west-1c")).to eq 'us-west-1'
|
39
|
+
expect(subject.region_from_az("eu-west-1a")).to eq 'eu-west-1'
|
40
|
+
expect(subject.region_from_az("eu-west-1b")).to eq 'eu-west-1'
|
41
|
+
expect(subject.region_from_az("eu-west-1c")).to eq 'eu-west-1'
|
43
42
|
end
|
44
43
|
end
|
data/spec/rds/snapshot_spec.rb
CHANGED
@@ -4,35 +4,35 @@ require 'logger'
|
|
4
4
|
ENV['MAX_SNAPSHOTS'] = "50"
|
5
5
|
|
6
6
|
describe Automan::RDS::Snapshot do
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
7
|
+
it { is_expected.to respond_to :rds }
|
8
|
+
it { is_expected.to respond_to :create }
|
9
|
+
it { is_expected.to respond_to :delete }
|
10
|
+
it { is_expected.to respond_to :prune }
|
11
|
+
it { is_expected.to respond_to :latest }
|
12
|
+
it { is_expected.to respond_to :default_snapshot_name }
|
13
13
|
|
14
14
|
describe '#default_snapshot_name' do
|
15
|
-
subject(
|
15
|
+
subject() do
|
16
16
|
AWS.stub!
|
17
17
|
s = Automan::RDS::Snapshot.new
|
18
18
|
s.logger = Logger.new('/dev/null')
|
19
|
-
s.
|
19
|
+
allow(s).to receive(:db_environment).and_return('dev1')
|
20
20
|
s
|
21
21
|
end
|
22
22
|
|
23
23
|
it "never returns nil" do
|
24
|
-
|
24
|
+
expect(subject.default_snapshot_name('somedb')).to_not be_nil
|
25
25
|
end
|
26
26
|
|
27
|
-
it "returns environment dash
|
28
|
-
name =
|
29
|
-
name.
|
27
|
+
it "returns environment dash time string" do
|
28
|
+
name = subject.default_snapshot_name('somedb')
|
29
|
+
expect(name).to match /^dev1-(\d{4})-(\d{2})-(\d{2})T(\d{2})-(\d{2})/
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#create' do
|
35
|
-
subject(
|
35
|
+
subject() do
|
36
36
|
AWS.stub!
|
37
37
|
s = Automan::RDS::Snapshot.new
|
38
38
|
s.logger = Logger.new('/dev/null')
|
@@ -40,56 +40,56 @@ describe Automan::RDS::Snapshot do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "raises error if could not find database" do
|
43
|
-
|
43
|
+
allow(subject).to receive(:find_db).and_return(nil)
|
44
44
|
expect {
|
45
|
-
|
45
|
+
subject.create
|
46
46
|
}.to raise_error Automan::RDS::DatabaseDoesNotExistError
|
47
47
|
end
|
48
48
|
|
49
49
|
it "raises error if RDS says database does not exist" do
|
50
50
|
db = double(:db)
|
51
|
-
db.
|
52
|
-
|
51
|
+
allow(db).to receive(:exists?).and_return(false)
|
52
|
+
allow(subject).to receive(:find_db).and_return(db)
|
53
53
|
|
54
54
|
expect {
|
55
|
-
|
55
|
+
subject.create
|
56
56
|
}.to raise_error Automan::RDS::DatabaseDoesNotExistError
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#tagged_can_prune?' do
|
62
|
-
subject(
|
62
|
+
subject() do
|
63
63
|
AWS.stub!
|
64
64
|
s = Automan::RDS::Snapshot.new
|
65
65
|
s.logger = Logger.new('/dev/null')
|
66
|
-
s.
|
66
|
+
allow(s).to receive(:snapshot_arn)
|
67
67
|
s
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'returns true if snapshot is tagged with CanPrune=yes' do
|
71
|
-
|
72
|
-
|
71
|
+
allow(subject).to receive(:tags).and_return( {'CanPrune' => 'yes'} )
|
72
|
+
expect(subject.tagged_can_prune?( double() )).to be_truthy
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns false if snapshot is missing CanPrune tag' do
|
76
|
-
|
77
|
-
|
76
|
+
allow(subject).to receive(:tags).and_return( {} )
|
77
|
+
expect(subject.tagged_can_prune?( double() )).to be_falsey
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'returns false if snapshot is tagged with CanPrune=nil' do
|
81
|
-
|
82
|
-
|
81
|
+
allow(subject).to receive(:tags).and_return( {'CanPrune' => nil} )
|
82
|
+
expect(subject.tagged_can_prune?( double() )).to be_falsey
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'returns false if snapshot is tagged with CanPrune=foo' do
|
86
|
-
|
87
|
-
|
86
|
+
allow(subject).to receive(:tags).and_return( {'CanPrune' => 'foo'} )
|
87
|
+
expect(subject.tagged_can_prune?( double() )).to be_falsey
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe '#available?' do
|
92
|
-
subject(
|
92
|
+
subject() do
|
93
93
|
AWS.stub!
|
94
94
|
s = Automan::RDS::Snapshot.new
|
95
95
|
s.logger = Logger.new('/dev/null')
|
@@ -97,21 +97,19 @@ describe Automan::RDS::Snapshot do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'returns true if status is "available"' do
|
100
|
-
snap = double(:
|
101
|
-
|
102
|
-
s.available?(snap).should be_true
|
100
|
+
snap = double(status: 'available')
|
101
|
+
expect(subject.available?(snap)).to be_truthy
|
103
102
|
end
|
104
103
|
|
105
104
|
it 'returns false if status is foo' do
|
106
|
-
snap = double(:
|
107
|
-
|
108
|
-
s.available?(snap).should be_false
|
105
|
+
snap = double(status: 'foo')
|
106
|
+
expect(subject.available?(snap)).to be_falsey
|
109
107
|
end
|
110
108
|
end
|
111
109
|
|
112
110
|
describe '#manual?' do
|
113
111
|
let(:snap) { double }
|
114
|
-
subject(
|
112
|
+
subject() do
|
115
113
|
AWS.stub!
|
116
114
|
s = Automan::RDS::Snapshot.new
|
117
115
|
s.logger = Logger.new('/dev/null')
|
@@ -119,34 +117,34 @@ describe Automan::RDS::Snapshot do
|
|
119
117
|
end
|
120
118
|
|
121
119
|
it 'returns true if type is "manual"' do
|
122
|
-
snap.
|
123
|
-
|
120
|
+
allow(snap).to receive(:snapshot_type).and_return('manual')
|
121
|
+
expect(subject.manual?(snap)).to be_truthy
|
124
122
|
end
|
125
123
|
|
126
124
|
it 'returns false if type is foo' do
|
127
|
-
snap.
|
128
|
-
|
125
|
+
allow(snap).to receive(:snapshot_type).and_return('foo')
|
126
|
+
expect(subject.manual?(snap)).to be_falsey
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
132
130
|
describe '#prunable_snapshots' do
|
133
131
|
let(:snap) { double }
|
134
|
-
subject(
|
132
|
+
subject() do
|
135
133
|
AWS.stub!
|
136
134
|
s = Automan::RDS::Snapshot.new
|
137
135
|
s.logger = Logger.new('/dev/null')
|
138
|
-
s.
|
136
|
+
allow(s).to receive(:get_all_snapshots).and_return( [ snap ] )
|
139
137
|
s
|
140
138
|
end
|
141
139
|
|
142
140
|
it 'includes snapshots which can be pruned' do
|
143
|
-
|
144
|
-
|
141
|
+
allow(subject).to receive(:can_prune?).and_return(true)
|
142
|
+
expect(subject.prunable_snapshots).to include(snap)
|
145
143
|
end
|
146
144
|
|
147
145
|
it 'excludes snapshots which should not be pruned' do
|
148
|
-
|
149
|
-
|
146
|
+
allow(subject).to receive(:can_prune?).and_return(false)
|
147
|
+
expect(subject.prunable_snapshots).to_not include(snap)
|
150
148
|
end
|
151
149
|
end
|
152
150
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# example .env file
|
3
|
+
# cp .env.example .env
|
4
|
+
#
|
5
|
+
# Set environment variables for all template parameters here.
|
6
|
+
# This .env file is in gitignore to help keep application
|
7
|
+
# secrets from leaking out into source code control.
|
8
|
+
#
|
9
|
+
export VPC_ID=vpc-foo
|
10
|
+
export SUBNET_ID=subnet-foo
|
11
|
+
export REMOTE_ACCESS_SG=sg-foo
|
12
|
+
export KEYPAIR_NAME=fookey
|
13
|
+
export INSTANCE_TYPE=m3.medium
|
14
|
+
export IMAGE_ID=ami-foo
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @app_name %>
|
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|