cf_deployer 1.6.0 → 2.0.0
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 +5 -5
- data/.github/workflows/ci.yml +29 -0
- data/.github/workflows/publish.yml +40 -0
- data/.rspec +4 -0
- data/ChangeLog.md +7 -0
- data/QUICKSTART.md +1 -1
- data/Rakefile +1 -1
- data/cf_deployer.gemspec +16 -10
- data/fixtures/vcr_cassettes/aws_call_count/driver/auto_scaling_group/healthy_instance_count.yml +2 -2
- data/lib/cf_deployer/cli.rb +1 -1
- data/lib/cf_deployer/config_loader.rb +2 -2
- data/lib/cf_deployer/config_validation.rb +1 -1
- data/lib/cf_deployer/driver/auto_scaling_group.rb +22 -26
- data/lib/cf_deployer/driver/cloud_formation_driver.rb +28 -18
- data/lib/cf_deployer/driver/elb_driver.rb +11 -4
- data/lib/cf_deployer/driver/instance.rb +4 -3
- data/lib/cf_deployer/driver/route53_driver.rb +17 -9
- data/lib/cf_deployer/logger.rb +10 -11
- data/lib/cf_deployer/stack.rb +18 -30
- data/lib/cf_deployer/status_presenter.rb +1 -1
- data/lib/cf_deployer/version.rb +1 -1
- data/lib/cf_deployer.rb +10 -7
- data/spec/aws_call_count_spec_helper.rb +14 -2
- data/spec/fakes/instance.rb +5 -4
- data/spec/fakes/route53_client.rb +4 -7
- data/spec/spec_helper.rb +11 -2
- data/spec/unit/application_spec.rb +9 -9
- data/spec/unit/component_spec.rb +3 -3
- data/spec/unit/config_loader_spec.rb +70 -69
- data/spec/unit/deployment_strategy/auto_scaling_group_swap_spec.rb +10 -10
- data/spec/unit/deployment_strategy/base_spec.rb +17 -18
- data/spec/unit/deployment_strategy/cname_swap_spec.rb +9 -9
- data/spec/unit/deployment_strategy/create_or_update_spec.rb +8 -8
- data/spec/unit/driver/auto_scaling_group_spec.rb +75 -65
- data/spec/unit/driver/aws_sdk_v3_spec.rb +163 -0
- data/spec/unit/driver/cloud_formation_spec.rb +19 -17
- data/spec/unit/driver/dry_run_spec.rb +8 -8
- data/spec/unit/driver/elb_spec.rb +10 -4
- data/spec/unit/driver/instance_spec.rb +1 -7
- data/spec/unit/driver/route53_spec.rb +34 -25
- data/spec/unit/hook_spec.rb +3 -3
- data/spec/unit/stack_spec.rb +22 -21
- metadata +134 -56
- data/.travis.yml +0 -20
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
describe "load config settings" do
|
|
3
3
|
|
|
4
4
|
before :each do
|
|
5
|
-
Dir.mkdir 'tmp' unless Dir.
|
|
5
|
+
Dir.mkdir 'tmp' unless Dir.exist?('tmp')
|
|
6
6
|
@config_file = File.expand_path("../../../tmp/test_config.yml", __FILE__)
|
|
7
7
|
@base_json = File.expand_path("../../../tmp/base.json", __FILE__)
|
|
8
8
|
@api_json = File.expand_path("../../../tmp/api.json", __FILE__)
|
|
@@ -146,143 +146,143 @@ environments:
|
|
|
146
146
|
|
|
147
147
|
it "all the keys should be symbols in config" do
|
|
148
148
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
149
|
-
config[:components][:base][:'deployment-strategy'].
|
|
150
|
-
config['components'].
|
|
149
|
+
expect(config[:components][:base][:'deployment-strategy']).to eq('create-or-update')
|
|
150
|
+
expect(config['components']).to be_nil
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
it "should copy application, environment, component to component settings" do
|
|
154
154
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
155
|
-
config[:components][:api][:settings][:application].
|
|
156
|
-
config[:components][:api][:settings][:component].
|
|
157
|
-
config[:components][:api][:settings][:environment].
|
|
158
|
-
config[:components][:base][:settings][:application].
|
|
159
|
-
config[:components][:base][:settings][:component].
|
|
160
|
-
config[:components][:base][:settings][:environment].
|
|
155
|
+
expect(config[:components][:api][:settings][:application]).to eq("myApp")
|
|
156
|
+
expect(config[:components][:api][:settings][:component]).to eq("api")
|
|
157
|
+
expect(config[:components][:api][:settings][:environment]).to eq("uat")
|
|
158
|
+
expect(config[:components][:base][:settings][:application]).to eq("myApp")
|
|
159
|
+
expect(config[:components][:base][:settings][:component]).to eq("base")
|
|
160
|
+
expect(config[:components][:base][:settings][:environment]).to eq("uat")
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
it "should copy region to coponent settings" do
|
|
164
164
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat', :region => 'us-west-1'})
|
|
165
|
-
config[:components][:api][:settings][:region].
|
|
166
|
-
config[:components][:base][:settings][:region].
|
|
165
|
+
expect(config[:components][:api][:settings][:region]).to eq("us-west-1")
|
|
166
|
+
expect(config[:components][:base][:settings][:region]).to eq("us-west-1")
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "should copy application, environment, component to component inputs" do
|
|
170
170
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
171
|
-
config[:components][:api][:inputs][:application].
|
|
172
|
-
config[:components][:api][:inputs][:component].
|
|
173
|
-
config[:components][:api][:inputs][:environment].
|
|
174
|
-
config[:components][:base][:inputs][:application].
|
|
175
|
-
config[:components][:base][:inputs][:component].
|
|
176
|
-
config[:components][:base][:inputs][:environment].
|
|
171
|
+
expect(config[:components][:api][:inputs][:application]).to eq("myApp")
|
|
172
|
+
expect(config[:components][:api][:inputs][:component]).to eq("api")
|
|
173
|
+
expect(config[:components][:api][:inputs][:environment]).to eq("uat")
|
|
174
|
+
expect(config[:components][:base][:inputs][:application]).to eq("myApp")
|
|
175
|
+
expect(config[:components][:base][:inputs][:component]).to eq("base")
|
|
176
|
+
expect(config[:components][:base][:inputs][:environment]).to eq("uat")
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
it "should copy region to coponent inputs" do
|
|
180
180
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat', :region => 'us-west-1'})
|
|
181
|
-
config[:components][:api][:inputs][:region].
|
|
182
|
-
config[:components][:base][:inputs][:region].
|
|
181
|
+
expect(config[:components][:api][:inputs][:region]).to eq("us-west-1")
|
|
182
|
+
expect(config[:components][:base][:inputs][:region]).to eq("us-west-1")
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
it "config_dir option should be copied to component context" do
|
|
186
186
|
config_dir = File.dirname(@config_file)
|
|
187
187
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
188
|
-
config[:components][:api][:config_dir].
|
|
189
|
-
config[:components][:base][:config_dir].
|
|
190
|
-
config[:components][:'front-end'][:config_dir].
|
|
188
|
+
expect(config[:components][:api][:config_dir]).to eq(config_dir)
|
|
189
|
+
expect(config[:components][:base][:config_dir]).to eq(config_dir)
|
|
190
|
+
expect(config[:components][:'front-end'][:config_dir]).to eq(config_dir)
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
it "notify option should be merged to component context" do
|
|
194
194
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'dev'})
|
|
195
|
-
config[:components][:base][:notify].
|
|
196
|
-
config[:components][:api][:notify].
|
|
197
|
-
config[:components][:'front-end'][:notify].
|
|
195
|
+
expect(config[:components][:base][:notify]).to eq(['arn:root', 'arn:base', 'arn:dev'])
|
|
196
|
+
expect(config[:components][:api][:notify]).to eq(['arn:root', 'arn:api', 'arn:dev'])
|
|
197
|
+
expect(config[:components][:'front-end'][:notify]).to eq(['arn:root', 'arn:base', 'arn:dev'])
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
it "notify option should be merged to environment context" do
|
|
201
201
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
202
|
-
config[:components][:base][:notify].
|
|
203
|
-
config[:components][:api][:notify].
|
|
204
|
-
config[:components][:'front-end'][:notify].
|
|
202
|
+
expect(config[:components][:base][:notify]).to eq(['arn:root', 'arn:base'])
|
|
203
|
+
expect(config[:components][:api][:notify]).to eq(['arn:root', 'arn:api'])
|
|
204
|
+
expect(config[:components][:'front-end'][:notify]).to eq(['arn:root', 'arn:base'])
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
it "tags option should be copied to component context" do
|
|
208
208
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
209
|
-
config[:components][:api][:tags].
|
|
210
|
-
config[:components][:base][:tags].
|
|
211
|
-
config[:components][:'front-end'][:tags].
|
|
209
|
+
expect(config[:components][:api][:tags]).to eq({:version => 'v1.1'})
|
|
210
|
+
expect(config[:components][:base][:tags]).to eq({:version => 'v1.1', :component => 'base'})
|
|
211
|
+
expect(config[:components][:'front-end'][:tags]).to eq({:version => 'v1.1'})
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
it "component's settings should be merged to common settings" do
|
|
216
216
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'uat'})
|
|
217
|
-
config[:components][:api][:inputs][:'timeout'].
|
|
218
|
-
config[:components][:api][:inputs][:'require-basic-auth'].
|
|
219
|
-
config[:components][:api][:inputs][:'mail-server'].
|
|
217
|
+
expect(config[:components][:api][:inputs][:'timeout']).to eq(90)
|
|
218
|
+
expect(config[:components][:api][:inputs][:'require-basic-auth']).to eq(true)
|
|
219
|
+
expect(config[:components][:api][:inputs][:'mail-server']).to eq('http://api.abc.com')
|
|
220
220
|
end
|
|
221
221
|
|
|
222
222
|
|
|
223
223
|
it "environment's settings should be merged to component settings" do
|
|
224
224
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'dev'})
|
|
225
|
-
config[:components][:api][:inputs][:'timeout'].
|
|
226
|
-
config[:components][:api][:inputs][:'require-basic-auth'].
|
|
227
|
-
config[:components][:api][:inputs][:'mail-server'].
|
|
225
|
+
expect(config[:components][:api][:inputs][:'timeout']).to eq(60)
|
|
226
|
+
expect(config[:components][:api][:inputs][:'require-basic-auth']).to eq(true)
|
|
227
|
+
expect(config[:components][:api][:inputs][:'mail-server']).to eq('http://dev.abc.com')
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
it "should merge environment's components to component settings" do
|
|
231
231
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'production'})
|
|
232
|
-
config[:components][:'front-end'][:inputs][:'cname'].
|
|
233
|
-
config[:components][:api][:inputs][:'cname'].
|
|
232
|
+
expect(config[:components][:'front-end'][:inputs][:'cname']).to eq('prod-front-end.myserver.com')
|
|
233
|
+
expect(config[:components][:api][:inputs][:'cname']).to eq('myserver.com')
|
|
234
234
|
end
|
|
235
235
|
|
|
236
236
|
it "environment variables without prefix 'cfdeploy_settings_' should not be merged to components settings" do
|
|
237
237
|
ENV['timeout'] = "180"
|
|
238
238
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'dev'})
|
|
239
|
-
config[:components][:api][:inputs][:'timeout'].
|
|
239
|
+
expect(config[:components][:api][:inputs][:'timeout']).to eq(60)
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
it "should merge environment variables should be merged to components settings" do
|
|
243
243
|
ENV['cfdeploy_inputs_timeout'] = "180"
|
|
244
244
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'dev'})
|
|
245
|
-
config[:components][:api][:inputs][:'timeout'].
|
|
245
|
+
expect(config[:components][:api][:inputs][:'timeout']).to eq("180")
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
it "cli settings should be merged to components settings" do
|
|
249
249
|
ENV['cfdeploy_settings_timeout'] = "180"
|
|
250
250
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file, :environment => 'dev',:cli_overrides => {:settings => {:timeout => 45}}})
|
|
251
|
-
config[:components][:api][:settings][:'timeout'].
|
|
251
|
+
expect(config[:components][:api][:settings][:'timeout']).to eq(45)
|
|
252
252
|
end
|
|
253
253
|
|
|
254
254
|
it "should set cloudFormation parameter names into each component" do
|
|
255
255
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
256
|
-
config[:components][:base][:defined_parameters].
|
|
257
|
-
config[:components][:api][:defined_parameters].
|
|
258
|
-
config[:components][:'front-end'][:defined_parameters].
|
|
256
|
+
expect(config[:components][:base][:defined_parameters]).to eq({})
|
|
257
|
+
expect(config[:components][:api][:defined_parameters]).to eq({:'require-basic-auth' => {:Default => "true"}})
|
|
258
|
+
expect(config[:components][:'front-end'][:defined_parameters]).to eq({:'require-basic-auth' => {}, :'mail-server' => {}})
|
|
259
259
|
end
|
|
260
260
|
|
|
261
261
|
it "should set cloudFormation output names into each component" do
|
|
262
262
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
263
|
-
config[:components][:base][:defined_outputs].
|
|
264
|
-
config[:components][:api][:defined_outputs].
|
|
265
|
-
config[:components][:'front-end'][:defined_outputs].
|
|
263
|
+
expect(config[:components][:base][:defined_outputs]).to eq({:'vpc-id' => {}, :'AutoScalingGroupName'=>{}, :'public-subnet-id'=>{}})
|
|
264
|
+
expect(config[:components][:api][:defined_outputs]).to eq({})
|
|
265
|
+
expect(config[:components][:'front-end'][:defined_outputs]).to eq({:'AutoScalingGroupName'=>{}, :'elb-cname' => {}})
|
|
266
266
|
end
|
|
267
267
|
|
|
268
268
|
it "should remove common settings in order not to confuse us" do
|
|
269
269
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
270
|
-
config[:settings].
|
|
270
|
+
expect(config[:settings]).to be_nil
|
|
271
271
|
end
|
|
272
272
|
|
|
273
273
|
it "should set default elb-name-output for cname-swap strategy" do
|
|
274
274
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
275
|
-
config[:components][:'front-end'][:settings][:'elb-name-output'].
|
|
275
|
+
expect(config[:components][:'front-end'][:settings][:'elb-name-output']).to eq('ELBName')
|
|
276
276
|
end
|
|
277
277
|
|
|
278
278
|
it "should set default auto-scaling-group-name-output for cname-swap strategy" do
|
|
279
279
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
280
|
-
config[:components][:api][:settings][:'auto-scaling-group-name-output'].
|
|
280
|
+
expect(config[:components][:api][:settings][:'auto-scaling-group-name-output']).to eq([ CfDeployer::Defaults::AutoScalingGroupName ])
|
|
281
281
|
end
|
|
282
282
|
|
|
283
283
|
it "should set auto-scaling-group-name-output to default if auto-scaling-group-name exists in output for create-or-update strategy" do
|
|
284
284
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
285
|
-
config[:components][:base][:settings][:'auto-scaling-group-name-output'].
|
|
285
|
+
expect(config[:components][:base][:settings][:'auto-scaling-group-name-output']).to eq([ CfDeployer::Defaults::AutoScalingGroupName ])
|
|
286
286
|
end
|
|
287
287
|
|
|
288
288
|
it "should not set auto-scaling-group-name-output to default if auto-scaling-group-name does not exists in output for create-or-update strategy" do
|
|
@@ -295,17 +295,17 @@ environments:
|
|
|
295
295
|
|
|
296
296
|
File.open(@base_json, 'w') {|f| f.write(base_json) }
|
|
297
297
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
298
|
-
config[:components][:'base'][:settings][:'auto-scaling-group-name-output'].
|
|
298
|
+
expect(config[:components][:'base'][:settings][:'auto-scaling-group-name-output']).to be_nil
|
|
299
299
|
end
|
|
300
300
|
|
|
301
301
|
it "should set auto-scaling-group-name-output to default if auto-scaling-group-name exists in output for cname-swap strategy" do
|
|
302
302
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
303
|
-
config[:components][:'front-end'][:settings][:'auto-scaling-group-name-output'].
|
|
303
|
+
expect(config[:components][:'front-end'][:settings][:'auto-scaling-group-name-output']).to eq([ CfDeployer::Defaults::AutoScalingGroupName ])
|
|
304
304
|
end
|
|
305
305
|
|
|
306
306
|
it "should set raise-error-for-unused-inputs to default" do
|
|
307
307
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
308
|
-
config[:components][:'front-end'][:settings][:'raise-error-for-unused-inputs'].
|
|
308
|
+
expect(config[:components][:'front-end'][:settings][:'raise-error-for-unused-inputs']).to eq(CfDeployer::Defaults::RaiseErrorForUnusedInputs)
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
it "should not set auto-scaling-group-name-output to default if auto-scaling-group-name does not exists in output for cname-swap strategy" do
|
|
@@ -319,23 +319,23 @@ environments:
|
|
|
319
319
|
|
|
320
320
|
File.open(@front_end_json, 'w') {|f| f.write(front_end_json) }
|
|
321
321
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
322
|
-
config[:components][:'front-end'][:settings][:'auto-scaling-group-name-output'].
|
|
322
|
+
expect(config[:components][:'front-end'][:settings][:'auto-scaling-group-name-output']).to be_nil
|
|
323
323
|
end
|
|
324
324
|
|
|
325
325
|
it "should ERB the config file and provide the environment in the binding" do
|
|
326
326
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file, :environment => 'DrWho')
|
|
327
|
-
config[:components][:base][:inputs][:'foobar'].
|
|
327
|
+
expect(config[:components][:base][:inputs][:'foobar']).to eq('DrWho.IsGreat')
|
|
328
328
|
end
|
|
329
329
|
|
|
330
330
|
it "should ERB the component JSON and make the parsed template available" do
|
|
331
331
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file, :environment => 'DrWho')
|
|
332
|
-
CfDeployer::ConfigLoader.erb_to_json('json-with-erb', config[:components][:'json-with-erb']).
|
|
332
|
+
expect(CfDeployer::ConfigLoader.erb_to_json('json-with-erb', config[:components][:'json-with-erb'])).to include('DrWho')
|
|
333
333
|
end
|
|
334
334
|
|
|
335
335
|
it 'should use error_document to show the broken document when parsing broken ERB' do
|
|
336
336
|
config = { :config_dir => File.dirname(@config_file) }
|
|
337
|
-
CfDeployer::ConfigLoader.
|
|
338
|
-
expect { CfDeployer::ConfigLoader.erb_to_json('broken_erb', config) }.to raise_error
|
|
337
|
+
allow_any_instance_of(CfDeployer::ConfigLoader).to receive(:error_document)
|
|
338
|
+
expect { CfDeployer::ConfigLoader.erb_to_json('broken_erb', config) }.to raise_error(TypeError)
|
|
339
339
|
end
|
|
340
340
|
|
|
341
341
|
it 'should use error_document to show the broken document when parsing broken json' do
|
|
@@ -347,35 +347,36 @@ environments:
|
|
|
347
347
|
:defined_parameters => {},
|
|
348
348
|
:defined_outputs => {}
|
|
349
349
|
}
|
|
350
|
-
CfDeployer::ConfigLoader.
|
|
351
|
-
|
|
350
|
+
allow_any_instance_of(CfDeployer::ConfigLoader).to receive(:error_document)
|
|
351
|
+
|
|
352
|
+
expect { loader.send(:cf_template, 'broken_json') }.to raise_error(RuntimeError)
|
|
352
353
|
end
|
|
353
354
|
|
|
354
355
|
it 'should use error_document to show the broken document when parsing broken yaml' do
|
|
355
|
-
CfDeployer::ConfigLoader.
|
|
356
|
-
expect { CfDeployer::ConfigLoader.new.send(:load_yaml, @broken_yaml) }.to raise_error
|
|
356
|
+
allow_any_instance_of(CfDeployer::ConfigLoader).to receive(:error_document)
|
|
357
|
+
expect { CfDeployer::ConfigLoader.new.send(:load_yaml, @broken_yaml) }.to raise_error(Psych::SyntaxError)
|
|
357
358
|
end
|
|
358
359
|
|
|
359
360
|
it 'should set default keep-previous-stack to true' do
|
|
360
361
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file)
|
|
361
|
-
config[:components][:api][:settings][:'keep-previous-stack'].
|
|
362
|
+
expect(config[:components][:api][:settings][:'keep-previous-stack']).to eq(CfDeployer::Defaults::KeepPreviousStack)
|
|
362
363
|
end
|
|
363
364
|
|
|
364
365
|
it 'should keep keep-previous-stack setting' do
|
|
365
366
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file)
|
|
366
|
-
config[:components][:'front-end'][:settings][:'keep-previous-stack'].
|
|
367
|
+
expect(config[:components][:'front-end'][:settings][:'keep-previous-stack']).to be_falsey
|
|
367
368
|
end
|
|
368
369
|
|
|
369
370
|
context 'targets' do
|
|
370
371
|
|
|
371
372
|
it 'should use all components as targets if no targets are specified' do
|
|
372
373
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file)
|
|
373
|
-
config[:targets].
|
|
374
|
+
expect(config[:targets]).to eq(['base', 'api', 'front-end', 'very-simple', 'json-with-erb'])
|
|
374
375
|
end
|
|
375
376
|
|
|
376
377
|
it 'should keep targets if targets are specified' do
|
|
377
378
|
config = CfDeployer::ConfigLoader.new.load(:'config-file' => @config_file, :component => ['api', 'web'])
|
|
378
|
-
config[:targets].
|
|
379
|
+
expect(config[:targets]).to eq(['api', 'web'])
|
|
379
380
|
end
|
|
380
381
|
|
|
381
382
|
end
|
|
@@ -418,7 +419,7 @@ components:
|
|
|
418
419
|
File.open(@config_file, 'w') {|f| f.write(config) }
|
|
419
420
|
|
|
420
421
|
config = CfDeployer::ConfigLoader.new.load({:'config-file' => @config_file})
|
|
421
|
-
config[:components][:'api'][:defined_parameters].
|
|
422
|
+
expect(config[:components][:'api'][:defined_parameters]).to eq({ db:'base::elb-cname', url:'http://abc.com'})
|
|
422
423
|
end
|
|
423
424
|
|
|
424
425
|
end
|
|
@@ -35,18 +35,18 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
35
35
|
it 'no if no G and B stacks exist' do
|
|
36
36
|
blue_stack.die!
|
|
37
37
|
green_stack.die!
|
|
38
|
-
CfDeployer::DeploymentStrategy.create(app, env, component, context).exists
|
|
38
|
+
expect(CfDeployer::DeploymentStrategy.create(app, env, component, context).exists?).to be_falsey
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'yes if B stacks exist' do
|
|
42
42
|
blue_stack.live!
|
|
43
43
|
green_stack.die!
|
|
44
|
-
CfDeployer::DeploymentStrategy.create(app, env, component, context).exists
|
|
44
|
+
expect(CfDeployer::DeploymentStrategy.create(app, env, component, context).exists?).to be_truthy
|
|
45
45
|
end
|
|
46
46
|
it 'yes if G stacks exist' do
|
|
47
47
|
blue_stack.die!
|
|
48
48
|
green_stack.live!
|
|
49
|
-
CfDeployer::DeploymentStrategy.create(app, env, component, context).exists
|
|
49
|
+
expect(CfDeployer::DeploymentStrategy.create(app, env, component, context).exists?).to be_truthy
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
end
|
|
@@ -123,7 +123,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
123
123
|
@log += "#{arg[:parameters][:name]} deleted."
|
|
124
124
|
end
|
|
125
125
|
CfDeployer::DeploymentStrategy.create(app, env, component, context).destroy
|
|
126
|
-
@log.
|
|
126
|
+
expect(@log).to eq('green deleted.blue deleted.')
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -601,7 +601,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
601
601
|
allow(green_asg_driver).to receive(:describe) {{desired: 0, min: 0, max: 0}}
|
|
602
602
|
allow(blue_asg_driver).to receive(:describe) {{desired: 3, min: 1, max: 5}}
|
|
603
603
|
asg_swap = CfDeployer::DeploymentStrategy.create(app, env, component, context)
|
|
604
|
-
asg_swap.output_value("AutoScalingGroupID").
|
|
604
|
+
expect(asg_swap.output_value("AutoScalingGroupID")).to eq("blueASG")
|
|
605
605
|
end
|
|
606
606
|
|
|
607
607
|
it 'should get the information where the value comes from if the active stack does not exist' do
|
|
@@ -612,7 +612,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
612
612
|
allow(green_asg_driver).to receive(:describe) {{desired: 0, min: 0, max: 0}}
|
|
613
613
|
allow(blue_asg_driver).to receive(:describe) {{desired: 0, min: 0, max: 0}}
|
|
614
614
|
asg_swap = CfDeployer::DeploymentStrategy.create(app, env, component, context)
|
|
615
|
-
asg_swap.output_value(:a_key).
|
|
615
|
+
expect(asg_swap.output_value(:a_key)).to eq("The value will be referenced from the output a_key of undeployed component worker")
|
|
616
616
|
end
|
|
617
617
|
end
|
|
618
618
|
|
|
@@ -642,7 +642,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
642
642
|
:status => 'green deployed'
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
|
-
asg_swap.status.
|
|
645
|
+
expect(asg_swap.status).to eq(expected_result)
|
|
646
646
|
end
|
|
647
647
|
|
|
648
648
|
it 'should get status for both green and blue stacks including resources info' do
|
|
@@ -667,7 +667,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
-
asg_swap.status(true).
|
|
670
|
+
expect(asg_swap.status(true)).to eq(expected_result)
|
|
671
671
|
end
|
|
672
672
|
end
|
|
673
673
|
|
|
@@ -686,7 +686,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
686
686
|
allow(blue_stack).to receive(:resource_statuses) { asg_ids('foo', 'bar') }
|
|
687
687
|
|
|
688
688
|
asg_swap = CfDeployer::DeploymentStrategy.create(app, env, component, context)
|
|
689
|
-
asg_swap.send(:get_active_asgs, blue_stack).
|
|
689
|
+
expect(asg_swap.send(:get_active_asgs, blue_stack)).to eq(['foo'])
|
|
690
690
|
end
|
|
691
691
|
end
|
|
692
692
|
|
|
@@ -700,7 +700,7 @@ describe 'Auto Scaling Group Swap Deployment Strategy' do
|
|
|
700
700
|
allow(green_asg_driver).to receive(:describe) { {min: 0, desired: 0, max: 0} }
|
|
701
701
|
|
|
702
702
|
asg_swap = CfDeployer::DeploymentStrategy.create(app, env, component, context)
|
|
703
|
-
asg_swap.send(:stack_active?, blue_stack).
|
|
703
|
+
expect(asg_swap.send(:stack_active?, blue_stack)).to be(true)
|
|
704
704
|
end
|
|
705
705
|
end
|
|
706
706
|
|
|
@@ -57,12 +57,11 @@ describe 'Base Deployment Strategy' do
|
|
|
57
57
|
|
|
58
58
|
it "should return nil if there is no active stack" do
|
|
59
59
|
the_stack = double()
|
|
60
|
-
the_stack.
|
|
61
|
-
the_stack.
|
|
60
|
+
expect(the_stack).to receive(:exists?).and_return(false)
|
|
61
|
+
expect(the_stack).not_to receive(:template)
|
|
62
62
|
|
|
63
63
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
64
|
-
strategy.
|
|
65
|
-
# strategy.should_not_receive(:get_parameters_outputs)
|
|
64
|
+
expect(strategy).to receive(:active_stack).and_return(the_stack)
|
|
66
65
|
|
|
67
66
|
expect( strategy.active_template ).to eq(nil)
|
|
68
67
|
end
|
|
@@ -71,11 +70,11 @@ describe 'Base Deployment Strategy' do
|
|
|
71
70
|
the_template = double
|
|
72
71
|
|
|
73
72
|
the_stack = double
|
|
74
|
-
the_stack.
|
|
75
|
-
the_stack.
|
|
73
|
+
expect(the_stack).to receive(:exists?).and_return(true)
|
|
74
|
+
expect(the_stack).to receive(:template).and_return(the_template)
|
|
76
75
|
|
|
77
76
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
78
|
-
strategy.
|
|
77
|
+
expect(strategy).to receive(:active_stack).and_return(the_stack)
|
|
79
78
|
|
|
80
79
|
expect( strategy.active_template ).to eq(the_template)
|
|
81
80
|
end
|
|
@@ -96,8 +95,8 @@ describe 'Base Deployment Strategy' do
|
|
|
96
95
|
|
|
97
96
|
it "should run the specified hook" do
|
|
98
97
|
hook = double()
|
|
99
|
-
CfDeployer::Hook.
|
|
100
|
-
hook.
|
|
98
|
+
expect(CfDeployer::Hook).to receive(:new).and_return(hook)
|
|
99
|
+
expect(hook).to receive(:run)
|
|
101
100
|
|
|
102
101
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
103
102
|
strategy.instance_variable_set('@params_and_outputs_resolved', true)
|
|
@@ -107,30 +106,30 @@ describe 'Base Deployment Strategy' do
|
|
|
107
106
|
it "should not try to resolve parameters and outputs they're already initialized" do
|
|
108
107
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
109
108
|
strategy.instance_variable_set('@params_and_outputs_resolved', true)
|
|
110
|
-
strategy.
|
|
109
|
+
expect(strategy).not_to receive(:get_parameters_outputs)
|
|
111
110
|
strategy.run_hook(:some_hook)
|
|
112
111
|
end
|
|
113
112
|
|
|
114
113
|
it "should not try to resolve parameters and outputs if there's no running stack" do
|
|
115
114
|
the_stack = double()
|
|
116
|
-
the_stack.
|
|
117
|
-
the_stack.
|
|
115
|
+
expect(the_stack).to receive(:exists?).and_return(false)
|
|
116
|
+
expect(the_stack).to receive(:name).and_return("thestack")
|
|
118
117
|
|
|
119
118
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
120
|
-
strategy.
|
|
121
|
-
strategy.
|
|
119
|
+
expect(strategy).to receive(:active_stack).and_return(the_stack)
|
|
120
|
+
expect(strategy).not_to receive(:get_parameters_outputs)
|
|
122
121
|
strategy.run_hook(:some_hook)
|
|
123
122
|
end
|
|
124
123
|
|
|
125
124
|
it "should not try to run a hook if there's no running stack" do
|
|
126
|
-
CfDeployer::Hook.
|
|
125
|
+
expect(CfDeployer::Hook).not_to receive(:new)
|
|
127
126
|
|
|
128
127
|
the_stack = double()
|
|
129
|
-
the_stack.
|
|
130
|
-
the_stack.
|
|
128
|
+
expect(the_stack).to receive(:exists?).and_return(false)
|
|
129
|
+
expect(the_stack).to receive(:name).and_return("thestack")
|
|
131
130
|
|
|
132
131
|
strategy = CfDeployer::DeploymentStrategy.create('myApp', 'uat', 'web', @context[:components][:web])
|
|
133
|
-
strategy.
|
|
132
|
+
expect(strategy).to receive(:active_stack).and_return(the_stack)
|
|
134
133
|
strategy.run_hook(:some_hook)
|
|
135
134
|
end
|
|
136
135
|
end
|
|
@@ -66,7 +66,7 @@ describe CfDeployer::DeploymentStrategy::CnameSwap do
|
|
|
66
66
|
end
|
|
67
67
|
expect(dns_driver).to receive(:delete_record_set).with('foobar.com', 'test.foobar.com')
|
|
68
68
|
cname_swap.destroy
|
|
69
|
-
@log.
|
|
69
|
+
expect(@log).to eq('green deleted.blue deleted.')
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -188,19 +188,19 @@ describe CfDeployer::DeploymentStrategy::CnameSwap do
|
|
|
188
188
|
blue_stack.die!
|
|
189
189
|
green_stack.die!
|
|
190
190
|
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', @context)
|
|
191
|
-
cname_swap.exists
|
|
191
|
+
expect(cname_swap.exists?).to be_falsey
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
it 'yes, if green stack exists and blue stack does not' do
|
|
195
195
|
blue_stack.die!
|
|
196
196
|
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', @context)
|
|
197
|
-
cname_swap.exists
|
|
197
|
+
expect(cname_swap.exists?).to be_truthy
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
it 'yes, if blue stack exists and green stack does not' do
|
|
201
201
|
green_stack.die!
|
|
202
202
|
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', @context)
|
|
203
|
-
cname_swap.exists
|
|
203
|
+
expect(cname_swap.exists?).to be_truthy
|
|
204
204
|
end
|
|
205
205
|
end
|
|
206
206
|
|
|
@@ -220,7 +220,7 @@ describe CfDeployer::DeploymentStrategy::CnameSwap do
|
|
|
220
220
|
my_context.delete :dns_driver
|
|
221
221
|
my_context[:settings][:'dns-driver'] = 'CfDeployer::Driver::Verisign'
|
|
222
222
|
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', my_context)
|
|
223
|
-
cname_swap.send(:dns_driver).class.to_s.
|
|
223
|
+
expect(cname_swap.send(:dns_driver).class.to_s).to eq(my_context[:settings][:'dns-driver'])
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
226
|
|
|
@@ -283,14 +283,14 @@ describe CfDeployer::DeploymentStrategy::CnameSwap do
|
|
|
283
283
|
|
|
284
284
|
it 'should get stack output if active stack exists' do
|
|
285
285
|
allow(dns_driver).to receive(:find_alias_target).with('foobar.com', 'test.foobar.com'){ 'BLUE-elb.aws.amazon.com' }
|
|
286
|
-
|
|
287
|
-
cname_swap.output_value("AutoScalingGroupID").
|
|
286
|
+
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', @context)
|
|
287
|
+
expect(cname_swap.output_value("AutoScalingGroupID")).to eq("blueASG")
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
it 'should get the information where the value comes from if the active stack does not exist' do
|
|
291
291
|
allow(dns_driver).to receive(:find_alias_target).with('foobar.com', 'test.foobar.com'){ '' }
|
|
292
|
-
|
|
293
|
-
cname_swap.output_value(:a_key).
|
|
292
|
+
cname_swap = CfDeployer::DeploymentStrategy.create('myapp', 'dev', 'web', @context)
|
|
293
|
+
expect(cname_swap.output_value(:a_key)).to eq("The value will be referenced from the output a_key of undeployed component web")
|
|
294
294
|
end
|
|
295
295
|
end
|
|
296
296
|
end
|
|
@@ -33,7 +33,7 @@ describe 'CreateOrUpdate Strategy' do
|
|
|
33
33
|
expect(@after_create_hook).to receive(:run) do |given_context|
|
|
34
34
|
hook_context = given_context
|
|
35
35
|
end
|
|
36
|
-
@stack.
|
|
36
|
+
expect(@stack).to receive(:exists?).and_return(false)
|
|
37
37
|
expect(@stack).to receive(:deploy)
|
|
38
38
|
@create_or_update.deploy
|
|
39
39
|
expect(hook_context[:parameters]).to eq( {'vpc' => 'myvpc'} )
|
|
@@ -45,7 +45,7 @@ describe 'CreateOrUpdate Strategy' do
|
|
|
45
45
|
expect(@after_update_hook).to receive(:run) do |given_context|
|
|
46
46
|
hook_context = given_context
|
|
47
47
|
end
|
|
48
|
-
@stack.
|
|
48
|
+
expect(@stack).to receive(:exists?).and_return(true)
|
|
49
49
|
expect(@stack).to receive(:deploy)
|
|
50
50
|
@create_or_update.deploy
|
|
51
51
|
expect(hook_context[:parameters]).to eq( {'vpc' => 'myvpc'} )
|
|
@@ -60,7 +60,7 @@ describe 'CreateOrUpdate Strategy' do
|
|
|
60
60
|
context = @context[:components][:base]
|
|
61
61
|
context[:settings] = {}
|
|
62
62
|
context[:settings][:'auto-scaling-group-name-output'] = ['AutoScalingGroupID']
|
|
63
|
-
@stack.
|
|
63
|
+
expect(@stack).to receive(:exists?).and_return(false)
|
|
64
64
|
allow(@stack).to receive(:find_output).with('AutoScalingGroupID') { 'asg_name' }
|
|
65
65
|
allow(CfDeployer::Driver::AutoScalingGroup).to receive(:new).with('asg_name') { asg_driver }
|
|
66
66
|
allow(asg_driver).to receive(:describe) { {desired:2, min:1, max:3} }
|
|
@@ -74,19 +74,19 @@ describe 'CreateOrUpdate Strategy' do
|
|
|
74
74
|
|
|
75
75
|
it 'should tell if stack exists' do
|
|
76
76
|
expect(@stack).to receive(:exists?){true}
|
|
77
|
-
@create_or_update.exists
|
|
77
|
+
expect(@create_or_update.exists?).to eq(true)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it 'should get stack output' do
|
|
81
81
|
allow(@stack).to receive(:exists?){true}
|
|
82
82
|
expect(@stack).to receive(:output).with(:a_key){ "output_value" }
|
|
83
|
-
@create_or_update.output_value(:a_key).
|
|
83
|
+
expect(@create_or_update.output_value(:a_key)).to eq("output_value")
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it 'should get the information where the value comes from if the stack does not exist' do
|
|
87
87
|
allow(@stack).to receive(:exists?){false}
|
|
88
88
|
expect(@stack).not_to receive(:output).with(anything)
|
|
89
|
-
@create_or_update.output_value(:a_key).
|
|
89
|
+
expect(@create_or_update.output_value(:a_key)).to eq("The value will be referenced from the output a_key of undeployed component base")
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
context '#destroy' do
|
|
@@ -119,11 +119,11 @@ describe 'CreateOrUpdate Strategy' do
|
|
|
119
119
|
allow(@stack).to receive(:exists?) { true }
|
|
120
120
|
end
|
|
121
121
|
it 'should get status from stack' do
|
|
122
|
-
@create_or_update.status.
|
|
122
|
+
expect(@create_or_update.status).to eq({ 'base-uat' => {status: 'deployed'}})
|
|
123
123
|
end
|
|
124
124
|
it 'should get status from stack including resource info' do
|
|
125
125
|
allow(@stack).to receive(:resource_statuses) { 'resource1' }
|
|
126
|
-
@create_or_update.status(true).
|
|
126
|
+
expect(@create_or_update.status(true)).to eq({ 'base-uat' => {status: 'deployed', resources: 'resource1'}})
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
end
|