eb_deployer 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +5 -0
- data/lib/eb_deployer/application.rb +0 -1
- data/lib/eb_deployer/config_loader.rb +1 -0
- data/lib/eb_deployer/deployment_strategy/blue_green.rb +11 -11
- data/lib/eb_deployer/eb_environment.rb +23 -23
- data/lib/eb_deployer/event_poller.rb +9 -9
- data/lib/eb_deployer/version.rb +1 -1
- data/lib/eb_deployer.rb +5 -3
- data/test/aws_driver_stubs.rb +21 -8
- data/test/blue_green_deploy_test.rb +106 -0
- data/test/config_loader_test.rb +13 -0
- data/test/deploy_test.rb +1 -444
- data/test/eb_environment_test.rb +61 -6
- data/test/inplace_update_deploy_test.rb +85 -0
- data/test/legacy_env_migrate_deploy_test.rb +94 -0
- data/test/resources_deploy_test.rb +122 -0
- data/test/tier_setting_deploy_test.rb +19 -0
- data/test/versions_deploy_test.rb +120 -0
- metadata +30 -16
data/test/deploy_test.rb
CHANGED
@@ -8,450 +8,7 @@ class DeployTest < MiniTest::Unit::TestCase
|
|
8
8
|
@sample_package = sample_file('app-package.war')
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
File.open('mingle_package.yml', 'w') do |f|
|
13
|
-
f.write("s3_bucket: test-bucket\n")
|
14
|
-
f.write("s3_key: test-mingle.war")
|
15
|
-
end
|
16
|
-
|
17
|
-
deploy(:application => 'simple', :environment => "production",
|
18
|
-
:package => 'mingle_package.yml', :version_label => 1)
|
19
|
-
assert @eb_driver.application_exists?('simple')
|
20
|
-
last_version = @eb_driver.application_versions('simple').last
|
21
|
-
assert_equal({'s3_bucket' => 'test-bucket', 's3_key' => 'test-mingle.war'}, last_version[:source_bundle])
|
22
|
-
ensure
|
23
|
-
FileUtils.rm_rf('mingle_package.yml')
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_first_deployment_create_eb_application
|
27
|
-
assert !@eb_driver.application_exists?('simple')
|
28
|
-
deploy(:application => 'simple', :environment => "production")
|
29
|
-
assert @eb_driver.application_exists?('simple')
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_set_option_settings_on_deployment
|
33
|
-
redudant = [{:namespace => 'aws:autoscaling:launchconfiguration',
|
34
|
-
:option_name => 'MinSize',
|
35
|
-
:value => '2' }]
|
36
|
-
deploy(:application => 'simple', :environment => "production",
|
37
|
-
:option_settings => [redudant])
|
38
|
-
|
39
|
-
assert_equal [redudant], @eb_driver.environment_settings('simple', 'production')
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_destroy_should_clean_up_eb_application_and_env
|
44
|
-
deploy(:application => 'simple', :environment => "production")
|
45
|
-
destroy(:application => 'simple')
|
46
|
-
assert !@eb_driver.application_exists?('simple')
|
47
|
-
assert !@eb_driver.environment_exists?('simple', 'production')
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_first_deployment_create_environment
|
51
|
-
assert !@eb_driver.environment_exists?('simple', 'production')
|
52
|
-
deploy(:application => 'simple', :environment => "production")
|
53
|
-
assert @eb_driver.environment_exists?('simple', 'production')
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_support_very_very_long_app_name
|
57
|
-
deploy(:application => 'ver-very-simple-application', :environment => "production")
|
58
|
-
assert @eb_driver.environment_exists?('ver-very-simple-application', 'production')
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_should_raise_error_when_env_name_is_too_long
|
62
|
-
assert_raises(RuntimeError) { deploy(:application => 'simple', :environment => "p" * 24) }
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_update_environment_with_new_version_should_change_version_that_deployed
|
66
|
-
deploy(:application => 'simple',
|
67
|
-
:environment => "production",
|
68
|
-
:version_label => 1)
|
69
|
-
assert_equal '1', @eb_driver.environment_verion_label('simple', 'production')
|
70
|
-
|
71
|
-
deploy(:application => 'simple',
|
72
|
-
:environment => "production",
|
73
|
-
:version_label => 2)
|
74
|
-
|
75
|
-
assert_equal '2', @eb_driver.environment_verion_label('simple', 'production')
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_version_prefix_should_be_prepended_to_version_label
|
79
|
-
deploy(:application => 'simple',
|
80
|
-
:environment => "production",
|
81
|
-
:version_label => 1,
|
82
|
-
:version_prefix => "prod-")
|
83
|
-
assert_equal 'prod-1', @eb_driver.environment_verion_label('simple', 'production')
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_should_keep_only_number_of_versions_specified
|
87
|
-
deploy(:application => 'simple',
|
88
|
-
:environment => "production",
|
89
|
-
:version_label => 1)
|
90
|
-
|
91
|
-
deploy(:application => 'simple',
|
92
|
-
:environment => "production",
|
93
|
-
:version_label => 2)
|
94
|
-
|
95
|
-
deploy(:application => 'simple',
|
96
|
-
:environment => "production",
|
97
|
-
:version_label => 3,
|
98
|
-
:keep_latest => 2)
|
99
|
-
|
100
|
-
assert_equal '1', @eb_driver.versions_deleted('simple').first
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_should_only_remove_versions_with_matching_prefix
|
104
|
-
deploy(:application => 'simple',
|
105
|
-
:environment => "production",
|
106
|
-
:version_label => 1,
|
107
|
-
:version_prefix => "prod1-",
|
108
|
-
:keep_latest => 1)
|
109
|
-
deploy(:application => 'simple',
|
110
|
-
:environment => "production",
|
111
|
-
:version_label => 2,
|
112
|
-
:version_prefix => "prod1-",
|
113
|
-
:keep_latest => 1)
|
114
|
-
deploy(:application => 'simple',
|
115
|
-
:environment => "production",
|
116
|
-
:version_label => 1,
|
117
|
-
:version_prefix => "prod2-",
|
118
|
-
:keep_latest => 1)
|
119
|
-
|
120
|
-
assert_equal 'prod1-1', @eb_driver.versions_deleted('simple').first
|
121
|
-
assert_equal 1, @eb_driver.versions_deleted('simple').count
|
122
|
-
|
123
|
-
app_versions = @eb_driver.application_versions('simple').map { |apv| apv[:version_label] }
|
124
|
-
assert_equal ["prod1-2", "prod2-1"], app_versions
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_default_cname_that_deployed_should_app_env_name
|
128
|
-
deploy(:application => 'simple',
|
129
|
-
:environment => "production",
|
130
|
-
:version_label => 42)
|
131
|
-
assert_equal "simple-production", @eb_driver.environment_cname_prefix('simple', 'production')
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_cname_prefix_can_be_override
|
135
|
-
deploy(:application => 'simple',
|
136
|
-
:environment => "production",
|
137
|
-
:cname_prefix => 'sports123',
|
138
|
-
:version_label => 42)
|
139
|
-
assert_equal "sports123", @eb_driver.environment_cname_prefix('simple', 'production')
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_smoke_test_should_be_run_after_env_created_or_update
|
143
|
-
host_for_smoke_test = nil
|
144
|
-
deploy(:application => 'simple',
|
145
|
-
:environment => "production",
|
146
|
-
:cname_prefix => 'foobar',
|
147
|
-
:smoke_test => lambda { |host| host_for_smoke_test = host },
|
148
|
-
:version_label => 42)
|
149
|
-
assert_equal 'foobar.elasticbeanstalk.com', host_for_smoke_test
|
150
|
-
|
151
|
-
host_for_smoke_test = nil
|
152
|
-
deploy(:application => 'simple',
|
153
|
-
:environment => "production",
|
154
|
-
:cname_prefix => 'foobar',
|
155
|
-
:smoke_test => lambda { |host| host_for_smoke_test = host },
|
156
|
-
:version_label => 43)
|
157
|
-
|
158
|
-
assert_equal 'foobar.elasticbeanstalk.com', host_for_smoke_test
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_blue_green_deployment_strategy_should_create_blue_env_on_first_deployment
|
162
|
-
deploy(:application => 'simple',
|
163
|
-
:environment => "production",
|
164
|
-
:strategy => 'blue-green',
|
165
|
-
:version_label => 42)
|
166
|
-
|
167
|
-
assert @eb_driver.environment_exists?('simple', 'production-a')
|
168
|
-
assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-a')
|
169
|
-
end
|
170
|
-
|
171
|
-
|
172
|
-
def test_blue_green_deployment_should_create_green_env_if_blue_exists
|
173
|
-
deploy(:application => 'simple',
|
174
|
-
:environment => "production",
|
175
|
-
:strategy => 'blue-green',
|
176
|
-
:version_label => 42)
|
177
|
-
|
178
|
-
deploy(:application => 'simple',
|
179
|
-
:environment => "production",
|
180
|
-
:strategy => 'blue-green',
|
181
|
-
:version_label => 43)
|
182
|
-
|
183
|
-
assert @eb_driver.environment_exists?('simple', 'production-a')
|
184
|
-
assert @eb_driver.environment_exists?('simple', 'production-b')
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
def test_blue_green_deployment_should_swap_cname_to_make_active_most_recent_updated_env
|
189
|
-
deploy(:application => 'simple',
|
190
|
-
:environment => "production",
|
191
|
-
:strategy => 'blue-green',
|
192
|
-
:version_label => 42)
|
193
|
-
|
194
|
-
deploy(:application => 'simple',
|
195
|
-
:environment => "production",
|
196
|
-
:strategy => 'blue-green',
|
197
|
-
:version_label => 43)
|
198
|
-
|
199
|
-
assert_match(/simple-production-inactive/, @eb_driver.environment_cname_prefix('simple', 'production-a'))
|
200
|
-
|
201
|
-
assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-b')
|
202
|
-
|
203
|
-
|
204
|
-
deploy(:application => 'simple',
|
205
|
-
:environment => "production",
|
206
|
-
:strategy => 'blue-green',
|
207
|
-
:version_label => 44)
|
208
|
-
|
209
|
-
assert_match(/simple-production-inactive/, @eb_driver.environment_cname_prefix('simple', 'production-b'))
|
210
|
-
|
211
|
-
assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-a')
|
212
|
-
end
|
213
|
-
|
214
|
-
|
215
|
-
def test_blue_green_deploy_should_run_smoke_test_before_cname_switch
|
216
|
-
smoked_host = []
|
217
|
-
smoke_test = lambda { |host| smoked_host << host }
|
218
|
-
[42, 43, 44].each do |version_label|
|
219
|
-
deploy(:application => 'simple',
|
220
|
-
:environment => "production",
|
221
|
-
:strategy => 'blue-green',
|
222
|
-
:smoke_test => smoke_test,
|
223
|
-
:version_label => version_label)
|
224
|
-
end
|
225
|
-
|
226
|
-
assert_equal ['simple-production.elasticbeanstalk.com',
|
227
|
-
'simple-production-inactive.elasticbeanstalk.com',
|
228
|
-
'simple-production-inactive.elasticbeanstalk.com'], smoked_host
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_deploy_with_resources_declared_will_create_a_cf_stack_for_env
|
232
|
-
cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
|
233
|
-
deploy(:application => 'simple', :environment => "production",
|
234
|
-
:resources => {
|
235
|
-
:template => cf_template
|
236
|
-
})
|
237
|
-
assert @cf_driver.stack_exists?('simple-production')
|
238
|
-
assert_equal({}, @cf_driver.stack_config('simple-production')[:parameters])
|
239
|
-
assert_equal([], @cf_driver.stack_config('simple-production')[:capabilities])
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_provision_resources_with_capacities
|
243
|
-
cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
|
244
|
-
deploy(:application => 'simple', :environment => "production",
|
245
|
-
:resources => {
|
246
|
-
:template => cf_template,
|
247
|
-
:capabilities => ['CAPABILITY_IAM']
|
248
|
-
})
|
249
|
-
assert_equal ['CAPABILITY_IAM'], @cf_driver.stack_config('simple-production')[:capabilities]
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_provision_resources_with_parameters
|
253
|
-
cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
|
254
|
-
deploy(:application => 'simple', :environment => "production",
|
255
|
-
:resources => {
|
256
|
-
:template => cf_template,
|
257
|
-
:parameters => {'a' => 1}
|
258
|
-
})
|
259
|
-
assert_equal({'a' => 1 }, @cf_driver.stack_config('simple-production')[:parameters])
|
260
|
-
end
|
261
|
-
|
262
|
-
def test_skip_resource_update
|
263
|
-
cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
|
264
|
-
deploy(:application => 'simple', :environment => "production",
|
265
|
-
:resources => {
|
266
|
-
:template => cf_template,
|
267
|
-
:parameters => {'a' => 1 }
|
268
|
-
})
|
269
|
-
assert_equal(1, @cf_driver.stack_config('simple-production')[:parameters]['a'])
|
270
|
-
deploy(:application => 'simple', :environment => "production",
|
271
|
-
:resources => {
|
272
|
-
:template => cf_template,
|
273
|
-
:parameters => {'a' => 2 }
|
274
|
-
})
|
275
|
-
assert_equal(2, @cf_driver.stack_config('simple-production')[:parameters]['a'])
|
276
|
-
deploy(:application => 'simple',
|
277
|
-
:environment => "production",
|
278
|
-
:skip_resource_stack_update => true,
|
279
|
-
:resources => {
|
280
|
-
:template => cf_template,
|
281
|
-
:parameters => {'a' => 3 }
|
282
|
-
})
|
283
|
-
assert_equal(2, @cf_driver.stack_config('simple-production')[:parameters]['a'])
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_should_still_query_output_to_set_eb_options_even_skip_resources_update_is_specified
|
287
|
-
cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}},
|
288
|
-
'Outputs' => {'O1' => {}, 'O2' => {}}}))
|
289
|
-
deploy(:application => 'simple', :environment => "production",
|
290
|
-
:resources => {
|
291
|
-
:template => cf_template
|
292
|
-
})
|
293
|
-
|
294
|
-
deploy(:application => 'simple', :environment => "production",
|
295
|
-
:skip_resource_stack_update => true,
|
296
|
-
:resources => {
|
297
|
-
:template => cf_template,
|
298
|
-
:transforms => {
|
299
|
-
'O2' => lambda { |v| {:namespace => 'aws.foo', :option_name => 'o2', :value => "transformed " + v} }
|
300
|
-
}
|
301
|
-
})
|
302
|
-
|
303
|
-
assert @eb_driver.environment_settings('simple', 'production').
|
304
|
-
include?({:namespace => 'aws.foo', :option_name => 'o2', :value => 'transformed value of O2'})
|
305
|
-
end
|
306
|
-
|
307
|
-
|
308
|
-
def test_set_s3_bucket_name_on_deployment
|
309
|
-
deploy(:application => 'simple',
|
310
|
-
:environment => "production",
|
311
|
-
:package_bucket => 'thoughtworks.simple')
|
312
|
-
|
313
|
-
assert @s3_driver.bucket_exists?('thoughtworks.simple.packages')
|
314
|
-
end
|
315
|
-
|
316
|
-
def test_transforms_resource_provsion_output_to_elastic_beanstalk_settings
|
317
|
-
cf_template = temp_file(JSON.dump({
|
318
|
-
'Resources' => {'R1' => {}},
|
319
|
-
'Outputs' => {'O1' => {}, 'O2' => {}}
|
320
|
-
}))
|
321
|
-
deploy(:application => 'simple', :environment => "production",
|
322
|
-
:resources => {
|
323
|
-
:template => cf_template,
|
324
|
-
:transforms => {
|
325
|
-
'O1' => lambda { |v| {:namespace => 'aws.foo', :option_name => 'o1', :value => v} }
|
326
|
-
}
|
327
|
-
})
|
328
|
-
assert @eb_driver.environment_settings('simple', 'production').
|
329
|
-
include?({:namespace => 'aws.foo', :option_name => 'o1', :value => 'value of O1'})
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_can_query_resource_stack_output_after_deploy
|
333
|
-
cf_template = temp_file(JSON.dump({
|
334
|
-
'Resources' => {'R1' => {}},
|
335
|
-
'Outputs' => {'O1' => {}, 'O2' => {}}
|
336
|
-
}))
|
337
|
-
deploy(:application => 'simple',
|
338
|
-
:environment => "production",
|
339
|
-
:resources => { :template => cf_template })
|
340
|
-
assert_equal 'value of O1', query_resource_output('O1',
|
341
|
-
:application => 'simple',
|
342
|
-
:environment => "production")
|
343
|
-
assert_equal 'value of O2', query_resource_output('O2',
|
344
|
-
:application => 'simple',
|
345
|
-
:environment => "production")
|
346
|
-
|
347
|
-
end
|
348
|
-
|
349
|
-
def test_should_raise_error_if_query_resources_that_have_not_been_provisioned_yet
|
350
|
-
assert_raises(EbDeployer::ResourceNotInReadyState) do
|
351
|
-
query_resource_output('O1',
|
352
|
-
:application => 'simple',
|
353
|
-
:environment => "production")
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def test_should_terminate_old_environment_if_phoenix_mode_is_enabled
|
358
|
-
deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
|
359
|
-
assert @eb_driver.environment_exists?('simple', 'production')
|
360
|
-
deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
|
361
|
-
assert @eb_driver.environments_been_deleted('simple').include?('production')
|
362
|
-
assert @eb_driver.environment_exists?('simple', 'production')
|
363
|
-
end
|
364
|
-
|
365
|
-
def test_blue_green_deployment_should_delete_and_recreate_inactive_env_if_phoenix_mode_is_enabled
|
366
|
-
deploy(:application => 'simple',
|
367
|
-
:environment => "production",
|
368
|
-
:strategy => 'blue-green',
|
369
|
-
:version_label => 42,
|
370
|
-
:phoenix_mode => true)
|
371
|
-
|
372
|
-
deploy(:application => 'simple',
|
373
|
-
:environment => "production",
|
374
|
-
:strategy => 'blue-green',
|
375
|
-
:version_label => 43,
|
376
|
-
:phoenix_mode => true)
|
377
|
-
|
378
|
-
assert_equal [], @eb_driver.environments_been_deleted('simple')
|
379
|
-
|
380
|
-
inactive_env = 'production-a'
|
381
|
-
assert_match(/inactive/, @eb_driver.environment_cname_prefix('simple', inactive_env))
|
382
|
-
|
383
|
-
|
384
|
-
deploy(:application => 'simple',
|
385
|
-
:environment => "production",
|
386
|
-
:strategy => 'blue-green',
|
387
|
-
:version_label => 44,
|
388
|
-
:phoenix_mode => true)
|
389
|
-
|
390
|
-
assert_equal [inactive_env], @eb_driver.environments_been_deleted('simple')
|
391
|
-
|
392
|
-
assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', inactive_env)
|
393
|
-
end
|
394
|
-
|
395
|
-
def test_pass_pathname_as_package_file
|
396
|
-
deploy(:package => Pathname.new(@sample_package),
|
397
|
-
:application => 'simple',
|
398
|
-
:environment => "production",
|
399
|
-
:package_bucket => 'thoughtworks.simple')
|
400
|
-
|
401
|
-
s3_objects = @s3_driver.objects('thoughtworks.simple.packages')
|
402
|
-
assert_equal 1, s3_objects.size
|
403
|
-
assert_equal @sample_package, s3_objects.values.first.to_s
|
404
|
-
end
|
405
|
-
|
406
|
-
def test_sets_default_tier_as_webserver
|
407
|
-
deploy(:application => 'simple', :environment => "production")
|
408
|
-
assert_equal EbDeployer.environment_tier('WebServer'), @eb_driver.environment_tier('simple', 'production')
|
409
|
-
end
|
410
|
-
|
411
|
-
def test_can_change_tier
|
412
|
-
deploy(:application => 'simple', :environment => "production", :tier => 'Worker')
|
413
|
-
assert_equal EbDeployer.environment_tier('Worker'), @eb_driver.environment_tier('simple', 'production')
|
414
|
-
end
|
415
|
-
|
416
|
-
def test_should_raise_error_when_tier_setting_is_not_recognized
|
417
|
-
assert_raises(RuntimeError) do
|
418
|
-
deploy(:application => 'simple', :environment => "production", :tier => 'Gum')
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
def test_pass_s3_object_name_as_package_file
|
423
|
-
package_name = 'test-bucket:test-mingle.war'
|
424
|
-
|
425
|
-
deploy(:package => package_name,
|
426
|
-
:application => 'simple',
|
427
|
-
:environment => "production",
|
428
|
-
:version_label => 1)
|
429
|
-
|
430
|
-
assert @eb_driver.application_exists?('simple')
|
431
|
-
last_version = @eb_driver.application_versions('simple').last
|
432
|
-
assert_equal({'s3_bucket' => 'test-bucket', 's3_key' => 'test-mingle.war'}, last_version[:source_bundle])
|
433
|
-
end
|
434
|
-
|
435
|
-
# def test_deploy_with_components
|
436
|
-
# deploy(:application => 'simple',
|
437
|
-
# :environment => 'production',
|
438
|
-
# :components => [{ :name => 'web' }])
|
439
|
-
|
440
|
-
# assert @eb_driver.environment_exists?('simple', 'production-web')
|
441
|
-
# end
|
442
|
-
|
443
|
-
def test_should_clean_up_legacy_environment_on_deploy
|
444
|
-
legacy_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production")
|
445
|
-
@eb_driver.create_application("simple")
|
446
|
-
@eb_driver.create_environment("simple", legacy_env_name, 'solution-stack', 'simple-production', 'foo', 'web' ,{})
|
447
|
-
deploy(:application => 'simple',
|
448
|
-
:environment => 'production',
|
449
|
-
:version_label => 1)
|
450
|
-
assert @eb_driver.environment_exists?("simple", "production")
|
451
|
-
assert !@eb_driver.environment_exists?("simple", legacy_env_name)
|
452
|
-
end
|
453
|
-
|
454
|
-
private
|
11
|
+
protected
|
455
12
|
|
456
13
|
def temp_file(content)
|
457
14
|
f = Tempfile.new("foo")
|
data/test/eb_environment_test.rb
CHANGED
@@ -55,17 +55,16 @@ class EbEnvironmentTest < MiniTest::Unit::TestCase
|
|
55
55
|
|
56
56
|
def test_should_raise_runtime_error_when_deploy_failed
|
57
57
|
env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
|
58
|
-
|
58
|
+
@eb_driver.set_events("myapp", "production", ["start deploying", "Failed to deploy application"])
|
59
59
|
assert_raises(RuntimeError) { env.deploy("version 1") }
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_should_raise_runtime_error_when_eb_extension_execution_failed
|
63
63
|
env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
"Successfully launched environment"])
|
64
|
+
@eb_driver.set_events("myapp", "production", ["start deploying",
|
65
|
+
"create environment",
|
66
|
+
"Command failed on instance. Return code: 1 Output: Error occurred during build: Command hooks failed",
|
67
|
+
"Successfully launched environment"])
|
69
68
|
|
70
69
|
assert_raises(RuntimeError) { env.deploy("version 1") }
|
71
70
|
end
|
@@ -78,6 +77,62 @@ class EbEnvironmentTest < MiniTest::Unit::TestCase
|
|
78
77
|
assert !@eb_driver.environment_exists?('myapp', 'production')
|
79
78
|
end
|
80
79
|
|
80
|
+
def test_should_terminate_legacy_env_upon_deployment
|
81
|
+
legacy_env_name = create_legacy_env("myapp", "production", "myapp-production")
|
82
|
+
env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
|
83
|
+
@eb_driver.set_events("myapp", legacy_env_name, ["terminateEnvironment completed successfully"])
|
84
|
+
@eb_driver.set_events("myapp", "production", ["Successfully launched environment"])
|
85
|
+
env.deploy("version1")
|
86
|
+
assert !@eb_driver.environment_exists?("myapp", legacy_env_name)
|
87
|
+
assert @eb_driver.environment_exists?("myapp", "production")
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_can_find_cname_if_legacy_env_exists
|
91
|
+
legacy_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("myapp", "production")
|
92
|
+
@eb_driver.create_environment("myapp", legacy_env_name, 'solution-stack', 'myapp-production', 'foo', 'web' ,{})
|
93
|
+
env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
|
94
|
+
assert_equal 'myapp-production', env.cname_prefix
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_terminate_legacy_env
|
98
|
+
legacy_env_name = create_legacy_env("myapp", "production", "myapp-production")
|
99
|
+
env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
|
100
|
+
env.terminate
|
101
|
+
assert !@eb_driver.environment_exists?("myapp", legacy_env_name)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_swap_legacy_env_with_non_legacy_env
|
105
|
+
create_legacy_env("myapp", "production-a", "myapp-production")
|
106
|
+
env_a = EbDeployer::EbEnvironment.new("myapp", "production-a", @eb_driver)
|
107
|
+
env_b = EbDeployer::EbEnvironment.new("myapp", "production-b", @eb_driver, :cname_prefix => 'myapp-production-inactive')
|
108
|
+
env_b.deploy('version1')
|
109
|
+
|
110
|
+
env_a.swap_cname_with(env_b)
|
111
|
+
|
112
|
+
assert_equal "myapp-production-inactive", env_a.cname_prefix
|
113
|
+
assert_equal "myapp-production", env_b.cname_prefix
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_swap_no_legacy_env_with_legacy_env
|
117
|
+
create_legacy_env("myapp", "production-a", "myapp-production")
|
118
|
+
env_a = EbDeployer::EbEnvironment.new("myapp", "production-a", @eb_driver)
|
119
|
+
env_b = EbDeployer::EbEnvironment.new("myapp", "production-b", @eb_driver, :cname_prefix => 'myapp-production-inactive')
|
120
|
+
env_b.deploy('version1')
|
121
|
+
|
122
|
+
env_b.swap_cname_with(env_a)
|
123
|
+
|
124
|
+
assert_equal "myapp-production-inactive", env_a.cname_prefix
|
125
|
+
assert_equal "myapp-production", env_b.cname_prefix
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def create_legacy_env(app_name, env_name, cname_prefix)
|
131
|
+
legacy_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name(app_name, env_name)
|
132
|
+
@eb_driver.create_environment(app_name, legacy_env_name, 'solution-stack', cname_prefix, 'foo', 'web' ,{})
|
133
|
+
legacy_env_name
|
134
|
+
end
|
135
|
+
|
81
136
|
|
82
137
|
|
83
138
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'deploy_test'
|
2
|
+
|
3
|
+
class InplaceUpdateDeployTest < DeployTest
|
4
|
+
def test_first_deployment_create_eb_application
|
5
|
+
assert !@eb_driver.application_exists?('simple')
|
6
|
+
deploy(:application => 'simple', :environment => "production")
|
7
|
+
assert @eb_driver.application_exists?('simple')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_set_option_settings_on_deployment
|
11
|
+
redudant = [{:namespace => 'aws:autoscaling:launchconfiguration',
|
12
|
+
:option_name => 'MinSize',
|
13
|
+
:value => '2' }]
|
14
|
+
deploy(:application => 'simple', :environment => "production",
|
15
|
+
:option_settings => [redudant])
|
16
|
+
|
17
|
+
assert_equal [redudant], @eb_driver.environment_settings('simple', 'production')
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_destroy_should_clean_up_eb_application_and_env
|
22
|
+
deploy(:application => 'simple', :environment => "production")
|
23
|
+
destroy(:application => 'simple')
|
24
|
+
assert !@eb_driver.application_exists?('simple')
|
25
|
+
assert !@eb_driver.environment_exists?('simple', 'production')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_first_deployment_create_environment
|
29
|
+
assert !@eb_driver.environment_exists?('simple', 'production')
|
30
|
+
deploy(:application => 'simple', :environment => "production")
|
31
|
+
assert @eb_driver.environment_exists?('simple', 'production')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_support_very_very_long_app_name
|
35
|
+
deploy(:application => 'ver-very-simple-application', :environment => "production")
|
36
|
+
assert @eb_driver.environment_exists?('ver-very-simple-application', 'production')
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_raise_error_when_env_name_is_too_long
|
40
|
+
assert_raises(RuntimeError) { deploy(:application => 'simple', :environment => "p" * 24) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_update_environment_with_new_version_should_change_version_that_deployed
|
44
|
+
deploy(:application => 'simple',
|
45
|
+
:environment => "production",
|
46
|
+
:version_label => 1)
|
47
|
+
assert_equal '1', @eb_driver.environment_verion_label('simple', 'production')
|
48
|
+
|
49
|
+
deploy(:application => 'simple',
|
50
|
+
:environment => "production",
|
51
|
+
:version_label => 2)
|
52
|
+
|
53
|
+
assert_equal '2', @eb_driver.environment_verion_label('simple', 'production')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_smoke_test_should_be_run_after_env_created_or_update
|
57
|
+
host_for_smoke_test = nil
|
58
|
+
deploy(:application => 'simple',
|
59
|
+
:environment => "production",
|
60
|
+
:cname_prefix => 'foobar',
|
61
|
+
:smoke_test => lambda { |host| host_for_smoke_test = host },
|
62
|
+
:version_label => 42)
|
63
|
+
assert_equal 'foobar.elasticbeanstalk.com', host_for_smoke_test
|
64
|
+
|
65
|
+
host_for_smoke_test = nil
|
66
|
+
deploy(:application => 'simple',
|
67
|
+
:environment => "production",
|
68
|
+
:cname_prefix => 'foobar',
|
69
|
+
:smoke_test => lambda { |host| host_for_smoke_test = host },
|
70
|
+
:version_label => 43)
|
71
|
+
|
72
|
+
assert_equal 'foobar.elasticbeanstalk.com', host_for_smoke_test
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_should_terminate_old_environment_if_phoenix_mode_is_enabled
|
76
|
+
deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
|
77
|
+
assert @eb_driver.environment_exists?('simple', 'production')
|
78
|
+
deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
|
79
|
+
assert @eb_driver.environments_been_deleted('simple').include?('production')
|
80
|
+
assert @eb_driver.environment_exists?('simple', 'production')
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
end
|