eb_deployer 0.4.4.beta5 → 0.4.4.beta6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/eb_deployer.rb CHANGED
@@ -191,11 +191,11 @@ module EbDeployer
191
191
  env.settings = opts[:option_settings] || opts[:settings] || []
192
192
  env.inactive_settings = opts[:inactive_settings] || []
193
193
  env.creation_opts = {
194
- :solution_stack => opts[:solution_stack_name] || "64bit Amazon Linux 2013.09 running Tomcat 7 Java 7",
194
+ :solution_stack => opts[:solution_stack_name],
195
195
  :cname_prefix => opts[:cname_prefix],
196
- :smoke_test => opts[:smoke_test] || Proc.new {},
196
+ :smoke_test => opts[:smoke_test],
197
197
  :phoenix_mode => opts[:phoenix_mode],
198
- :tier => opts[:tier] || 'WebServer'
198
+ :tier => opts[:tier]
199
199
  }
200
200
  env.strategy_name = opts[:strategy] || :blue_green
201
201
  env.components = opts[:components]
@@ -1,5 +1,7 @@
1
1
  module EbDeployer
2
2
  class EbEnvironment
3
+ include Utils
4
+
3
5
  attr_reader :app, :name
4
6
  attr_writer :event_poller
5
7
 
@@ -13,7 +15,7 @@ module EbDeployer
13
15
  @app = app
14
16
  @name = self.class.unique_ebenv_name(name, app)
15
17
  @bs = eb_driver
16
- @creation_opts = creation_opts
18
+ @creation_opts = default_create_options.merge(reject_nil(creation_opts))
17
19
  end
18
20
 
19
21
  def deploy(version_label, settings={})
@@ -61,8 +63,10 @@ module EbDeployer
61
63
  private
62
64
 
63
65
  def create_eb_env(settings, version_label)
66
+ solution_stack = @creation_opts[:solution_stack]
67
+ validate_solutions_stack(solution_stack)
64
68
  with_polling_events(/Successfully launched environment/i) do
65
- @bs.create_environment(@app, @name, @creation_opts[:solution_stack], @creation_opts[:cname_prefix], version_label, @creation_opts[:tier], settings)
69
+ @bs.create_environment(@app, @name, solution_stack, @creation_opts[:cname_prefix], version_label, @creation_opts[:tier], settings)
66
70
  end
67
71
  end
68
72
 
@@ -72,6 +76,11 @@ module EbDeployer
72
76
  end
73
77
  end
74
78
 
79
+ def validate_solutions_stack(stack_name)
80
+ names = @bs.list_solution_stack_names
81
+ raise "'#{stack_name}' is not a valid solution stack name, available solution stack names are: #{names.join(', ')}" unless names.include?(stack_name)
82
+ end
83
+
75
84
  def smoke_test
76
85
  host_name = @bs.environment_cname(@app, @name)
77
86
  SmokeTest.new(@creation_opts[:smoke_test]).run(host_name, self)
@@ -112,6 +121,13 @@ module EbDeployer
112
121
  @event_poller || EventPoller.new(@app, @name, @bs)
113
122
  end
114
123
 
124
+ def default_create_options
125
+ {
126
+ :solution_stack => "64bit Amazon Linux 2013.09 running Tomcat 7 Java 7",
127
+ :smoke_test => Proc.new {},
128
+ :tier => 'WebServer'
129
+ }
130
+ end
115
131
 
116
132
  def log_event(event)
117
133
  puts "[#{event[:event_date]}][environment:#{@name}] #{event[:message]}"
@@ -24,5 +24,10 @@ module EbDeployer
24
24
  def symbolize_keys(hash)
25
25
  hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
26
26
  end
27
+
28
+
29
+ def reject_nil(hash)
30
+ hash.reject{| k, v| v.nil?}
31
+ end
27
32
  end
28
33
  end
@@ -1,3 +1,3 @@
1
1
  module EbDeployer
2
- VERSION = "0.4.4.beta5"
2
+ VERSION = "0.4.4.beta6"
3
3
  end
@@ -127,11 +127,19 @@ class EBStub
127
127
  @envs[env_key(app_name, env_name)][:version]
128
128
  end
129
129
 
130
+ def list_solution_stack_names
131
+ @solution_stacks || ["64bit Amazon Linux 2013.09 running Tomcat 7 Java 7"]
132
+ end
133
+
130
134
  #test only
131
135
  def mark_all_envs_ready
132
136
  @envs.values.each { |env| set_env_ready(env[:application], env[:name], true) }
133
137
  end
134
138
 
139
+ def set_solution_stacks(names)
140
+ @solution_stacks = names
141
+ end
142
+
135
143
  def environment_tier(app_name, env_name)
136
144
  @envs[env_key(app_name, env_name)][:tier]
137
145
  end
@@ -51,11 +51,20 @@ class EbEnvironmentTest < MiniTest::Unit::TestCase
51
51
  assert_raises(RuntimeError) { env.deploy("version 1") }
52
52
  end
53
53
 
54
-
55
54
  def test_terminate_should_delete_environment
56
55
  env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver)
57
56
  env.deploy("version1")
58
57
  env.terminate
59
58
  assert !@eb_driver.environment_exists?('myapp', t('production', 'myapp'))
60
59
  end
60
+
61
+ def test_should_raise_runtime_error_when_solution_stack_is_not_valid
62
+ env = EbDeployer::EbEnvironment.new("myapp", "production", @eb_driver, {
63
+ :solution_stack => "python"
64
+ })
65
+ @eb_driver.set_solution_stacks(["java", "ruby"])
66
+ assert_raises(RuntimeError) { env.deploy("version 1") }
67
+ end
68
+
69
+
61
70
  end
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.4.4.beta5
4
+ version: 0.4.4.beta6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: