eb_deployer 0.6.0.beta5 → 0.6.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +16 -2
- data/lib/eb_deployer/aws_driver/cloud_formation_driver.rb +8 -15
- data/lib/eb_deployer/cf_event_source.rb +26 -0
- data/lib/eb_deployer/cloud_formation_provisioner.rb +34 -15
- data/lib/eb_deployer/default_config.yml +1 -1
- data/lib/eb_deployer/deployment_strategy/blue_green.rb +6 -6
- data/lib/eb_deployer/deployment_strategy/blue_only.rb +6 -6
- data/lib/eb_deployer/deployment_strategy/inplace_update.rb +3 -3
- data/lib/eb_deployer/deployment_strategy.rb +4 -4
- data/lib/eb_deployer/eb_environment.rb +1 -1
- data/lib/eb_deployer/eb_event_source.rb +35 -0
- data/lib/eb_deployer/event_poller.rb +7 -27
- data/lib/eb_deployer/version.rb +1 -1
- data/lib/eb_deployer.rb +8 -3
- data/lib/generators/eb_deployer/install/templates/eb_deployer.yml.erb +1 -1
- data/test/aws_driver_stubs.rb +34 -0
- data/test/cf_event_poller_test.rb +32 -0
- data/test/{event_poller_test.rb → eb_event_poller_test.rb} +2 -2
- data/test/test_helper.rb +1 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efa2db8d5f05ab918bb9466b260d9f617d36ee7b
|
4
|
+
data.tar.gz: dd4301dc2e402e64609d0a898f153bd18b1703a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dfbdc52c6c5b943bad1470d61ac2547917f439579606b58285db9858b7879793ed855d47d830fb4ef8dd5058b0216115867f3487f5549d5825d62427ecceeb2
|
7
|
+
data.tar.gz: 7fe2d1e43f6bef25e2ebc4e10ea1fe65d144df7f25fbedef53997a8c70670446efda243f181390a0c1d4ec5622af5f81f599240016859dd6b86e3b0991b29a8c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# EbDeployer [![Build Status](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master/build_image)](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master) [![Build Status](https://travis-ci.org/ThoughtWorksStudios/eb_deployer.png?branch=master)](https://travis-ci.org/ThoughtWorksStudios/eb_deployer)
|
2
2
|
|
3
|
-
[Built with :yellow_heart: and :coffee: in San Francisco](http://
|
3
|
+
[Built with :yellow_heart: and :coffee: in San Francisco](http://www.thoughtworks.com/mingle/team/)
|
4
4
|
|
5
5
|
Low friction deployments should be a breeze. Elastic Beanstalk provides a great foundation for performing Blue-Green deployments, and EbDeployer add a missing link to automate the whole flow out of box.
|
6
6
|
|
7
7
|
EbDeployer thus allows you to do continuous delivery on AWS.
|
8
8
|
|
9
|
-
[
|
9
|
+
[Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -93,10 +93,20 @@ Take a look at code if you can not wait for the documentation.
|
|
93
93
|
|
94
94
|
## More
|
95
95
|
|
96
|
+
[Automated zero downtime deployment to AWS Elastic Beanstalk for Rails with EbDeployer](http://helabs.com/blog/2015/05/19/automated-zero-downtime-deployment-to-aws-elastic-beanstalk-for-rails-with-eb-deployer/?utm_content=buffer12098&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer)
|
97
|
+
|
98
|
+
[Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
|
99
|
+
|
96
100
|
[Rails 3/4 Support](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Rails-3-Support)
|
97
101
|
|
98
102
|
[EbDeployer environment](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/EbDeployer-environment)
|
99
103
|
|
104
|
+
[Introduction to EbDeployer](http://getmingle.io/scaling/2014/06/13/introduction-to-eb-deployer.html)
|
105
|
+
|
106
|
+
AWS re:Invent 2013: [slideshare](http://www.slideshare.net/AmazonWebServices/aws-elastic-beanstalk-under-the-hood-dmg301-aws-reinvent-2013-28428616) and [video (starting at 27:46)](http://www.youtube.com/watch?v=U06-QLd4FL4)
|
107
|
+
|
108
|
+
[Papertrail Solution for Rails Applications on ElasticBeanstalk
|
109
|
+
](http://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html)
|
100
110
|
## Contributing
|
101
111
|
|
102
112
|
1. Fork it
|
@@ -104,3 +114,7 @@ Take a look at code if you can not wait for the documentation.
|
|
104
114
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
105
115
|
4. Push to the branch (`git push origin my-new-feature`)
|
106
116
|
5. Create new Pull Request
|
117
|
+
|
118
|
+
|
119
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ThoughtWorksStudios/eb_deployer/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
120
|
+
|
@@ -20,21 +20,9 @@ module EbDeployer
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def update_stack(name, template, opts)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:parameters => convert_parameters(opts[:parameters])))
|
27
|
-
rescue Aws::CloudFormation::Errors::ValidationError => e
|
28
|
-
if e.message =~ /No updates are to be performed/
|
29
|
-
log(e.message)
|
30
|
-
else
|
31
|
-
raise
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def stack_status(name)
|
37
|
-
describe_stack(name)[:stack_status].downcase.to_sym
|
23
|
+
@client.update_stack(opts.merge(:stack_name => name,
|
24
|
+
:template_body => template,
|
25
|
+
:parameters => convert_parameters(opts[:parameters])))
|
38
26
|
end
|
39
27
|
|
40
28
|
def query_output(name, key)
|
@@ -42,6 +30,11 @@ module EbDeployer
|
|
42
30
|
output && output[:output_value]
|
43
31
|
end
|
44
32
|
|
33
|
+
def fetch_events(name, options={})
|
34
|
+
response = @client.describe_stack_events(options.merge(:stack_name => name))
|
35
|
+
return response.stack_events, response.next_token
|
36
|
+
end
|
37
|
+
|
45
38
|
private
|
46
39
|
|
47
40
|
def describe_stack(name)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EbDeployer
|
2
|
+
class CfEventSource
|
3
|
+
def initialize(stack_name, cf_driver)
|
4
|
+
@stack_name = stack_name
|
5
|
+
@cf_driver = cf_driver
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_anchor
|
9
|
+
events, _ = @cf_driver.fetch_events(@stack_name)
|
10
|
+
events.first
|
11
|
+
end
|
12
|
+
|
13
|
+
def fetch_events(from_anchor, &block)
|
14
|
+
events, next_token = @cf_driver.fetch_events(@stack_name)
|
15
|
+
should_continue = yield(events)
|
16
|
+
fetch_next(next_token, &block) if next_token && should_continue
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def fetch_next(next_token, &block)
|
21
|
+
events, next_token = @cf_driver.fetch_events(@stack_name, :next_token => next_token)
|
22
|
+
should_continue = yield(events)
|
23
|
+
fetch_next(next_token, &block) if next_token && should_continue
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,12 +3,13 @@ module EbDeployer
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class CloudFormationProvisioner
|
6
|
-
SUCCESS_STATS = [
|
7
|
-
FAILED_STATS = [
|
6
|
+
SUCCESS_STATS = ["CREATE_COMPLETE", "UPDATE_COMPLETE"]
|
7
|
+
FAILED_STATS = ["CREATE_FAILED", "UPDATE_FAILED"]
|
8
8
|
|
9
9
|
def initialize(stack_name, cf_driver)
|
10
10
|
@stack_name = stack_name
|
11
11
|
@cf_driver = cf_driver
|
12
|
+
@poller = EventPoller.new(CfEventSource.new(@stack_name, @cf_driver))
|
12
13
|
end
|
13
14
|
|
14
15
|
def provision(resources)
|
@@ -16,8 +17,24 @@ module EbDeployer
|
|
16
17
|
template = File.read(resources[:template])
|
17
18
|
capabilities = resources[:capabilities] || []
|
18
19
|
params = resources[:inputs] || resources[:parameters] || {}
|
19
|
-
|
20
|
-
|
20
|
+
anchor = nil
|
21
|
+
begin
|
22
|
+
if stack_exists?
|
23
|
+
anchor = @poller.get_anchor
|
24
|
+
update_stack(template, params, capabilities)
|
25
|
+
else
|
26
|
+
create_stack(template, params, capabilities)
|
27
|
+
end
|
28
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
29
|
+
if e.message =~ /No updates are to be performed/
|
30
|
+
log(e.message)
|
31
|
+
return
|
32
|
+
else
|
33
|
+
raise
|
34
|
+
end
|
35
|
+
end
|
36
|
+
wait_for_stack_op_terminate(anchor)
|
37
|
+
log("Resource stack provisioned successfully")
|
21
38
|
end
|
22
39
|
|
23
40
|
def transform_outputs(resources)
|
@@ -65,10 +82,6 @@ module EbDeployer
|
|
65
82
|
:parameters => params)
|
66
83
|
end
|
67
84
|
|
68
|
-
def stack_status
|
69
|
-
@cf_driver.stack_status(@stack_name)
|
70
|
-
end
|
71
|
-
|
72
85
|
def transform_output_to_settings(transforms)
|
73
86
|
(transforms || []).inject([]) do |settings, pair|
|
74
87
|
key, transform = pair
|
@@ -77,16 +90,22 @@ module EbDeployer
|
|
77
90
|
end.flatten
|
78
91
|
end
|
79
92
|
|
80
|
-
def wait_for_stack_op_terminate
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
93
|
+
def wait_for_stack_op_terminate(anchor)
|
94
|
+
@poller.poll(anchor) do |event|
|
95
|
+
log_event(event)
|
96
|
+
if FAILED_STATS.include?(event.resource_status)
|
97
|
+
raise "Resource stack update failed!"
|
98
|
+
end
|
99
|
+
|
100
|
+
break if event.logical_resource_id == @stack_name && SUCCESS_STATS.include?(event.resource_status)
|
87
101
|
end
|
88
102
|
end
|
89
103
|
|
104
|
+
def log_event(event)
|
105
|
+
puts "[#{event.timestamp}][cloud_formation_provisioner] #{event.resource_type}(#{event.logical_resource_id}) #{event.resource_status} \"#{event.resource_status_reason}\""
|
106
|
+
end
|
107
|
+
|
108
|
+
|
90
109
|
def log(msg)
|
91
110
|
puts "[#{Time.now.utc}][cloud_formation_provisioner] #{msg}"
|
92
111
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module EbDeployer
|
2
2
|
module DeploymentStrategy
|
3
3
|
class BlueGreen
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(component)
|
5
|
+
@component = component
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_compatibility(env_create_options)
|
@@ -14,7 +14,7 @@ module EbDeployer
|
|
14
14
|
|
15
15
|
def deploy(version_label, env_settings, inactive_settings=[])
|
16
16
|
if !ebenvs.any?(&method(:active_ebenv?))
|
17
|
-
ebenv('a', @
|
17
|
+
ebenv('a', @component.cname_prefix).
|
18
18
|
deploy(version_label, env_settings)
|
19
19
|
return
|
20
20
|
end
|
@@ -32,7 +32,7 @@ module EbDeployer
|
|
32
32
|
|
33
33
|
private
|
34
34
|
def active_ebenv?(ebenv)
|
35
|
-
ebenv.cname_prefix == @
|
35
|
+
ebenv.cname_prefix == @component.cname_prefix
|
36
36
|
end
|
37
37
|
|
38
38
|
def ebenvs
|
@@ -40,11 +40,11 @@ module EbDeployer
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def ebenv(suffix, cname_prefix=nil)
|
43
|
-
@
|
43
|
+
@component.new_eb_env(suffix, cname_prefix || inactive_cname_prefix)
|
44
44
|
end
|
45
45
|
|
46
46
|
def inactive_cname_prefix
|
47
|
-
"#{@
|
47
|
+
"#{@component.cname_prefix}-inactive"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module EbDeployer
|
2
2
|
module DeploymentStrategy
|
3
3
|
class BlueOnly
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(component)
|
5
|
+
@component = component
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_compatibility(env_create_options)
|
@@ -14,7 +14,7 @@ module EbDeployer
|
|
14
14
|
|
15
15
|
def deploy(version_label, env_settings, inactive_settings=[])
|
16
16
|
if !ebenvs.any?(&method(:active_ebenv?))
|
17
|
-
ebenv('a', @
|
17
|
+
ebenv('a', @component.cname_prefix).
|
18
18
|
deploy(version_label, env_settings)
|
19
19
|
return
|
20
20
|
end
|
@@ -27,7 +27,7 @@ module EbDeployer
|
|
27
27
|
|
28
28
|
private
|
29
29
|
def active_ebenv?(ebenv)
|
30
|
-
ebenv.cname_prefix == @
|
30
|
+
ebenv.cname_prefix == @component.cname_prefix
|
31
31
|
end
|
32
32
|
|
33
33
|
def ebenvs
|
@@ -35,11 +35,11 @@ module EbDeployer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def ebenv(suffix, cname_prefix=nil)
|
38
|
-
@
|
38
|
+
@component.new_eb_env(suffix, cname_prefix || inactive_cname_prefix)
|
39
39
|
end
|
40
40
|
|
41
41
|
def inactive_cname_prefix
|
42
|
-
"#{@
|
42
|
+
"#{@component.cname_prefix}-inactive"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module EbDeployer
|
2
2
|
module DeploymentStrategy
|
3
3
|
class InplaceUpdate
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(component)
|
5
|
+
@component = component
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_compatibility(env_create_opts)
|
9
9
|
end
|
10
10
|
|
11
11
|
def deploy(version_label, env_settings, inactive_settings)
|
12
|
-
@
|
12
|
+
@component.new_eb_env.deploy(version_label, env_settings)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -4,14 +4,14 @@ require 'eb_deployer/deployment_strategy/blue_only'
|
|
4
4
|
|
5
5
|
module EbDeployer
|
6
6
|
module DeploymentStrategy
|
7
|
-
def self.create(
|
7
|
+
def self.create(component, strategy_name)
|
8
8
|
case strategy_name.to_s
|
9
9
|
when 'inplace_update', 'inplace-update'
|
10
|
-
InplaceUpdate.new(
|
10
|
+
InplaceUpdate.new(component)
|
11
11
|
when 'blue_green', 'blue-green'
|
12
|
-
BlueGreen.new(
|
12
|
+
BlueGreen.new(component)
|
13
13
|
when 'blue_only', 'blue-only'
|
14
|
-
BlueOnly.new(
|
14
|
+
BlueOnly.new(component)
|
15
15
|
else
|
16
16
|
raise 'strategy_name: ' + strategy_name.to_s + ' not supported'
|
17
17
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module EbDeployer
|
2
|
+
class EbEventSource
|
3
|
+
def initialize(app, env, eb_driver)
|
4
|
+
@app, @env, @eb_driver = app, env, eb_driver
|
5
|
+
end
|
6
|
+
|
7
|
+
def get_anchor
|
8
|
+
events, _ = fetch_events_from_eb(:max_records => 1)
|
9
|
+
events.first
|
10
|
+
end
|
11
|
+
|
12
|
+
def fetch_events(from_anchor, &block)
|
13
|
+
options = {}
|
14
|
+
if from_anchor && from_anchor[:event_date]
|
15
|
+
options[:start_time] = from_anchor[:event_date].iso8601
|
16
|
+
end
|
17
|
+
events, next_token = fetch_events_from_eb(options)
|
18
|
+
should_continue = yield(events)
|
19
|
+
fetch_next(next_token, &block) if next_token && should_continue
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def fetch_next(next_token, &block)
|
25
|
+
events, next_token = fetch_events_from_eb(:next_token => next_token)
|
26
|
+
should_continue = yield(events)
|
27
|
+
fetch_next(next_token, &block) if next_token && should_continue
|
28
|
+
end
|
29
|
+
|
30
|
+
def fetch_events_from_eb(options)
|
31
|
+
@eb_driver.fetch_events(@app, @env, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module EbDeployer
|
2
2
|
class EventPoller
|
3
3
|
include Utils
|
4
|
+
POLL_INTERVAL = 15
|
4
5
|
|
5
|
-
def initialize(
|
6
|
-
@
|
6
|
+
def initialize(event_source)
|
7
|
+
@event_source = event_source
|
7
8
|
end
|
8
9
|
|
9
10
|
def get_anchor
|
10
|
-
|
11
|
-
events.first
|
11
|
+
@event_source.get_anchor
|
12
12
|
end
|
13
13
|
|
14
14
|
def poll(from_anchor, &block)
|
15
15
|
handled = Set.new
|
16
16
|
loop do
|
17
|
-
fetch_events(from_anchor) do |events|
|
18
|
-
# events from
|
17
|
+
@event_source.fetch_events(from_anchor) do |events|
|
18
|
+
# events from event source is latest first order
|
19
19
|
to_be_handled = []
|
20
20
|
reached_anchor = false
|
21
21
|
|
@@ -36,7 +36,7 @@ module EbDeployer
|
|
36
36
|
|
37
37
|
!reached_anchor
|
38
38
|
end
|
39
|
-
sleep
|
39
|
+
sleep POLL_INTERVAL
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -47,25 +47,5 @@ module EbDeployer
|
|
47
47
|
event = event.to_h if event.respond_to?(:to_h)
|
48
48
|
JSON.dump(event)
|
49
49
|
end
|
50
|
-
|
51
|
-
def fetch_events(from_anchor, &block)
|
52
|
-
options = {}
|
53
|
-
if from_anchor && from_anchor[:event_date]
|
54
|
-
options[:start_time] = from_anchor[:event_date].iso8601
|
55
|
-
end
|
56
|
-
events, next_token = fetch_events_from_eb(options)
|
57
|
-
should_continue = yield(events)
|
58
|
-
fetch_next(next_token, &block) if next_token && should_continue
|
59
|
-
end
|
60
|
-
|
61
|
-
def fetch_next(next_token, &block)
|
62
|
-
events, next_token = fetch_events_from_eb(:next_token => next_token)
|
63
|
-
should_continue = yield(events)
|
64
|
-
fetch_next(next_token, &block) if next_token && should_continue
|
65
|
-
end
|
66
|
-
|
67
|
-
def fetch_events_from_eb(options)
|
68
|
-
@eb_driver.fetch_events(@app, @env, options)
|
69
|
-
end
|
70
50
|
end
|
71
51
|
end
|
data/lib/eb_deployer/version.rb
CHANGED
data/lib/eb_deployer.rb
CHANGED
@@ -20,6 +20,8 @@ require 'eb_deployer/eb_environment'
|
|
20
20
|
require 'eb_deployer/environment'
|
21
21
|
require 'eb_deployer/default_component'
|
22
22
|
require 'eb_deployer/component'
|
23
|
+
require 'eb_deployer/eb_event_source'
|
24
|
+
require 'eb_deployer/cf_event_source'
|
23
25
|
require 'eb_deployer/event_poller'
|
24
26
|
require 'eb_deployer/package'
|
25
27
|
require 'eb_deployer/config_loader'
|
@@ -40,7 +42,9 @@ module EbDeployer
|
|
40
42
|
#
|
41
43
|
def self.query_resource_output(key, opts)
|
42
44
|
if region = opts[:region]
|
43
|
-
|
45
|
+
Aws.config.update({
|
46
|
+
region: region
|
47
|
+
})
|
44
48
|
end
|
45
49
|
app = opts[:application]
|
46
50
|
env_name = opts[:environment]
|
@@ -215,7 +219,7 @@ module EbDeployer
|
|
215
219
|
|
216
220
|
def self.destroy(opts)
|
217
221
|
if region = opts[:region]
|
218
|
-
|
222
|
+
Aws.config.update(:region => region)
|
219
223
|
end
|
220
224
|
|
221
225
|
app = opts[:application]
|
@@ -295,9 +299,10 @@ module EbDeployer
|
|
295
299
|
|
296
300
|
opts.on("--debug", "Output AWS debug log") do |d|
|
297
301
|
require 'logger'
|
302
|
+
require 'aws-sdk'
|
298
303
|
logger = Logger.new($stdout)
|
299
304
|
logger.level = Logger::DEBUG
|
300
|
-
|
305
|
+
Aws.config[:logger] = logger
|
301
306
|
end
|
302
307
|
|
303
308
|
opts.on("-h", "--help", "help") do
|
data/test/aws_driver_stubs.rb
CHANGED
@@ -271,6 +271,8 @@ end
|
|
271
271
|
class CFStub
|
272
272
|
def initialize
|
273
273
|
@stacks = {}
|
274
|
+
@events = {}
|
275
|
+
@event_fetch_counter = 0;
|
274
276
|
end
|
275
277
|
|
276
278
|
def create_stack(name, template, opts)
|
@@ -297,4 +299,36 @@ class CFStub
|
|
297
299
|
def stack_config(name)
|
298
300
|
@stacks[name][:opts]
|
299
301
|
end
|
302
|
+
|
303
|
+
def set_events(name, *messages)
|
304
|
+
events_seq = []
|
305
|
+
messages.each do |messages_for_call_seq|
|
306
|
+
if old_events = events_seq.last
|
307
|
+
events_seq << generate_event_from_messages(name, messages_for_call_seq) + old_events
|
308
|
+
else
|
309
|
+
events_seq << generate_event_from_messages(name, messages_for_call_seq)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
@events[name] = events_seq
|
313
|
+
end
|
314
|
+
|
315
|
+
def fetch_events(name, opts={})
|
316
|
+
@event_fetch_counter += 1
|
317
|
+
if es = @events[name]
|
318
|
+
return es[@event_fetch_counter - 1], nil
|
319
|
+
else
|
320
|
+
return generate_event_from_messages(name, ["UPDATE_COMPLETE"]), nil
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
private
|
325
|
+
|
326
|
+
def generate_event_from_messages(stack, messages)
|
327
|
+
messages.map do |message|
|
328
|
+
event = OpenStruct.new(timestamp: Time.now,
|
329
|
+
resource_type: 'AWS::CloudFormation::Stack',
|
330
|
+
logical_resource_id: stack,
|
331
|
+
resource_status: message)
|
332
|
+
end.reverse
|
333
|
+
end
|
300
334
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CfEventPollerTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@cf = CFStub.new
|
6
|
+
@poller = EbDeployer::EventPoller.new(EbDeployer::CfEventSource.new("mystack", @cf))
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_run_handle_block_through_all_events_when_there_is_no_from_anchor
|
10
|
+
messages_handled = []
|
11
|
+
@cf.set_events('mystack', ['a', 'b', nil])
|
12
|
+
@poller.poll(nil) do |event|
|
13
|
+
break if event.resource_status.nil?
|
14
|
+
messages_handled << event.resource_status
|
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
|
+
@cf.set_events('mystack', ['a', 'b'], ['c', 'd', nil])
|
23
|
+
anchor = @poller.get_anchor
|
24
|
+
messages_handled = []
|
25
|
+
@poller.poll(anchor) do |event|
|
26
|
+
break if event.resource_status.nil?
|
27
|
+
messages_handled << event.resource_status
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal ['c', 'd'], messages_handled
|
31
|
+
end
|
32
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class EbEventPollerTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
@eb = EBStub.new
|
6
|
-
@poller = EbDeployer::EventPoller.new("myapp", "test", @eb)
|
6
|
+
@poller = EbDeployer::EventPoller.new(EbDeployer::EbEventSource.new("myapp", "test", @eb))
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_run_handle_block_through_all_events_when_there_is_no_from_anchor
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eb_deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
4
|
+
version: 0.6.0.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wpc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/eb_deployer/aws_driver/beanstalk.rb
|
60
60
|
- lib/eb_deployer/aws_driver/cloud_formation_driver.rb
|
61
61
|
- lib/eb_deployer/aws_driver/s3_driver.rb
|
62
|
+
- lib/eb_deployer/cf_event_source.rb
|
62
63
|
- lib/eb_deployer/cloud_formation_provisioner.rb
|
63
64
|
- lib/eb_deployer/component.rb
|
64
65
|
- lib/eb_deployer/config_loader.rb
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/eb_deployer/deployment_strategy/blue_only.rb
|
71
72
|
- lib/eb_deployer/deployment_strategy/inplace_update.rb
|
72
73
|
- lib/eb_deployer/eb_environment.rb
|
74
|
+
- lib/eb_deployer/eb_event_source.rb
|
73
75
|
- lib/eb_deployer/environment.rb
|
74
76
|
- lib/eb_deployer/event_poller.rb
|
75
77
|
- lib/eb_deployer/package.rb
|
@@ -88,11 +90,12 @@ files:
|
|
88
90
|
- test/aws_driver_stubs.rb
|
89
91
|
- test/blue_green_deploy_test.rb
|
90
92
|
- test/blue_only_deploy_test.rb
|
93
|
+
- test/cf_event_poller_test.rb
|
91
94
|
- test/cloud_formation_provisioner_test.rb
|
92
95
|
- test/config_loader_test.rb
|
93
96
|
- test/deploy_test.rb
|
94
97
|
- test/eb_environment_test.rb
|
95
|
-
- test/
|
98
|
+
- test/eb_event_poller_test.rb
|
96
99
|
- test/inplace_update_deploy_test.rb
|
97
100
|
- test/multi_components_deploy_test.rb
|
98
101
|
- test/rails_generators_test.rb
|
@@ -131,11 +134,12 @@ test_files:
|
|
131
134
|
- test/aws_driver_stubs.rb
|
132
135
|
- test/blue_green_deploy_test.rb
|
133
136
|
- test/blue_only_deploy_test.rb
|
137
|
+
- test/cf_event_poller_test.rb
|
134
138
|
- test/cloud_formation_provisioner_test.rb
|
135
139
|
- test/config_loader_test.rb
|
136
140
|
- test/deploy_test.rb
|
137
141
|
- test/eb_environment_test.rb
|
138
|
-
- test/
|
142
|
+
- test/eb_event_poller_test.rb
|
139
143
|
- test/inplace_update_deploy_test.rb
|
140
144
|
- test/multi_components_deploy_test.rb
|
141
145
|
- test/rails_generators_test.rb
|