eb_deployer 0.3.8 → 0.3.9

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.
@@ -0,0 +1,94 @@
1
+ require 'deploy_test'
2
+ class LegacyEnvMigrateDeployTest < DeployTest
3
+
4
+ def setup
5
+ super
6
+ @eb_driver.create_application("simple")
7
+ end
8
+
9
+ def test_should_clean_up_legacy_environment_in_inplace_update_deployment
10
+ legacy_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production")
11
+ @eb_driver.create_environment("simple", legacy_env_name, 'solution-stack', 'simple-production', 'foo', 'web' ,{})
12
+ deploy(:application => 'simple',
13
+ :environment => 'production',
14
+ :version_label => 1)
15
+ assert @eb_driver.environment_exists?("simple", "production")
16
+ assert !@eb_driver.environment_exists?("simple", legacy_env_name)
17
+ end
18
+
19
+ def test_should_clean_up_legacy_environment_in_blue_green_deployment
20
+ legacy_a_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-a")
21
+ legacy_b_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-b")
22
+
23
+ @eb_driver.create_environment("simple", legacy_a_env_name, 'solution-stack', 'simple-production', 'foo', 'web' ,{})
24
+ @eb_driver.create_environment("simple", legacy_b_env_name, 'solution-stack', 'simple-production-inactive', 'foo', 'web' ,{})
25
+
26
+ deploy(:application => 'simple',
27
+ :environment => 'production',
28
+ :strategy => 'blue-green')
29
+
30
+
31
+ assert !@eb_driver.environment_exists?("simple", legacy_b_env_name)
32
+ assert @eb_driver.environment_exists?("simple", legacy_a_env_name)
33
+
34
+ assert @eb_driver.environment_exists?("simple", "production-b")
35
+ assert !@eb_driver.environment_exists?("simple", "production-a")
36
+
37
+ assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-b')
38
+ assert_equal 'simple-production-inactive', @eb_driver.environment_cname_prefix('simple', legacy_a_env_name)
39
+
40
+ deploy(:application => 'simple',
41
+ :environment => 'production',
42
+ :strategy => :blue_green)
43
+
44
+ assert @eb_driver.environment_exists?("simple", "production-a")
45
+ assert @eb_driver.environment_exists?("simple", "production-b")
46
+ assert !@eb_driver.environment_exists?("simple", legacy_a_env_name)
47
+ assert !@eb_driver.environment_exists?("simple", legacy_b_env_name)
48
+
49
+ assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-a')
50
+ assert_equal 'simple-production-inactive', @eb_driver.environment_cname_prefix('simple', 'production-b')
51
+ end
52
+
53
+ def test_should_clean_up_legacy_environment_in_blue_green_deployment_when_only_active_en_is_there
54
+ legacy_a_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-a")
55
+ legacy_b_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-b")
56
+ @eb_driver.create_environment("simple", legacy_a_env_name, 'solution-stack', 'simple-production', 'foo', 'web' ,{})
57
+
58
+ deploy(:application => 'simple',
59
+ :environment => 'production',
60
+ :strategy => 'blue-green')
61
+
62
+
63
+ assert @eb_driver.environment_exists?("simple", "production-b")
64
+ assert !@eb_driver.environment_exists?("simple", "production-a")
65
+ assert !@eb_driver.environment_exists?("simple", legacy_b_env_name)
66
+ assert @eb_driver.environment_exists?("simple", legacy_a_env_name)
67
+
68
+ assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-b')
69
+ assert_equal 'simple-production-inactive', @eb_driver.environment_cname_prefix('simple', legacy_a_env_name)
70
+
71
+ deploy(:application => 'simple',
72
+ :environment => 'production',
73
+ :strategy => 'blue-green')
74
+
75
+ assert @eb_driver.environment_exists?("simple", "production-a")
76
+ assert @eb_driver.environment_exists?("simple", "production-b")
77
+ assert !@eb_driver.environment_exists?("simple", legacy_a_env_name)
78
+ assert !@eb_driver.environment_exists?("simple", legacy_b_env_name)
79
+
80
+ assert_equal 'simple-production', @eb_driver.environment_cname_prefix('simple', 'production-a')
81
+ assert_equal 'simple-production-inactive', @eb_driver.environment_cname_prefix('simple', 'production-b')
82
+
83
+ end
84
+
85
+ def test_terminate_legacy_environments
86
+ legacy_a_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-a")
87
+ legacy_b_env_name = EbDeployer::EbEnvironment.legacy_ebenv_name("simple", "production-b")
88
+ @eb_driver.create_environment("simple", legacy_a_env_name, 'solution-stack', 'simple-production', 'foo', 'web' ,{})
89
+ destroy(:application => 'simple')
90
+
91
+ assert !@eb_driver.environment_exists?("simple", legacy_a_env_name)
92
+ assert !@eb_driver.environment_exists?("simple", legacy_b_env_name)
93
+ end
94
+ end
@@ -0,0 +1,122 @@
1
+ require 'deploy_test'
2
+
3
+ class ResourcesDeployTest < DeployTest
4
+
5
+ def test_deploy_with_resources_declared_will_create_a_cf_stack_for_env
6
+ cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
7
+ deploy(:application => 'simple', :environment => "production",
8
+ :resources => {
9
+ :template => cf_template
10
+ })
11
+ assert @cf_driver.stack_exists?('simple-production')
12
+ assert_equal({}, @cf_driver.stack_config('simple-production')[:parameters])
13
+ assert_equal([], @cf_driver.stack_config('simple-production')[:capabilities])
14
+ end
15
+
16
+ def test_provision_resources_with_capacities
17
+ cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
18
+ deploy(:application => 'simple', :environment => "production",
19
+ :resources => {
20
+ :template => cf_template,
21
+ :capabilities => ['CAPABILITY_IAM']
22
+ })
23
+ assert_equal ['CAPABILITY_IAM'], @cf_driver.stack_config('simple-production')[:capabilities]
24
+ end
25
+
26
+ def test_provision_resources_with_parameters
27
+ cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
28
+ deploy(:application => 'simple', :environment => "production",
29
+ :resources => {
30
+ :template => cf_template,
31
+ :parameters => {'a' => 1}
32
+ })
33
+ assert_equal({'a' => 1 }, @cf_driver.stack_config('simple-production')[:parameters])
34
+ end
35
+
36
+ def test_skip_resource_update
37
+ cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}}}))
38
+ deploy(:application => 'simple', :environment => "production",
39
+ :resources => {
40
+ :template => cf_template,
41
+ :parameters => {'a' => 1 }
42
+ })
43
+ assert_equal(1, @cf_driver.stack_config('simple-production')[:parameters]['a'])
44
+ deploy(:application => 'simple', :environment => "production",
45
+ :resources => {
46
+ :template => cf_template,
47
+ :parameters => {'a' => 2 }
48
+ })
49
+ assert_equal(2, @cf_driver.stack_config('simple-production')[:parameters]['a'])
50
+ deploy(:application => 'simple',
51
+ :environment => "production",
52
+ :skip_resource_stack_update => true,
53
+ :resources => {
54
+ :template => cf_template,
55
+ :parameters => {'a' => 3 }
56
+ })
57
+ assert_equal(2, @cf_driver.stack_config('simple-production')[:parameters]['a'])
58
+ end
59
+
60
+ def test_should_still_query_output_to_set_eb_options_even_skip_resources_update_is_specified
61
+ cf_template = temp_file(JSON.dump({'Resources' => {'R1' => {}},
62
+ 'Outputs' => {'O1' => {}, 'O2' => {}}}))
63
+ deploy(:application => 'simple', :environment => "production",
64
+ :resources => {
65
+ :template => cf_template
66
+ })
67
+
68
+ deploy(:application => 'simple', :environment => "production",
69
+ :skip_resource_stack_update => true,
70
+ :resources => {
71
+ :template => cf_template,
72
+ :transforms => {
73
+ 'O2' => lambda { |v| {:namespace => 'aws.foo', :option_name => 'o2', :value => "transformed " + v} }
74
+ }
75
+ })
76
+
77
+ assert @eb_driver.environment_settings('simple', 'production').
78
+ include?({:namespace => 'aws.foo', :option_name => 'o2', :value => 'transformed value of O2'})
79
+ end
80
+
81
+
82
+ def test_transforms_resource_provsion_output_to_elastic_beanstalk_settings
83
+ cf_template = temp_file(JSON.dump({
84
+ 'Resources' => {'R1' => {}},
85
+ 'Outputs' => {'O1' => {}, 'O2' => {}}
86
+ }))
87
+ deploy(:application => 'simple', :environment => "production",
88
+ :resources => {
89
+ :template => cf_template,
90
+ :transforms => {
91
+ 'O1' => lambda { |v| {:namespace => 'aws.foo', :option_name => 'o1', :value => v} }
92
+ }
93
+ })
94
+ assert @eb_driver.environment_settings('simple', 'production').
95
+ include?({:namespace => 'aws.foo', :option_name => 'o1', :value => 'value of O1'})
96
+ end
97
+
98
+ def test_can_query_resource_stack_output_after_deploy
99
+ cf_template = temp_file(JSON.dump({
100
+ 'Resources' => {'R1' => {}},
101
+ 'Outputs' => {'O1' => {}, 'O2' => {}}
102
+ }))
103
+ deploy(:application => 'simple',
104
+ :environment => "production",
105
+ :resources => { :template => cf_template })
106
+ assert_equal 'value of O1', query_resource_output('O1',
107
+ :application => 'simple',
108
+ :environment => "production")
109
+ assert_equal 'value of O2', query_resource_output('O2',
110
+ :application => 'simple',
111
+ :environment => "production")
112
+
113
+ end
114
+
115
+ def test_should_raise_error_if_query_resources_that_have_not_been_provisioned_yet
116
+ assert_raises(EbDeployer::ResourceNotInReadyState) do
117
+ query_resource_output('O1',
118
+ :application => 'simple',
119
+ :environment => "production")
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,19 @@
1
+ require 'deploy_test'
2
+
3
+ class TierSettingDeployTest < DeployTest
4
+ def test_sets_default_tier_as_webserver
5
+ deploy(:application => 'simple', :environment => "production")
6
+ assert_equal EbDeployer.environment_tier('WebServer'), @eb_driver.environment_tier('simple', 'production')
7
+ end
8
+
9
+ def test_can_change_tier
10
+ deploy(:application => 'simple', :environment => "production", :tier => 'Worker')
11
+ assert_equal EbDeployer.environment_tier('Worker'), @eb_driver.environment_tier('simple', 'production')
12
+ end
13
+
14
+ def test_should_raise_error_when_tier_setting_is_not_recognized
15
+ assert_raises(RuntimeError) do
16
+ deploy(:application => 'simple', :environment => "production", :tier => 'Gum')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,120 @@
1
+ require 'deploy_test'
2
+
3
+ class VersionsDeployTest < DeployTest
4
+
5
+ def test_deployment_with_s3_package_specification
6
+ File.open('mingle_package.yml', 'w') do |f|
7
+ f.write("s3_bucket: test-bucket\n")
8
+ f.write("s3_key: test-mingle.war")
9
+ end
10
+
11
+ deploy(:application => 'simple', :environment => "production",
12
+ :package => 'mingle_package.yml', :version_label => 1)
13
+ assert @eb_driver.application_exists?('simple')
14
+ last_version = @eb_driver.application_versions('simple').last
15
+ assert_equal({'s3_bucket' => 'test-bucket', 's3_key' => 'test-mingle.war'}, last_version[:source_bundle])
16
+ ensure
17
+ FileUtils.rm_rf('mingle_package.yml')
18
+ end
19
+
20
+
21
+
22
+ def test_version_prefix_should_be_prepended_to_version_label
23
+ deploy(:application => 'simple',
24
+ :environment => "production",
25
+ :version_label => 1,
26
+ :version_prefix => "prod-")
27
+ assert_equal 'prod-1', @eb_driver.environment_verion_label('simple', 'production')
28
+ end
29
+
30
+ def test_should_keep_only_number_of_versions_specified
31
+ deploy(:application => 'simple',
32
+ :environment => "production",
33
+ :version_label => 1)
34
+
35
+ deploy(:application => 'simple',
36
+ :environment => "production",
37
+ :version_label => 2)
38
+
39
+ deploy(:application => 'simple',
40
+ :environment => "production",
41
+ :version_label => 3,
42
+ :keep_latest => 2)
43
+
44
+ assert_equal '1', @eb_driver.versions_deleted('simple').first
45
+ end
46
+
47
+ def test_should_only_remove_versions_with_matching_prefix
48
+ deploy(:application => 'simple',
49
+ :environment => "production",
50
+ :version_label => 1,
51
+ :version_prefix => "prod1-",
52
+ :keep_latest => 1)
53
+ deploy(:application => 'simple',
54
+ :environment => "production",
55
+ :version_label => 2,
56
+ :version_prefix => "prod1-",
57
+ :keep_latest => 1)
58
+ deploy(:application => 'simple',
59
+ :environment => "production",
60
+ :version_label => 1,
61
+ :version_prefix => "prod2-",
62
+ :keep_latest => 1)
63
+
64
+ assert_equal 'prod1-1', @eb_driver.versions_deleted('simple').first
65
+ assert_equal 1, @eb_driver.versions_deleted('simple').count
66
+
67
+ app_versions = @eb_driver.application_versions('simple').map { |apv| apv[:version_label] }
68
+ assert_equal ["prod1-2", "prod2-1"], app_versions
69
+ end
70
+
71
+ def test_default_cname_that_deployed_should_app_env_name
72
+ deploy(:application => 'simple',
73
+ :environment => "production",
74
+ :version_label => 42)
75
+ assert_equal "simple-production", @eb_driver.environment_cname_prefix('simple', 'production')
76
+ end
77
+
78
+ def test_cname_prefix_can_be_override
79
+ deploy(:application => 'simple',
80
+ :environment => "production",
81
+ :cname_prefix => 'sports123',
82
+ :version_label => 42)
83
+ assert_equal "sports123", @eb_driver.environment_cname_prefix('simple', 'production')
84
+ end
85
+
86
+ def test_pass_s3_object_name_as_package_file
87
+ package_name = 'test-bucket:test-mingle.war'
88
+
89
+ deploy(:package => package_name,
90
+ :application => 'simple',
91
+ :environment => "production",
92
+ :version_label => 1)
93
+
94
+ assert @eb_driver.application_exists?('simple')
95
+ last_version = @eb_driver.application_versions('simple').last
96
+ assert_equal({'s3_bucket' => 'test-bucket', 's3_key' => 'test-mingle.war'}, last_version[:source_bundle])
97
+ end
98
+
99
+ def test_set_s3_bucket_name_on_deployment
100
+ deploy(:application => 'simple',
101
+ :environment => "production",
102
+ :package_bucket => 'thoughtworks.simple')
103
+
104
+ assert @s3_driver.bucket_exists?('thoughtworks.simple.packages')
105
+ end
106
+
107
+
108
+ def test_pass_pathname_as_package_file
109
+ deploy(:package => Pathname.new(@sample_package),
110
+ :application => 'simple',
111
+ :environment => "production",
112
+ :package_bucket => 'thoughtworks.simple')
113
+
114
+ s3_objects = @s3_driver.objects('thoughtworks.simple.packages')
115
+ assert_equal 1, s3_objects.size
116
+ assert_equal @sample_package, s3_objects.values.first.to_s
117
+ end
118
+
119
+
120
+ end
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eb_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - wpc
8
8
  - betarelease
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2014-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- version_requirements: !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
- requirement: !ruby/object:Gem::Requirement
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
22
24
  requirements:
23
- - - '>='
25
+ - - ! '>='
24
26
  - !ruby/object:Gem::Version
25
27
  version: '0'
26
- prerelease: false
27
- type: :runtime
28
28
  description: For automating Blue-Green deployment flows on Elastic Beanstalk.
29
29
  email:
30
30
  - alex.hal9000@gmail.com
@@ -67,42 +67,56 @@ files:
67
67
  - lib/eb_deployer/version.rb
68
68
  - lib/eb_deployer/version_cleaner.rb
69
69
  - test/aws_driver_stubs.rb
70
+ - test/blue_green_deploy_test.rb
70
71
  - test/cloud_formation_provisioner_test.rb
71
72
  - test/config_loader_test.rb
72
73
  - test/deploy_test.rb
73
74
  - test/eb_environment_test.rb
75
+ - test/inplace_update_deploy_test.rb
76
+ - test/legacy_env_migrate_deploy_test.rb
77
+ - test/resources_deploy_test.rb
74
78
  - test/smoke_test_test.rb
75
79
  - test/test_helper.rb
80
+ - test/tier_setting_deploy_test.rb
81
+ - test/versions_deploy_test.rb
76
82
  homepage: https://github.com/ThoughtWorksStudios/eb_deployer
77
83
  licenses:
78
84
  - MIT
79
85
  metadata: {}
80
- post_install_message:
86
+ post_install_message:
81
87
  rdoc_options: []
82
88
  require_paths:
83
89
  - lib
84
90
  required_ruby_version: !ruby/object:Gem::Requirement
85
91
  requirements:
86
- - - '>='
92
+ - - ! '>='
87
93
  - !ruby/object:Gem::Version
88
94
  version: '0'
89
95
  required_rubygems_version: !ruby/object:Gem::Requirement
90
96
  requirements:
91
- - - '>='
97
+ - - ! '>='
92
98
  - !ruby/object:Gem::Version
93
99
  version: '0'
94
100
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.2.1
97
- signing_key:
101
+ rubyforge_project:
102
+ rubygems_version: 2.2.0
103
+ signing_key:
98
104
  specification_version: 4
99
- summary: Low friction deployments should be a breeze. Elastic Beanstalk provides a great foundation for performing Blue-Green deployments, and EbDeployer add a missing top to automate the whole flow out of the box.
105
+ summary: Low friction deployments should be a breeze. Elastic Beanstalk provides a
106
+ great foundation for performing Blue-Green deployments, and EbDeployer add a missing
107
+ top to automate the whole flow out of the box.
100
108
  test_files:
101
109
  - test/aws_driver_stubs.rb
110
+ - test/blue_green_deploy_test.rb
102
111
  - test/cloud_formation_provisioner_test.rb
103
112
  - test/config_loader_test.rb
104
113
  - test/deploy_test.rb
105
114
  - test/eb_environment_test.rb
115
+ - test/inplace_update_deploy_test.rb
116
+ - test/legacy_env_migrate_deploy_test.rb
117
+ - test/resources_deploy_test.rb
106
118
  - test/smoke_test_test.rb
107
119
  - test/test_helper.rb
108
- has_rdoc:
120
+ - test/tier_setting_deploy_test.rb
121
+ - test/versions_deploy_test.rb
122
+ has_rdoc: