eb_deployer_updated 0.8.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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +14 -0
  6. data/CHANGELOG.md +127 -0
  7. data/Gemfile +10 -0
  8. data/LICENSE +22 -0
  9. data/README.md +136 -0
  10. data/Rakefile +12 -0
  11. data/TODOS.md +11 -0
  12. data/bin/eb_deploy +13 -0
  13. data/eb_deployer.gemspec +22 -0
  14. data/lib/eb_deployer/application.rb +96 -0
  15. data/lib/eb_deployer/aws_driver/beanstalk.rb +158 -0
  16. data/lib/eb_deployer/aws_driver/cloud_formation_driver.rb +53 -0
  17. data/lib/eb_deployer/aws_driver/s3_driver.rb +35 -0
  18. data/lib/eb_deployer/aws_driver.rb +8 -0
  19. data/lib/eb_deployer/cf_event_source.rb +26 -0
  20. data/lib/eb_deployer/cloud_formation_provisioner.rb +120 -0
  21. data/lib/eb_deployer/component.rb +45 -0
  22. data/lib/eb_deployer/config_loader.rb +64 -0
  23. data/lib/eb_deployer/default_component.rb +32 -0
  24. data/lib/eb_deployer/default_config.rb +20 -0
  25. data/lib/eb_deployer/default_config.yml +159 -0
  26. data/lib/eb_deployer/deployment_strategy/blue_green.rb +79 -0
  27. data/lib/eb_deployer/deployment_strategy/blue_only.rb +45 -0
  28. data/lib/eb_deployer/deployment_strategy/inplace_update.rb +16 -0
  29. data/lib/eb_deployer/deployment_strategy.rb +20 -0
  30. data/lib/eb_deployer/eb_environment.rb +204 -0
  31. data/lib/eb_deployer/eb_event_source.rb +35 -0
  32. data/lib/eb_deployer/environment.rb +60 -0
  33. data/lib/eb_deployer/event_poller.rb +51 -0
  34. data/lib/eb_deployer/package.rb +39 -0
  35. data/lib/eb_deployer/resource_stacks.rb +20 -0
  36. data/lib/eb_deployer/smoke_test.rb +23 -0
  37. data/lib/eb_deployer/tasks.rb +45 -0
  38. data/lib/eb_deployer/throttling_handling.rb +17 -0
  39. data/lib/eb_deployer/utils.rb +33 -0
  40. data/lib/eb_deployer/version.rb +3 -0
  41. data/lib/eb_deployer/version_cleaner.rb +30 -0
  42. data/lib/eb_deployer.rb +339 -0
  43. data/lib/generators/eb_deployer/install/install_generator.rb +82 -0
  44. data/lib/generators/eb_deployer/install/templates/eb_deployer.rake +1 -0
  45. data/lib/generators/eb_deployer/install/templates/eb_deployer.yml.erb +181 -0
  46. data/lib/generators/eb_deployer/install/templates/ebextensions/01_postgres_packages.config +5 -0
  47. data/lib/generators/eb_deployer/install/templates/postgres_rds.json +88 -0
  48. data/test/aws_driver_stubs.rb +350 -0
  49. data/test/beanstalk_test.rb +23 -0
  50. data/test/blue_green_deploy_test.rb +114 -0
  51. data/test/blue_only_deploy_test.rb +78 -0
  52. data/test/cf_event_poller_test.rb +32 -0
  53. data/test/cloud_formation_provisioner_test.rb +47 -0
  54. data/test/config_loader_test.rb +205 -0
  55. data/test/deploy_test.rb +42 -0
  56. data/test/eb_environment_test.rb +120 -0
  57. data/test/eb_event_poller_test.rb +32 -0
  58. data/test/inplace_update_deploy_test.rb +110 -0
  59. data/test/multi_components_deploy_test.rb +164 -0
  60. data/test/rails_generators_test.rb +67 -0
  61. data/test/resources_deploy_test.rb +191 -0
  62. data/test/smoke_test_test.rb +23 -0
  63. data/test/template_deploy_test.rb +13 -0
  64. data/test/test_helper.rb +68 -0
  65. data/test/tier_setting_deploy_test.rb +24 -0
  66. data/test/versions_deploy_test.rb +120 -0
  67. metadata +194 -0
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class CloudFormationProvisionerTest < Test::Unit::TestCase
4
+ def setup
5
+ @cf = CFStub.new
6
+ @provisioner = EbDeployer::CloudFormationProvisioner.new("myresources", @cf)
7
+ @template = sample_file("sample_template.json")
8
+ end
9
+
10
+
11
+ def test_convert_inputs_as_params_to_cf
12
+ resources = { 'template' => @template, 'inputs' => { 'Foo' => 'Bar' } }
13
+ @provisioner.provision(resources, [])
14
+
15
+ assert_equal({ 'Foo' => 'Bar' }, @cf.stack_config("myresources")[:parameters])
16
+ end
17
+
18
+ def test_transform_to_eb_settings
19
+ resources = { 'template' => @template,
20
+ 'outputs' => {
21
+ 'S' => {
22
+ 'namespace' => "foo",
23
+ "option_name" => "bar"
24
+ }
25
+ }}
26
+
27
+ @provisioner.provision(resources, [])
28
+ settings = @provisioner.transform_outputs(resources)
29
+ assert_equal [{'namespace' => 'foo', 'option_name' => 'bar', 'value' => 'value of S'}], settings
30
+ end
31
+
32
+ def test_stack_is_tagged
33
+ resources = { 'template' => @template }
34
+
35
+ @provisioner.provision(resources, [{key: 'Tag1', value: 'Value1'}])
36
+
37
+ assert_equal([{key: 'Tag1', value: 'Value1'}], @cf.stack_config("myresources")[:tags])
38
+ end
39
+
40
+ def test_stack_is_not_tagged_when_no_tags_specified
41
+ resources = { 'template' => @template }
42
+
43
+ @provisioner.provision(resources, [])
44
+
45
+ assert_equal([], @cf.stack_config("myresources")[:tags])
46
+ end
47
+ end
@@ -0,0 +1,205 @@
1
+ require 'test_helper'
2
+
3
+ class ConfigLoaderTest < Test::Unit::TestCase
4
+ def setup
5
+ @loader = EbDeployer::ConfigLoader.new
6
+ @sample_package = sample_file('app-package.war')
7
+ end
8
+
9
+ def test_all_default_cases
10
+ config = @loader.load(generate_input(<<-YAML))
11
+ application: myapp
12
+ common:
13
+ option_settings:
14
+ resources:
15
+ environments:
16
+ dev:
17
+ production:
18
+ YAML
19
+ assert_equal('myapp', config[:application])
20
+ assert_equal(@sample_package, config[:package])
21
+ assert_equal('dev', config[:environment])
22
+ assert_equal(md5_digest(@sample_package), config[:version_label])
23
+ assert_equal([], config[:option_settings])
24
+ assert_equal(nil, config[:resources])
25
+ assert_equal(nil, config[:common])
26
+ end
27
+
28
+ def test_use_package_as_version_label_when_using_s3_obj_as_package
29
+ config = @loader.load(generate_input(<<-YAML, :package => 'bucket:obj'))
30
+ application: myapp
31
+ common:
32
+ strategy: inplace-update
33
+ environments:
34
+ dev:
35
+ YAML
36
+ assert_equal('myapp', config[:application])
37
+ assert_equal('bucket:obj', config[:package])
38
+ assert_equal('bucket:obj', config[:version_label])
39
+ end
40
+
41
+ def test_common_settings_get_merge_into_the_config
42
+ config = @loader.load(generate_input(<<-YAML))
43
+ application: myapp
44
+ common:
45
+ strategy: inplace-update
46
+ package_bucket: thoughtworks
47
+ phoenix_mode: true
48
+ option_settings:
49
+ - namespace: aws:autoscaling:launchconfiguration
50
+ option_name: InstanceType
51
+ value: m1.small
52
+ resources:
53
+ environments:
54
+ dev:
55
+ production:
56
+ YAML
57
+ assert_equal('inplace-update', config[:strategy])
58
+ assert_equal('thoughtworks', config[:package_bucket])
59
+ assert_equal([{'namespace' => 'aws:autoscaling:launchconfiguration',
60
+ 'option_name' => 'InstanceType',
61
+ 'value' => 'm1.small'}], config[:option_settings])
62
+ end
63
+
64
+ def test_eval_random_hash
65
+ yaml = <<-YAML
66
+ application: myapp
67
+ common:
68
+ resources:
69
+ template: config/my_rds.json
70
+ inputs:
71
+ DBPassword: <%= random_hash %>
72
+ environments:
73
+ dev:
74
+ production:
75
+ YAML
76
+ first_time = @loader.load(generate_input(yaml))[:resources]['inputs']['DBPassword']
77
+ second_time = @loader.load(generate_input(yaml))[:resources]['inputs']['DBPassword']
78
+ assert first_time && second_time
79
+ assert first_time != second_time
80
+ end
81
+
82
+ def test_environment_specific_setting_will_override_common_settings
83
+ yaml = <<-YAML
84
+ application: myapp
85
+ common:
86
+ phoenix_mode: true
87
+ environments:
88
+ dev:
89
+ phoenix_mode: false
90
+ production:
91
+ YAML
92
+
93
+ assert !@loader.load(generate_input(yaml, :environment => 'dev'))[:phoenix_mode]
94
+ assert @loader.load(generate_input(yaml, :environment => 'production'))[:phoenix_mode]
95
+ end
96
+
97
+ def test_env_specific_option_settings_will_merge_with_commons
98
+ config = @loader.load(generate_input(<<-YAML, :environment => 'production'))
99
+ application: myapp
100
+ common:
101
+ strategy: inplace-update
102
+ phoenix_mode: true
103
+ option_settings:
104
+ - namespace: aws:autoscaling:launchconfiguration
105
+ option_name: InstanceType
106
+ value: m1.small
107
+ resources:
108
+ environments:
109
+ dev:
110
+ production:
111
+ option_settings:
112
+ - namespace: aws:autoscaling:asg
113
+ option_name: MinSize
114
+ value: "2"
115
+ YAML
116
+ assert_equal([{'namespace' => 'aws:autoscaling:launchconfiguration',
117
+ 'option_name' => 'InstanceType',
118
+ 'value' => 'm1.small'},
119
+ {'namespace' => 'aws:autoscaling:asg',
120
+ 'option_name' => 'MinSize',
121
+ 'value' => "2"}], config[:option_settings])
122
+ end
123
+
124
+ def test_env_is_required
125
+ error = assert_raises(RuntimeError) {
126
+ @loader.load(generate_input(<<-YAML, :environment => 'non_existant'))
127
+ application: myapp
128
+ common:
129
+ strategy: inplace-update
130
+ environments:
131
+ dev:
132
+ YAML
133
+ }
134
+
135
+ assert_match(/non_existant/, error.message)
136
+ end
137
+
138
+ def test_set_inactive_settings_at_common_level
139
+ config = @loader.load(generate_input(<<-YAML, :environment => 'production'))
140
+ application: myapp
141
+ common:
142
+ inactive_settings:
143
+ - namespace: aws:autoscaling:asg
144
+ option_name: MinSize
145
+ value: "1"
146
+ environments:
147
+ dev:
148
+ production:
149
+ YAML
150
+ assert_equal([{'namespace' => 'aws:autoscaling:asg',
151
+ 'option_name' => 'MinSize',
152
+ 'value' => '1'}], config[:inactive_settings])
153
+ end
154
+
155
+ def test_set_inactive_settings_at_env_level
156
+ config = @loader.load(generate_input(<<-YAML, :environment => 'dev'))
157
+ application: myapp
158
+ common:
159
+ inactive_settings:
160
+ - namespace: aws:autoscaling:asg
161
+ option_name: MinSize
162
+ value: "1"
163
+ environments:
164
+ dev:
165
+ inactive_settings:
166
+ - namespace: aws:autoscaling:asg
167
+ option_name: MinSize
168
+ value: "0"
169
+ production:
170
+ YAML
171
+ assert_equal([{'namespace' => 'aws:autoscaling:asg',
172
+ 'option_name' => 'MinSize',
173
+ 'value' => '0'}], config[:inactive_settings])
174
+ end
175
+
176
+ def test_access_environment_name_in_config_yml_file
177
+ config = @loader.load(generate_input(<<-YAML, :environment => 'dev'))
178
+ application: myapp
179
+ common:
180
+ resources:
181
+ inputs:
182
+ env: <%= environment %>
183
+ environments:
184
+ dev:
185
+ production:
186
+ YAML
187
+ assert_equal('dev', config[:resources]['inputs']['env'])
188
+ end
189
+
190
+ private
191
+
192
+ def md5_digest(file)
193
+ Digest::MD5.file(file).hexdigest
194
+ end
195
+
196
+ def generate_input(config_file_content, overriding={})
197
+ { :environment => 'dev',
198
+ :package => @sample_package,
199
+ :config_file => generate_config(config_file_content)}.merge(overriding)
200
+ end
201
+
202
+ def generate_config(content)
203
+ sample_file('eb_deployer.yml', content)
204
+ end
205
+ end
@@ -0,0 +1,42 @@
1
+ require 'test_helper'
2
+
3
+ class DeployTest < Test::Unit::TestCase
4
+ def setup
5
+ @eb = ErrorRaisingWrapper.new(EBStub.new)
6
+ @s3_driver = S3Stub.new
7
+ @cf_driver = CFStub.new
8
+ @sample_package = sample_file('app-package.war')
9
+ end
10
+
11
+ protected
12
+
13
+ def temp_file(content)
14
+ f = Tempfile.new("foo")
15
+ f.write(content)
16
+ f
17
+ end
18
+
19
+ def query_resource_output(key, opts)
20
+ EbDeployer.query_resource_output(key, {:bs_driver => @eb,
21
+ :s3_driver => @s3_driver,
22
+ :cf_driver => @cf_driver}.merge(opts))
23
+ end
24
+
25
+ def deploy(opts)
26
+ @eb.mark_all_envs_ready
27
+ EbDeployer.deploy({:package => @sample_package,
28
+ :strategy => :'inplace-update',
29
+ :version_label => 1}.merge(opts).merge(stubs))
30
+ end
31
+
32
+ def destroy(opts)
33
+ EbDeployer.destroy(opts.merge(stubs))
34
+ end
35
+
36
+ def stubs
37
+ { :bs_driver => @eb,
38
+ :s3_driver => @s3_driver,
39
+ :cf_driver => @cf_driver
40
+ }
41
+ end
42
+ end
@@ -0,0 +1,120 @@
1
+ require 'test_helper'
2
+
3
+ class EbEnvironmentTest < Test::Unit::TestCase
4
+ def setup
5
+ @eb_driver = EBStub.new
6
+ @eb_driver.create_application("myapp")
7
+ end
8
+
9
+ def test_deploy_should_create_corresponding_eb_env
10
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
11
+ env.deploy("version1")
12
+ assert @eb_driver.environment_exists?('myapp', t('production', 'myapp'))
13
+ end
14
+
15
+ def test_deploy_again_should_update_environment
16
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
17
+ env.deploy("version1")
18
+ env.deploy("version2")
19
+ assert @eb_driver.environment_exists?('myapp', t('production', 'myapp'))
20
+ assert_equal 'version2', @eb_driver.environment_verion_label('myapp', t('production', 'myapp'))
21
+ end
22
+
23
+ def test_option_setttings_get_set_on_eb_env
24
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
25
+ env.deploy("version1", {s1: 'v1'})
26
+ assert_equal({s1: 'v1' }, @eb_driver.environment_settings('myapp', t('production', 'myapp')))
27
+ end
28
+
29
+ def test_deploy_should_include_tags
30
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production', :tags => {:my_tag => 'my_value', :tag2 => 'value2'})
31
+ env.deploy("version1")
32
+ assert_equal [{:key => :my_tag, :value => 'my_value'}, {:key => :tag2, :value => 'value2'}], @eb_driver.environment_tags('myapp', t('production', 'myapp'))
33
+ end
34
+
35
+ def test_should_run_smoke_test_after_deploy
36
+ smoked_host = nil
37
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :smoke_test => Proc.new { |host| smoked_host = host }, :cname_prefix => 'myapp-production')
38
+ env.deploy("version1")
39
+
40
+ assert !smoked_host.nil?
41
+ assert_match( /myapp.*\.elasticbeanstalk\.com/, smoked_host)
42
+ end
43
+
44
+ def test_should_raise_runtime_error_when_deploy_failed
45
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
46
+ @eb_driver.set_events("myapp", t("production", 'myapp'),
47
+ [],
48
+ ["start deploying", "Failed to deploy application"])
49
+ assert_raises(RuntimeError) { env.deploy("version 1") }
50
+ end
51
+
52
+ def test_should_raise_runtime_error_when_eb_extension_execution_failed
53
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
54
+ @eb_driver.set_events("myapp", t("production", 'myapp'),
55
+ [],
56
+ ["start deploying",
57
+ "create environment",
58
+ "Command failed on instance. Return code: 1 Output: Error occurred during build: Command hooks failed",
59
+ "Successfully launched environment"])
60
+
61
+ assert_raises(RuntimeError) { env.deploy("version 1") }
62
+ end
63
+
64
+ def test_should_raise_runtime_error_when_issues_during_environment_update
65
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
66
+ @eb_driver.set_events("myapp", t("production", 'myapp'),
67
+ [],
68
+ ["start deploying",
69
+ "create environment",
70
+ "Update environment operation is complete, but with errors. For more information, see troubleshooting documentation."])
71
+
72
+ assert_raises(RuntimeError) { env.deploy("version 1") }
73
+ end
74
+
75
+ def test_should_raise_runtime_error_when_issues_during_launch
76
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
77
+ @eb_driver.set_events("myapp", t("production", 'myapp'),
78
+ [],
79
+ ["start deploying",
80
+ "create environment",
81
+ "Launched environment: dev-a-1234567. However, there were issues during launch. See event log for details."])
82
+
83
+ assert_raises(RuntimeError) { env.deploy("version 1") }
84
+ end
85
+
86
+ def test_terminate_should_delete_environment
87
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :cname_prefix => 'myapp-production')
88
+ env.deploy("version1")
89
+ env.terminate
90
+ assert !@eb_driver.environment_exists?('myapp', t('production', 'myapp'))
91
+ end
92
+
93
+ def test_should_raise_runtime_error_when_solution_stack_is_not_valid
94
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, {
95
+ :cname_prefix => 'myapp-production',
96
+ :solution_stack => "python"
97
+ })
98
+ @eb_driver.set_solution_stacks(["java", "ruby"])
99
+ assert_raises(RuntimeError) { env.deploy("version 1") }
100
+ end
101
+
102
+ def test_should_no_set_cname_prefix_for_create_unless_for_web_tier
103
+ env = EbDeployer::EbEnvironment.new("myapp",
104
+ "production",
105
+ @eb_driver,
106
+ :tier => "Worker",
107
+ :cname_prefix => 'myapp-production')
108
+ env.deploy("version1")
109
+ assert @eb_driver.environment_exists?('myapp', t('production', 'myapp'))
110
+ assert_nil @eb_driver.environment_cname_prefix('myapp', t('production', 'myapp'))
111
+ end
112
+
113
+ def test_should_be_possible_to_accept_yellow_health_state
114
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, :accepted_healthy_states => ["Green", "Yellow"])
115
+ @eb_driver.mark_env_health_state_as("myapp", env.name, "Yellow")
116
+ env.deploy("version1")
117
+ assert @eb_driver.environment_exists?('myapp', t('production', 'myapp'))
118
+ end
119
+
120
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ class EbEventPollerTest < Test::Unit::TestCase
4
+ def setup
5
+ @eb = EBStub.new
6
+ @poller = EbDeployer::EventPoller.new(EbDeployer::EbEventSource.new("myapp", "test", @eb))
7
+ end
8
+
9
+ def test_run_handle_block_through_all_events_when_there_is_no_from_anchor
10
+ messages_handled = []
11
+ @eb.set_events('myapp', 'test', ['a', 'b', nil])
12
+ @poller.poll(nil) do |event|
13
+ break if event[:message].nil?
14
+ messages_handled << event[:message]
15
+ end
16
+
17
+ assert_equal ['a', 'b'], messages_handled
18
+ end
19
+
20
+
21
+ def test_can_poll_all_events_after_an_anchor
22
+ @eb.set_events('myapp', 'test', ['a', 'b'], ['c', 'd', nil])
23
+ anchor = @poller.get_anchor
24
+ messages_handled = []
25
+ @poller.poll(anchor) do |event|
26
+ break if event[:message].nil?
27
+ messages_handled << event[:message]
28
+ end
29
+
30
+ assert_equal ['c', 'd'], messages_handled
31
+ end
32
+ end
@@ -0,0 +1,110 @@
1
+ require 'deploy_test'
2
+
3
+ class InplaceUpdateDeployTest < DeployTest
4
+ def test_first_deployment_create_eb_application
5
+ assert !@eb.application_exists?('simple')
6
+ deploy(:application => 'simple', :environment => "production")
7
+ assert @eb.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.environment_settings('simple', t('production', 'simple'))
18
+
19
+ end
20
+
21
+ def test_first_deployment_create_environment
22
+ assert !@eb.environment_exists?('simple', t('production', 'simple'))
23
+ deploy(:application => 'simple', :environment => "production")
24
+ assert @eb.environment_exists?('simple', t('production', 'simple'))
25
+ end
26
+
27
+ def test_support_very_very_long_app_name
28
+ deploy(:application => 'ver-very-simple-application', :environment => "production")
29
+ assert @eb.environment_exists?('ver-very-simple-application', t('production', 'ver-very-simple-application'))
30
+ end
31
+
32
+ def test_should_raise_error_when_env_name_is_too_long
33
+ assert_raises(RuntimeError) { deploy(:application => 'simple', :environment => "p" * 24) }
34
+ end
35
+
36
+ def test_update_environment_with_new_version_should_change_version_that_deployed
37
+ deploy(:application => 'simple',
38
+ :environment => "production",
39
+ :version_label => 1)
40
+ assert_equal '1', @eb.environment_verion_label('simple', t('production', 'simple'))
41
+
42
+ deploy(:application => 'simple',
43
+ :environment => "production",
44
+ :version_label => 2)
45
+
46
+ assert_equal '2', @eb.environment_verion_label('simple', t('production', 'simple'))
47
+ end
48
+
49
+ def test_smoke_test_should_be_run_after_env_created_or_update
50
+ host_for_smoke_test = nil
51
+ deploy(:application => 'simple',
52
+ :environment => "production",
53
+ :cname_prefix => 'foobar',
54
+ :smoke_test => lambda { |host| host_for_smoke_test = host },
55
+ :version_label => 42)
56
+ assert_equal 'foobar.us-west-1.elasticbeanstalk.com', host_for_smoke_test
57
+
58
+ host_for_smoke_test = nil
59
+ deploy(:application => 'simple',
60
+ :environment => "production",
61
+ :cname_prefix => 'foobar',
62
+ :smoke_test => lambda { |host| host_for_smoke_test = host },
63
+ :version_label => 43)
64
+
65
+ assert_equal 'foobar.us-west-1.elasticbeanstalk.com', host_for_smoke_test
66
+ end
67
+
68
+ def test_should_terminate_old_environment_if_phoenix_mode_is_enabled
69
+ deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
70
+ assert @eb.environment_exists?('simple', t('production', 'simple'))
71
+ deploy(:application => 'simple', :environment => "production", :phoenix_mode => true)
72
+ assert @eb.environments_been_deleted('simple').include?(t('production', 'simple'))
73
+ assert @eb.environment_exists?('simple', t('production', 'simple'))
74
+ end
75
+
76
+ def test_destroy_should_clean_up_env
77
+ deploy(:application => 'simple', :environment => "production")
78
+ destroy(:application => 'simple', :environment => 'production')
79
+ assert !@eb.environment_exists?('simple', t('production', 'simple'))
80
+ end
81
+
82
+ def test_deploy_should_raise_error_when_constantly_hitting_throttling_error
83
+ throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
84
+ @eb.set_error(:fetch_events, throttling_error)
85
+ assert_raises(Aws::ElasticBeanstalk::Errors::Throttling) do
86
+ deploy(:application => 'simple', :environment => "production")
87
+ end
88
+ end
89
+
90
+ def test_deploy_should_retry_on_temporary_throttling_error_from_fetch_events
91
+ throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
92
+ error_seq = [throttling_error] * 5
93
+ @eb.set_error_generator(:fetch_events) do
94
+ error_seq.pop
95
+ end
96
+ deploy(:application => 'simple', :environment => "production")
97
+ assert @eb.environment_exists?('simple', t('production', 'simple'))
98
+ end
99
+
100
+ def test_deploy_should_retry_on_temporary_throttling_error_from_create_env
101
+ throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
102
+ error_seq = [throttling_error] * 5
103
+ @eb.set_error_generator(:create_environment) do
104
+ error_seq.pop
105
+ end
106
+ deploy(:application => 'simple', :environment => "production")
107
+ assert @eb.environment_exists?('simple', t('production', 'simple'))
108
+ end
109
+
110
+ end