engineyard-serverside 1.4.9.nodestack → 1.4.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/lib/engineyard-serverside.rb +1 -3
  2. data/lib/engineyard-serverside/cli.rb +4 -5
  3. data/lib/engineyard-serverside/configuration.rb +1 -1
  4. data/lib/engineyard-serverside/deploy.rb +19 -131
  5. data/lib/engineyard-serverside/lockfile_parser.rb +5 -3
  6. data/lib/engineyard-serverside/logged_output.rb +0 -5
  7. data/lib/engineyard-serverside/task.rb +0 -1
  8. data/lib/engineyard-serverside/version.rb +1 -1
  9. data/spec/custom_deploy_spec.rb +7 -14
  10. data/spec/git_strategy_spec.rb +2 -4
  11. data/spec/real_deploy_spec.rb +103 -67
  12. data/spec/spec_helper.rb +1 -62
  13. metadata +23 -67
  14. data/lib/core-ext/README.md +0 -3
  15. data/lib/core-ext/string.rb +0 -9
  16. data/lib/vendor/ruby_1.8.6_openssl.patch +0 -7
  17. data/spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile +0 -5
  18. data/spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile.lock +0 -29
  19. data/spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile +0 -5
  20. data/spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile.lock +0 -29
  21. data/spec/fixtures/gemfiles/activerecord_mysql/Gemfile +0 -5
  22. data/spec/fixtures/gemfiles/activerecord_mysql/Gemfile.lock +0 -25
  23. data/spec/fixtures/gemfiles/activerecord_mysql2/Gemfile +0 -5
  24. data/spec/fixtures/gemfiles/activerecord_mysql2/Gemfile.lock +0 -25
  25. data/spec/fixtures/gemfiles/activerecord_pg/Gemfile +0 -5
  26. data/spec/fixtures/gemfiles/activerecord_pg/Gemfile.lock +0 -25
  27. data/spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile +0 -5
  28. data/spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile.lock +0 -25
  29. data/spec/fixtures/gemfiles/diy_database_yml/Gemfile +0 -5
  30. data/spec/fixtures/gemfiles/diy_database_yml/Gemfile.lock +0 -25
  31. data/spec/fixtures/gemfiles/diy_database_yml/config/database.yml +0 -7
  32. data/spec/fixtures/gitrepo/foo +0 -0
  33. data/spec/generate_configs_spec.rb +0 -228
  34. data/spec/lib/full_test_deploy.rb +0 -86
@@ -4,8 +4,6 @@ $LOAD_PATH.unshift File.expand_path('vendor/escape/lib', File.dirname(__FILE__))
4
4
  $LOAD_PATH.unshift File.expand_path('vendor/json_pure/lib', File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift File.expand_path('vendor/dataflow', File.dirname(__FILE__))
6
6
 
7
- require 'core-ext/string' if RUBY_VERSION == '1.8.6'
8
-
9
7
  require 'escape'
10
8
  require 'json'
11
9
  require 'dataflow'
@@ -36,7 +34,7 @@ module EY
36
34
  {}.to_json
37
35
  end
38
36
  end
39
-
37
+
40
38
  RemoteFailure = Class.new StandardError
41
39
 
42
40
  private
@@ -1,6 +1,5 @@
1
1
  require 'thor'
2
2
  require 'pathname'
3
- require 'tmpdir'
4
3
 
5
4
  module EY
6
5
  module Serverside
@@ -215,11 +214,11 @@ module EY
215
214
  def propagate
216
215
  config = EY::Serverside::Deploy::Configuration.new
217
216
  gem_filename = "engineyard-serverside-#{EY::Serverside::VERSION}.gem"
218
- local_gem_file = File.join(::Gem.dir, 'cache', gem_filename)
217
+ local_gem_file = File.join(Gem.dir, 'cache', gem_filename)
219
218
  remote_gem_file = File.join(Dir.tmpdir, gem_filename)
220
- gem_binary = File.join(::Gem.default_bindir, 'gem')
219
+ gem_binary = File.join(Gem.default_bindir, 'gem')
221
220
 
222
- EY::Serverside::Server.all.find_all do |server|
221
+ barrier(*(EY::Serverside::Server.all.find_all do |server|
223
222
  !server.local? # of course this machine has it
224
223
  end.map do |server|
225
224
  need_later do
@@ -240,7 +239,7 @@ module EY
240
239
  server.run("sudo #{gem_binary} install --no-rdoc --no-ri '#{remote_gem_file}'")
241
240
  end
242
241
  end
243
- end
242
+ end))
244
243
  end
245
244
 
246
245
  private
@@ -119,7 +119,7 @@ module EY
119
119
  end
120
120
 
121
121
  def framework_envs
122
- "RAILS_ENV=#{environment} RACK_ENV=#{environment} NODE_ENV=#{environment} MERB_ENV=#{environment}"
122
+ "RAILS_ENV=#{environment} RACK_ENV=#{environment} MERB_ENV=#{environment}"
123
123
  end
124
124
 
125
125
  def current_path
@@ -27,7 +27,6 @@ module EY
27
27
  create_revision_file
28
28
  run_with_callbacks(:bundle)
29
29
  symlink_configs
30
- generate_configs
31
30
  conditionally_enable_maintenance_page
32
31
  run_with_callbacks(:migrate)
33
32
  callback(:before_symlink)
@@ -137,12 +136,11 @@ module EY
137
136
  bundler_installer = if File.exist?(lockfile)
138
137
  get_bundler_installer(lockfile)
139
138
  else
140
- missing_lock_version = EY::Serverside::LockfileParser::Parse10::DEFAULT
141
- warn_about_missing_lockfile missing_lock_version
142
- bundler_10_installer missing_lock_version
139
+ warn_about_missing_lockfile
140
+ bundler_09_installer(default_09_bundler)
143
141
  end
144
142
 
145
- sudo "#{$0} _#{EY::Serverside::VERSION}_ install_bundler #{bundler_installer.version}"
143
+ sudo "#{serverside_bin} install_bundler #{bundler_installer.version}"
146
144
 
147
145
  bundled_gems_path = File.join(c.shared_path, "bundled_gems")
148
146
  ruby_version_file = File.join(bundled_gems_path, "RUBY_VERSION")
@@ -166,15 +164,6 @@ module EY
166
164
 
167
165
  run "mkdir -p #{bundled_gems_path} && ruby -v > #{ruby_version_file} && uname -m > #{system_version_file}"
168
166
  end
169
-
170
- if File.exist?("#{c.release_path}/package.json")
171
- unless run("which npm")
172
- error "~> package.json detected, BUT npm not installed"
173
- else
174
- info "~> package.json detected, installing npm packages"
175
- run "cd #{c.release_path} && npm install"
176
- end
177
- end
178
167
  end
179
168
 
180
169
  # task
@@ -229,7 +218,6 @@ module EY
229
218
  run create_revision_file_command
230
219
  end
231
220
 
232
- # symlink to shared path; may be overridden by #generate_configs
233
221
  def symlink_configs(release_to_link=c.release_path)
234
222
  info "~> Symlinking configs"
235
223
  [ "chmod -R g+w #{release_to_link}",
@@ -240,8 +228,8 @@ module EY
240
228
  "mkdir -p #{release_to_link}/config",
241
229
  "ln -nfs #{c.shared_path}/system #{release_to_link}/public/system",
242
230
  "ln -nfs #{c.shared_path}/pids #{release_to_link}/tmp/pids",
243
- "find #{c.shared_path}/config ! -name 'database.yml*' -type f -exec ln -s {} #{release_to_link}/config \\;",
244
- # database.yml generated or symlink created in #generate_database_yml
231
+ "find #{c.shared_path}/config -type f -exec ln -s {} #{release_to_link}/config \\;",
232
+ "ln -nfs #{c.shared_path}/config/database.yml #{release_to_link}/config/database.yml",
245
233
  "ln -nfs #{c.shared_path}/config/mongrel_cluster.yml #{release_to_link}/config/mongrel_cluster.yml",
246
234
  ].each do |cmd|
247
235
  run cmd
@@ -251,84 +239,6 @@ module EY
251
239
  run "if [ -f \"#{c.shared_path}/config/newrelic.yml\" ]; then ln -nfs #{c.shared_path}/config/newrelic.yml #{release_to_link}/config/newrelic.yml; fi"
252
240
  end
253
241
 
254
- def generate_configs(release_to_link=c.release_path)
255
- generate_database_yml(release_to_link)
256
- end
257
-
258
- # Do nothing if there is no Gemfile.lock to determine what ORM gems are being used
259
- # (falls back to using the symlinked shared/database.yml file)
260
- def generate_database_yml(release_to_link)
261
- return if keep_database_yml?(release_to_link)
262
- if config["db_adapter"] || File.exist?("#{c.release_path}/Gemfile.lock")
263
- info "~> Generating database.yml from Gemfile.lock"
264
- database_yml = "#{release_to_link}/config/database.yml"
265
- node = EY::Serverside.node
266
- node_app = node["engineyard"]["environment"]["apps"].find { |app| app['name'] == c['app'] }
267
- abort("Invalid application name for target environment: #{c['app']}") unless node_app
268
-
269
- db_stack_name = node[:engineyard][:environment][:db_stack_name]
270
- instances = node[:engineyard][:environment][:instances]
271
- db_master = {"public_hostname" => "localhost"} # you know, just in case
272
- db_slaves = []
273
- instances.each do |i|
274
- case i['role']
275
- when 'db_master', 'solo'
276
- db_master = i
277
- when 'db_slave'
278
- db_slaves << i
279
- end
280
- end
281
- db_host = db_master["public_hostname"]
282
- db_slaves_hosts = db_slaves.map {|slave| slave["public_hostname"]}
283
-
284
- if config["db_adapter"]
285
- adapter = config["db_adapter"]
286
- elsif bundler_gems_include?("mysql2")
287
- adapter = "mysql2"
288
- elsif bundler_gems_include?("mysql")
289
- adapter = "mysql"
290
- elsif bundler_gems_include?("pg")
291
- adapter = "postgresql"
292
- elsif bundler_gems_include?("jdbc-mysql")
293
- adapter = "mysql"
294
- elsif bundler_gems_include?("jdbc-postgres")
295
- adapter = "postgresql"
296
- elsif db_stack_name && db_stack_name =~ /postgres/
297
- adapter = "postgresql"
298
- else
299
- adapter = "mysql"
300
- end
301
-
302
- File.open(database_yml, "w") do |file|
303
- contents = <<-EOS.gsub(/^\s{12}/, '')
304
- #{node[:engineyard][:environment][:framework_env]}:
305
- adapter: #{adapter}
306
- database: #{node_app[:database_name]}
307
- username: #{node[:engineyard][:environment][:ssh_username]}
308
- password: #{node[:engineyard][:environment][:ssh_password]}
309
- host: #{db_host}
310
- reconnect: true
311
- EOS
312
- db_slaves_hosts.each_with_index do |host, n|
313
- slave_name = n.zero? ? "slave" : "slave_#{n}"
314
- contents << <<-EOS.gsub(/^\s{14}/, '')
315
- #{slave_name}:
316
- adapter: #{adapter}
317
- database: #{node_app[:database_name]}
318
- username: #{node[:engineyard][:environment][:ssh_username]}
319
- password: #{node[:engineyard][:environment][:ssh_password]}
320
- host: #{host}
321
- reconnect: true
322
- EOS
323
- end
324
- file << contents
325
- end
326
- else
327
- info "~> Symlinking database.yml config"
328
- run "ln -nfs #{c.shared_path}/config/database.yml #{release_to_link}/config/database.yml"
329
- end
330
- end
331
-
332
242
  # task
333
243
  def symlink(release_to_link=c.release_path)
334
244
  info "~> Symlinking code"
@@ -357,18 +267,18 @@ module EY
357
267
  protected
358
268
 
359
269
  def base_callback_command_for(what)
360
- [$0, version_specifier, 'hook', what.to_s,
270
+ [serverside_bin, 'hook', what.to_s,
361
271
  '--app', config.app.to_s,
362
272
  '--release-path', config.release_path.to_s,
363
273
  '--framework-env', c.environment.to_s,
364
274
  ].compact
365
275
  end
366
276
 
367
- def version_specifier
368
- "_#{EY::Serverside::VERSION}_"
277
+ def serverside_bin
278
+ basedir = File.expand_path('../../..', __FILE__)
279
+ File.join(basedir, 'bin', 'engineyard-serverside')
369
280
  end
370
281
 
371
-
372
282
  def puts_deploy_failure
373
283
  if @cleanup_failed
374
284
  info "~> [Relax] Your site is running new code, but cleaning up old deploys failed"
@@ -400,7 +310,7 @@ module EY
400
310
  raise
401
311
  end
402
312
 
403
- def warn_about_missing_lockfile(missing_lock_version)
313
+ def warn_about_missing_lockfile
404
314
  info "!>"
405
315
  info "!> WARNING: Gemfile.lock is missing!"
406
316
  info "!> You can get different gems in production than what you tested with."
@@ -410,52 +320,30 @@ module EY
410
320
  info "!> Fix this by running \"git add Gemfile.lock; git commit\" and deploying again."
411
321
  info "!> If you don't have a Gemfile.lock, run \"bundle lock\" to create one."
412
322
  info "!>"
413
- info "!> This deployment will use bundler #{missing_lock_version} to run 'bundle install'."
323
+ info "!> This deployment will use bundler #{default_09_bundler} to run 'bundle install'."
414
324
  info "!>"
415
325
  end
416
326
 
417
- def keep_database_yml?(release_to_link=c.release_path)
418
- File.exists?(File.join(release_to_link, "config", "keep.database.yml"))
419
- end
420
-
421
- # returns true if "bundle list" includes all gems requested
422
- def bundler_gems_include?(*gems)
423
- lockfile = File.join(c.release_path, "Gemfile.lock")
424
- @lockfile_contents ||= File.read(lockfile)
425
-
426
- # Parsing Gemfile.lock which looks like
427
- # GEM
428
- # remote: http://rubygems.org/
429
- # specs:
430
- # activemodel (3.0.10)
431
- # activesupport (= 3.0.10)
432
- # builder (~> 2.1.2)
433
- # i18n (~> 0.5.0)
434
- #
435
- gems.inject(true) {|found_all, gem| found_all && (@lockfile_contents =~ / #{gem} \(/)}
436
- end
437
-
438
- def get_bundler_installer(lockfile, options = '')
327
+ def get_bundler_installer(lockfile)
439
328
  parser = LockfileParser.new(File.read(lockfile))
440
329
  case parser.lockfile_version
441
330
  when :bundler09
442
- bundler_09_installer(parser.bundler_version, options)
331
+ bundler_09_installer(parser.bundler_version)
443
332
  when :bundler10
444
- bundler_10_installer(parser.bundler_version, options)
333
+ bundler_10_installer(parser.bundler_version)
445
334
  else
446
335
  raise "Unknown lockfile version #{parser.lockfile_version}"
447
336
  end
448
337
  end
449
338
  public :get_bundler_installer
450
339
 
451
- def bundler_09_installer(version, options = '')
452
- default_options = '--without=development --without=test'
453
- BundleInstaller.new(version, default_options + options)
340
+ def bundler_09_installer(version)
341
+ BundleInstaller.new(version, '--without=development --without=test')
454
342
  end
455
343
 
456
- def bundler_10_installer(version, options = '')
457
- default_options = "--deployment --path #{c.shared_path}/bundled_gems --binstubs #{c.binstubs_path} --without development test"
458
- BundleInstaller.new(version, default_options + options)
344
+ def bundler_10_installer(version)
345
+ BundleInstaller.new(version,
346
+ "--deployment --path #{c.shared_path}/bundled_gems --binstubs #{c.binstubs_path} --without development test")
459
347
  end
460
348
  end # DeployBase
461
349
 
@@ -79,11 +79,13 @@ module EY
79
79
  when '='
80
80
  bundler_version
81
81
  when '>='
82
- ::Gem::Version.new(bundler_version) > ::Gem::Version.new(DEFAULT) ? bundler_version : DEFAULT
82
+ Gem::Version.new(bundler_version) > Gem::Version.new(DEFAULT) ? bundler_version : DEFAULT
83
83
  when '~>'
84
- bundler_gem_version = ::Gem::Version.new(bundler_version)
84
+ bundler_gem_version = Gem::Version.new(bundler_version)
85
85
  recommendation = bundler_gem_version.spermy_recommendation.gsub(/~>\s*(.+)$/, '\1.')
86
- DEFAULT.start_with?(recommendation) && ::Gem::Version.new(DEFAULT) > bundler_gem_version ? DEFAULT : bundler_version
86
+ recommends_default = DEFAULT.index(recommendation) == 0
87
+ default_newer_than_requested = Gem::Version.new(DEFAULT) > bundler_gem_version
88
+ (recommends_default && default_newer_than_requested) ? DEFAULT : bundler_version
87
89
  end
88
90
  end
89
91
 
@@ -41,11 +41,6 @@ module EY
41
41
  EY::Serverside::LoggedOutput.verbose?
42
42
  end
43
43
 
44
- # TODO color output
45
- def error(msg)
46
- info(msg)
47
- end
48
-
49
44
  def info(msg)
50
45
  with_logfile do |log|
51
46
  Tee.new($stdout, log) << (msg + "\n")
@@ -54,7 +54,6 @@ module EY
54
54
  need_later { server.run(Escape.shell_command(wrapper + [to_run])) }
55
55
  end
56
56
  barrier *results
57
-
58
57
  # MRI's truthiness check is an internal C thing that does not call
59
58
  # any methods... so Dataflow cannot proxy it & we must "x == true"
60
59
  # Rubinius, wherefore art thou!?
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module Serverside
3
- VERSION = '1.4.9.nodestack'
3
+ VERSION = '1.4.11'
4
4
  end
5
5
  end
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
- require 'fileutils'
3
2
 
4
3
  describe "the EY::Serverside::Deploy API" do
5
4
  it "calls tasks in the right order" do
@@ -30,12 +29,9 @@ describe "the EY::Serverside::Deploy API" do
30
29
  def cleanup_old_releases() @call_order << 'cleanup_old_releases' end
31
30
  def conditionally_enable_maintenance_page() @call_order << 'conditionally_enable_maintenance_page' end
32
31
  def disable_maintenance_page() @call_order << 'disable_maintenance_page' end
33
- def generate_database_yml(path) @call_order << 'generate_database_yml' end
34
32
  end
35
33
 
36
- setup_dna_json
37
-
38
- td = TestDeploy.new(EY::Serverside::Deploy::Configuration.new('app' => 'myfirstapp'))
34
+ td = TestDeploy.new(EY::Serverside::Deploy::Configuration.new)
39
35
  td.deploy
40
36
  td.call_order.should == %w(
41
37
  push_code
@@ -43,7 +39,6 @@ describe "the EY::Serverside::Deploy API" do
43
39
  create_revision_file
44
40
  bundle
45
41
  symlink_configs
46
- generate_database_yml
47
42
  conditionally_enable_maintenance_page
48
43
  migrate
49
44
  symlink
@@ -58,17 +53,15 @@ describe "the EY::Serverside::Deploy API" do
58
53
  end
59
54
 
60
55
  before(:each) do
61
- @tempdir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
62
- @config = EY::Serverside::Deploy::Configuration.new('repository_cache' => @tempdir)
63
- @deploy = TestQuietDeploy.new(@config)
64
- end
65
-
66
- after do
67
- FileUtils.rm_rf(@tempdir)
56
+ @tempdir = `mktemp -d -t custom_deploy_spec.XXXXX`.strip
57
+ @config = EY::Serverside::Deploy::Configuration.new('repository_cache' => @tempdir)
58
+ @deploy = TestQuietDeploy.new(@config)
68
59
  end
69
60
 
70
61
  def write_eydeploy(relative_path, contents = "def got_new_methods() 'from the file on disk' end")
71
- FileUtils.mkdir_p(File.join(@tempdir, File.dirname(relative_path)))
62
+ FileUtils.mkdir_p(File.join(
63
+ @tempdir,
64
+ File.dirname(relative_path)))
72
65
 
73
66
  File.open(File.join(@tempdir, relative_path), 'w') do |f|
74
67
  f.write contents
@@ -2,10 +2,8 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "the git deploy strategy" do
4
4
  subject do
5
- EY::Serverside::Strategies::Git.new(:repo => File.expand_path("../fixtures/gitrepo/.git", __FILE__),
6
- :repository_cache => File.expand_path("../fixtures/gitrepo", __FILE__),
7
- :ref => "master"
8
- )
5
+ EY::Serverside::Strategies::Git.new(:repo => File.join(GITREPO_DIR, 'git'),
6
+ :repository_cache => GITREPO_DIR, :ref => "master")
9
7
  end
10
8
 
11
9
  before { subject.checkout }
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
- require File.dirname(__FILE__) + '/lib/full_test_deploy'
3
2
 
4
- module EY::Serverside::Strategies::DeployIntegrationSpec
3
+ module EY::Serverside::Strategies::IntegrationSpec
5
4
  module Helpers
6
5
 
7
6
  def update_repository_cache
@@ -20,6 +19,7 @@ module EY::Serverside::Strategies::DeployIntegrationSpec
20
19
 
21
20
  FileUtils.mkdir_p(File.join(c.shared_path, 'config'))
22
21
 
22
+ FileUtils.mkdir_p(cached_copy)
23
23
  Dir.chdir(cached_copy) do
24
24
  `echo "this is my file; there are many like it, but this one is mine" > file`
25
25
  File.open('Gemfile', 'w') do |f|
@@ -46,21 +46,6 @@ DEPENDENCIES
46
46
  rake
47
47
  EOF
48
48
  end
49
-
50
- File.open('package.json', 'w') do |f|
51
- f.write <<-EOF
52
- {
53
- "name": "application-name"
54
- , "version": "0.0.1"
55
- , "private": true
56
- , "dependencies": {
57
- "express": "2.3.12"
58
- , "jade": ">= 0.0.1"
59
- }
60
- }
61
- EOF
62
- end
63
-
64
49
  end
65
50
  end
66
51
 
@@ -76,44 +61,125 @@ EOF
76
61
  end
77
62
 
78
63
  describe "deploying an application" do
64
+ class FullTestDeploy < EY::Serverside::Deploy
65
+ attr_reader :infos, :debugs, :commands
66
+
67
+ def initialize(*)
68
+ super
69
+ @infos = []
70
+ @debugs = []
71
+ @commands = []
72
+ end
73
+
74
+ # stfu
75
+ def info(msg)
76
+ @infos << msg
77
+ end
78
+
79
+ # no really, stfu
80
+ def debug(msg)
81
+ @debugs << msg
82
+ end
83
+
84
+ # passwordless sudo is neither guaranteed nor desired
85
+ def sudo(cmd)
86
+ run(cmd)
87
+ end
88
+
89
+ def run(cmd)
90
+ @commands << cmd
91
+ super
92
+ end
93
+
94
+ def version_specifier
95
+ # Normally, the deploy task invokes the hook task by executing
96
+ # the rubygems-generated wrapper (it's what's in $PATH). It
97
+ # specifies the version to make sure that the pieces don't get
98
+ # out of sync. However, in test mode, there's no
99
+ # rubygems-generated wrapper, and so the hook task doesn't get
100
+ # run because thor thinks we're trying to invoke the _$VERSION_
101
+ # task instead, which doesn't exist.
102
+ #
103
+ # By stripping that out, we can get the hooks to actually run
104
+ # inside this test.
105
+ nil
106
+ end
107
+
108
+ def restart
109
+ FileUtils.touch("#{c.release_path}/restart")
110
+ end
111
+
112
+ # we're probably running this spec under bundler, but a real
113
+ # deploy does not
114
+ def bundle
115
+ my_env = ENV.to_hash
116
+
117
+ ENV.delete("BUNDLE_GEMFILE")
118
+ ENV.delete("BUNDLE_BIN_PATH")
119
+
120
+ result = super
121
+
122
+ ENV.replace(my_env)
123
+ result
124
+ end
125
+
126
+ def get_bundler_installer(lockfile)
127
+ installer = super
128
+ installer.options << ' --quiet' # stfu already!
129
+ installer
130
+ end
131
+
132
+ end
79
133
 
80
134
  before(:all) do
81
135
  @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
82
- FileUtils.mkdir_p(@deploy_dir)
83
136
 
84
137
  # set up EY::Serverside::Server like we're on a solo
85
138
  EY::Serverside::Server.reset
86
139
  EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
87
140
 
88
- setup_dna_json
89
-
90
141
  # run a deploy
91
142
  config = EY::Serverside::Deploy::Configuration.new({
92
- "strategy" => "DeployIntegrationSpec",
143
+ "strategy" => "IntegrationSpec",
93
144
  "deploy_to" => @deploy_dir,
94
145
  "group" => `id -gn`.strip,
95
146
  "stack" => 'nginx_passenger',
96
147
  "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
97
- 'app' => 'myfirstapp',
148
+ 'app' => 'foo',
98
149
  'framework_env' => 'staging'
99
150
  })
100
151
 
101
152
  # pretend there is a shared bundled_gems directory
102
153
  FileUtils.mkdir_p(File.join(@deploy_dir, 'shared', 'bundled_gems'))
103
- %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
154
+ %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
104
155
  File.open(File.join(@deploy_dir, 'shared', 'bundled_gems', name), "w") { |f| f.write("old\n") }
105
156
  end
106
157
 
107
- @binpath = $0 = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
108
-
158
+ @binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
109
159
  @deployer = FullTestDeploy.new(config)
110
160
  @deployer.deploy
111
161
  end
112
162
 
163
+ it "runs the right bundler command" do
164
+ install_bundler_command_ran = @deployer.commands.detect{ |command| command.index("install_bundler") }
165
+ install_bundler_command_ran.should_not be_nil
166
+ install_bundler_command_ran.should == "#{@binpath} install_bundler 1.0.10"
167
+ end
168
+
113
169
  it "creates a REVISION file" do
114
170
  File.exist?(File.join(@deploy_dir, 'current', 'REVISION')).should be_true
115
171
  end
116
172
 
173
+ it "restarts the app servers" do
174
+ File.exist?(File.join(@deploy_dir, 'current', 'restart')).should be_true
175
+ end
176
+
177
+ it "runs 'bundle install' with --deployment" do
178
+ bundle_install_cmd = @deployer.commands.grep(/bundle _\S+_ install/).first
179
+ bundle_install_cmd.should_not be_nil
180
+ bundle_install_cmd.should include('--deployment')
181
+ end
182
+
117
183
  it "creates a ruby version file" do
118
184
  File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'RUBY_VERSION')).should be_true
119
185
  end
@@ -122,48 +188,22 @@ describe "deploying an application" do
122
188
  File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'SYSTEM_VERSION')).should be_true
123
189
  end
124
190
 
125
- if RUBY_VERSION != '1.8.6'
126
- it "runs the right bundler command" do
127
- install_bundler_command_ran = @deployer.commands.detect{ |command| command.index("install_bundler") }
128
- install_bundler_command_ran.should_not be_nil
129
- install_bundler_command_ran.should == "#{@binpath} _#{EY::Serverside::VERSION}_ install_bundler 1.0.10"
130
- end
131
-
132
- it "runs 'bundle install' with --deployment" do
133
- bundle_install_cmd = @deployer.commands.grep(/bundle _\S+_ install/).first
134
- bundle_install_cmd.should_not be_nil
135
- bundle_install_cmd.should include('--deployment')
136
- end
137
-
138
- it "creates binstubs somewhere out of the way" do
139
- File.exist?(File.join(@deploy_dir, 'current', 'ey_bundler_binstubs', 'rake')).should be_true
140
- end
141
-
142
- it "has the binstubs in the path when migrating" do
143
- File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
144
- end
145
-
146
- it "removes bundled_gems directory if the ruby version changed" do
147
- clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
148
- clear_bundle_cmd.should_not be_nil
149
- end
150
-
151
- it "removes bundled_gems directory if the system version changed" do
152
- clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
153
- clear_bundle_cmd.should_not be_nil
154
- end
191
+ it "removes bundled_gems directory if the ruby version changed" do
192
+ clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
193
+ clear_bundle_cmd.should_not be_nil
194
+ end
155
195
 
156
- it "creates binstubs somewhere out of the way" do
157
- File.exist?(File.join(@deploy_dir, 'current', 'ey_bundler_binstubs', 'rake')).should be_true
158
- end
196
+ it "removes bundled_gems directory if the system version changed" do
197
+ clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
198
+ clear_bundle_cmd.should_not be_nil
159
199
  end
160
200
 
161
- it "runs 'npm install'" do
162
- bundle_install_cmd = @deployer.commands.grep(/npm install/).first
163
- bundle_install_cmd.should_not be_nil
201
+ it "creates binstubs somewhere out of the way" do
202
+ File.exist?(File.join(@deploy_dir, 'current', 'ey_bundler_binstubs', 'rake')).should be_true
164
203
  end
165
- it "generates a database.yml file" do
166
- File.exist?(File.join(@deploy_dir, 'current', 'config', 'database.yml')).should be_true
204
+
205
+ it "has the binstubs in the path when migrating" do
206
+ File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
167
207
  end
168
208
 
169
209
  it "runs all the hooks" do
@@ -176,8 +216,4 @@ describe "deploying an application" do
176
216
  File.exist?(File.join(@deploy_dir, 'current', 'before_restart.ran')).should be_true
177
217
  File.exist?(File.join(@deploy_dir, 'current', 'after_restart.ran' )).should be_true
178
218
  end
179
-
180
- it "restarts the app servers" do
181
- File.exist?(File.join(@deploy_dir, 'current', 'restart')).should be_true
182
- end
183
219
  end