engineyard-serverside 2.0.0.pre3 → 2.0.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside/cli.rb +46 -153
- data/lib/engineyard-serverside/cli_helpers.rb +53 -0
- data/lib/engineyard-serverside/configuration.rb +131 -161
- data/lib/engineyard-serverside/deploy.rb +69 -37
- data/lib/engineyard-serverside/deploy_hook.rb +31 -6
- data/lib/engineyard-serverside/paths.rb +106 -0
- data/lib/engineyard-serverside/server.rb +7 -59
- data/lib/engineyard-serverside/servers.rb +93 -0
- data/lib/engineyard-serverside/task.rb +4 -3
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/basic_deploy_spec.rb +2 -2
- data/spec/bundler_deploy_spec.rb +6 -6
- data/spec/configuration_spec.rb +2 -1
- data/spec/custom_deploy_spec.rb +9 -4
- data/spec/deploy_hook_spec.rb +31 -15
- data/spec/ey_yml_customized_deploy_spec.rb +17 -15
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
- data/spec/rails31_deploy_spec.rb +8 -8
- data/spec/restart_spec.rb +3 -2
- data/spec/rollback_spec.rb +61 -0
- data/spec/server_spec.rb +44 -50
- data/spec/spec_helper.rb +19 -12
- metadata +17 -4
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Rolling back" do
|
4
|
+
context "without bundler" do
|
5
|
+
before(:all) do
|
6
|
+
deploy_test_application('not_bundled', 'migrate' => nil)
|
7
|
+
@good_revision = deploy_dir.join('current', 'REVISION').read.strip
|
8
|
+
deploy_dir.join('current', 'REVISION').should exist
|
9
|
+
deploy_dir.join('current', 'restart').delete
|
10
|
+
deploy_test_application('not_bundled', 'migrate' => nil)
|
11
|
+
deploy_dir.join('current', 'REVISION').should exist
|
12
|
+
deploy_dir.join('current', 'restart').delete
|
13
|
+
end
|
14
|
+
|
15
|
+
it "rolls back to the older deploy" do
|
16
|
+
releases = @deployer.config.paths.all_releases
|
17
|
+
releases.size.should == 2
|
18
|
+
good_release = releases.first
|
19
|
+
bad_release = releases.last
|
20
|
+
|
21
|
+
@deployer.rollback
|
22
|
+
out = read_output
|
23
|
+
out.should =~ /Rolling back to previous release.*#{@good_revision}/
|
24
|
+
out.should =~ /Restarting with previous release./
|
25
|
+
out.should =~ /Finished rollback/
|
26
|
+
|
27
|
+
deploy_dir.join('current', 'restart').should exist
|
28
|
+
bad_release.should_not exist
|
29
|
+
good_release.join('restart').should exist
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with complex config" do
|
34
|
+
before(:all) do
|
35
|
+
deploy_test_application('ey_yml', 'migrate' => nil)
|
36
|
+
@good_revision = deploy_dir.join('current', 'REVISION').read.strip
|
37
|
+
deploy_dir.join('current', 'REVISION').should exist
|
38
|
+
deploy_dir.join('current', 'restart').delete
|
39
|
+
deploy_test_application('ey_yml', 'migrate' => nil)
|
40
|
+
deploy_dir.join('current', 'REVISION').should exist
|
41
|
+
deploy_dir.join('current', 'restart').delete
|
42
|
+
end
|
43
|
+
|
44
|
+
it "rolls back to the older deploy" do
|
45
|
+
releases = @deployer.config.paths.all_releases
|
46
|
+
releases.size.should == 2
|
47
|
+
good_release = releases.first
|
48
|
+
bad_release = releases.last
|
49
|
+
|
50
|
+
@deployer.rollback
|
51
|
+
out = read_output
|
52
|
+
out.should =~ /Rolling back to previous release.*#{@good_revision}/
|
53
|
+
out.should =~ /Restarting with previous release./
|
54
|
+
out.should =~ /Finished rollback/
|
55
|
+
|
56
|
+
deploy_dir.join('current', 'restart').should exist
|
57
|
+
bad_release.should_not exist
|
58
|
+
good_release.join('restart').should exist
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/server_spec.rb
CHANGED
@@ -1,76 +1,70 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe EY::Serverside::Server do
|
4
|
-
|
5
|
-
EY::Serverside::
|
4
|
+
it "starts off empty" do
|
5
|
+
EY::Serverside::Servers.new([]).should be_empty
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
it "is added to with .add" do
|
14
|
-
EY::Serverside::Server.add(:hostname => 'otherhost', :roles => %w[fire water])
|
15
|
-
EY::Serverside::Server.all.size.should == 1
|
16
|
-
|
17
|
-
EY::Serverside::Server.by_hostname('otherhost').should_not be_nil
|
18
|
-
end
|
8
|
+
it "loads from hashes" do
|
9
|
+
servers = EY::Serverside::Servers.from_hashes([{:hostname => 'otherhost', :roles => %w[fire water]}])
|
10
|
+
servers.size.should == 1
|
11
|
+
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
it "rejects duplicates" do
|
14
|
+
lambda do
|
15
|
+
EY::Serverside::Servers.from_hashes([
|
16
|
+
{:hostname => 'otherhost', :roles => [:fire]},
|
17
|
+
{:hostname => 'otherhost', :roles => [:water]},
|
18
|
+
])
|
19
|
+
end.should raise_error(EY::Serverside::Servers::DuplicateHostname)
|
26
20
|
end
|
27
21
|
|
28
22
|
it "makes sure your roles are symbols at creation time" do
|
29
|
-
EY::Serverside::
|
30
|
-
|
31
|
-
EY::Serverside::Server.by_hostname('otherhost').roles.should == [:beerguy]
|
23
|
+
servers = EY::Serverside::Servers.from_hashes([{:hostname => 'otherhost', :roles => %w[fire water]}])
|
24
|
+
servers.each { |server| server.roles.should == Set[:fire, :water] }
|
32
25
|
end
|
33
26
|
|
34
|
-
|
35
|
-
|
27
|
+
context "filtering" do
|
28
|
+
before(:each) do
|
29
|
+
@servers = EY::Serverside::Servers.from_hashes([
|
30
|
+
{:hostname => 'localhost', :roles => [:ice, :cold]},
|
31
|
+
{:hostname => 'firewater', :roles => [:fire, :water]},
|
32
|
+
{:hostname => 'icewater', :roles => [:ice, :water]},
|
33
|
+
])
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
it "#roles works with strings or symbols" do
|
37
|
+
@servers.roles(:fire ).map{|s| s.hostname}.should == ['firewater']
|
38
|
+
@servers.roles('fire').map{|s| s.hostname}.should == ['firewater'] # hits the cache the second time
|
39
|
+
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
@
|
45
|
-
@host1 = EY::Serverside::Server.add(:hostname => 'host1', :roles => [:fire, :water])
|
46
|
-
@host2 = EY::Serverside::Server.add(:hostname => 'host2', :roles => [:ice, :water])
|
41
|
+
it "#roles finds all servers with the specified role" do
|
42
|
+
@servers.roles(:ice).size.should == 2
|
43
|
+
@servers.roles(:ice).map{|s| s.hostname}.sort.should == ['icewater','localhost']
|
47
44
|
end
|
48
45
|
|
49
|
-
it "
|
50
|
-
|
51
|
-
EY::Serverside::Server.from_roles('fire').should == [@host1]
|
46
|
+
it "#roles finds all servers with any of the specified roles" do
|
47
|
+
@servers.roles(:ice, :water).should == @servers
|
52
48
|
end
|
53
49
|
|
54
|
-
it "
|
55
|
-
|
56
|
-
EY::Serverside::Server.from_roles('ice').sort do |a, b|
|
57
|
-
a.hostname <=> b.hostname
|
58
|
-
end.should == [@host2, @localhost]
|
50
|
+
it "#roles returns everything when asked for :all" do
|
51
|
+
@servers.roles(:all).should == @servers
|
59
52
|
end
|
60
53
|
|
61
|
-
it "
|
62
|
-
|
54
|
+
it "#roles also yields filtered server set" do
|
55
|
+
@servers.roles(:ice) do |servers|
|
56
|
+
servers.size.should == 2
|
57
|
+
servers.map{|s| s.hostname}.sort.should == ['icewater','localhost']
|
58
|
+
end
|
63
59
|
end
|
64
60
|
|
65
|
-
it "returns
|
66
|
-
|
61
|
+
it "#localhost returns the localhost server" do
|
62
|
+
@servers.localhost.hostname.should == 'localhost'
|
67
63
|
end
|
68
|
-
end
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
EY::Serverside::Server.new('neighborhost').should_not be_local
|
65
|
+
it "#remote returns non-localhost servers" do
|
66
|
+
@servers.remote.size.should == 2
|
67
|
+
@servers.remote.map {|s| s.hostname}.sort.should == ['firewater','icewater']
|
74
68
|
end
|
75
69
|
end
|
76
70
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -83,30 +83,37 @@ Spec::Runner.configure do |config|
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_shell
|
86
|
-
|
87
|
-
|
86
|
+
@test_shell ||= begin
|
87
|
+
log_path = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}.log")
|
88
|
+
EY::Serverside::Shell.new(:verbose => true, :log_path => log_path, :stdout => stdout, :stderr => stderr)
|
89
|
+
end
|
88
90
|
end
|
89
91
|
|
90
92
|
def exist
|
91
93
|
be_exist
|
92
94
|
end
|
93
95
|
|
96
|
+
def deploy_dir
|
97
|
+
@deploy_dir ||= Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}")
|
98
|
+
end
|
99
|
+
|
100
|
+
# set up EY::Serverside::Server like we're on a solo
|
101
|
+
def test_servers
|
102
|
+
EY::Serverside::Servers.from_hashes([{:hostname => 'localhost', :roles => %w[solo]}])
|
103
|
+
end
|
104
|
+
|
94
105
|
# When a repo fixture name is specified, the files found in the specified
|
95
106
|
# spec/fixtures/repos dir are copied into the test github repository.
|
96
107
|
def deploy_test_application(repo_fixture_name = 'default', extra_config = {}, &block)
|
97
|
-
|
98
|
-
|
99
|
-
# set up EY::Serverside::Server like we're on a solo
|
100
|
-
EY::Serverside::Server.reset
|
101
|
-
EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
|
108
|
+
servers = test_servers
|
102
109
|
|
103
110
|
# run a deploy
|
104
111
|
@config = EY::Serverside::Deploy::Configuration.new({
|
105
112
|
"strategy" => "IntegrationSpec",
|
106
|
-
"deploy_to" =>
|
113
|
+
"deploy_to" => deploy_dir.to_s,
|
107
114
|
"group" => GROUP,
|
108
115
|
"stack" => 'nginx_passenger',
|
109
|
-
"migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{
|
116
|
+
"migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{deploy_dir}/path-when-migrating",
|
110
117
|
'app' => 'rails31',
|
111
118
|
'environment_name' => 'env',
|
112
119
|
'account_name' => 'acc',
|
@@ -116,13 +123,13 @@ Spec::Runner.configure do |config|
|
|
116
123
|
}.merge(extra_config))
|
117
124
|
|
118
125
|
# pretend there is a shared bundled_gems directory
|
119
|
-
|
126
|
+
deploy_dir.join('shared', 'bundled_gems').mkpath
|
120
127
|
%w(RUBY_VERSION SYSTEM_VERSION).each do |name|
|
121
|
-
|
128
|
+
deploy_dir.join('shared', 'bundled_gems', name).open("w") { |f| f.write("old\n") }
|
122
129
|
end
|
123
130
|
|
124
131
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
125
|
-
@deployer = FullTestDeploy.new(@config, test_shell)
|
132
|
+
@deployer = FullTestDeploy.new(servers, @config, test_shell)
|
126
133
|
yield @deployer if block_given?
|
127
134
|
@deployer.deploy
|
128
135
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-serverside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 883885311
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 2.0.0.
|
11
|
+
- 4
|
12
|
+
version: 2.0.0.pre4
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- EY Cloud Team
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-06-
|
20
|
+
date: 2012-06-13 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rspec
|
@@ -105,6 +105,7 @@ extra_rdoc_files: []
|
|
105
105
|
files:
|
106
106
|
- bin/engineyard-serverside
|
107
107
|
- lib/engineyard-serverside/cli.rb
|
108
|
+
- lib/engineyard-serverside/cli_helpers.rb
|
108
109
|
- lib/engineyard-serverside/configuration.rb
|
109
110
|
- lib/engineyard-serverside/default_maintenance_page.html
|
110
111
|
- lib/engineyard-serverside/deploy.rb
|
@@ -114,8 +115,10 @@ files:
|
|
114
115
|
- lib/engineyard-serverside/futures/celluloid.rb
|
115
116
|
- lib/engineyard-serverside/futures/dataflow.rb
|
116
117
|
- lib/engineyard-serverside/lockfile_parser.rb
|
118
|
+
- lib/engineyard-serverside/paths.rb
|
117
119
|
- lib/engineyard-serverside/rails_asset_support.rb
|
118
120
|
- lib/engineyard-serverside/server.rb
|
121
|
+
- lib/engineyard-serverside/servers.rb
|
119
122
|
- lib/engineyard-serverside/shell/formatter.rb
|
120
123
|
- lib/engineyard-serverside/shell/helpers.rb
|
121
124
|
- lib/engineyard-serverside/shell.rb
|
@@ -364,17 +367,20 @@ files:
|
|
364
367
|
- spec/fixtures/lockfiles/1.0.6-with-any-bundler
|
365
368
|
- spec/fixtures/lockfiles/1.0.6-with-bundler
|
366
369
|
- spec/fixtures/lockfiles/not-a-lockfile
|
370
|
+
- spec/fixtures/repos/assets_disabled/app/assets/empty
|
367
371
|
- spec/fixtures/repos/assets_disabled/config/application.rb
|
368
372
|
- spec/fixtures/repos/assets_disabled/Gemfile
|
369
373
|
- spec/fixtures/repos/assets_disabled/Gemfile.lock
|
370
374
|
- spec/fixtures/repos/assets_disabled/Rakefile
|
371
375
|
- spec/fixtures/repos/assets_disabled/README
|
376
|
+
- spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty
|
372
377
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb
|
373
378
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml
|
374
379
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile
|
375
380
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock
|
376
381
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile
|
377
382
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/README
|
383
|
+
- spec/fixtures/repos/assets_enabled/app/assets/empty
|
378
384
|
- spec/fixtures/repos/assets_enabled/config/application.rb
|
379
385
|
- spec/fixtures/repos/assets_enabled/Gemfile
|
380
386
|
- spec/fixtures/repos/assets_enabled/Gemfile.lock
|
@@ -385,6 +391,7 @@ files:
|
|
385
391
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock
|
386
392
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile
|
387
393
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/README
|
394
|
+
- spec/fixtures/repos/assets_in_hook/app/assets/empty
|
388
395
|
- spec/fixtures/repos/assets_in_hook/config/application.rb
|
389
396
|
- spec/fixtures/repos/assets_in_hook/deploy/before_migrate.rb
|
390
397
|
- spec/fixtures/repos/assets_in_hook/Gemfile
|
@@ -434,6 +441,7 @@ files:
|
|
434
441
|
- spec/nodejs_deploy_spec.rb
|
435
442
|
- spec/rails31_deploy_spec.rb
|
436
443
|
- spec/restart_spec.rb
|
444
|
+
- spec/rollback_spec.rb
|
437
445
|
- spec/server_spec.rb
|
438
446
|
- spec/services_deploy_spec.rb
|
439
447
|
- spec/shell_spec.rb
|
@@ -500,17 +508,20 @@ test_files:
|
|
500
508
|
- spec/fixtures/lockfiles/1.0.6-with-any-bundler
|
501
509
|
- spec/fixtures/lockfiles/1.0.6-with-bundler
|
502
510
|
- spec/fixtures/lockfiles/not-a-lockfile
|
511
|
+
- spec/fixtures/repos/assets_disabled/app/assets/empty
|
503
512
|
- spec/fixtures/repos/assets_disabled/config/application.rb
|
504
513
|
- spec/fixtures/repos/assets_disabled/Gemfile
|
505
514
|
- spec/fixtures/repos/assets_disabled/Gemfile.lock
|
506
515
|
- spec/fixtures/repos/assets_disabled/Rakefile
|
507
516
|
- spec/fixtures/repos/assets_disabled/README
|
517
|
+
- spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty
|
508
518
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb
|
509
519
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml
|
510
520
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile
|
511
521
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock
|
512
522
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile
|
513
523
|
- spec/fixtures/repos/assets_disabled_in_ey_yml/README
|
524
|
+
- spec/fixtures/repos/assets_enabled/app/assets/empty
|
514
525
|
- spec/fixtures/repos/assets_enabled/config/application.rb
|
515
526
|
- spec/fixtures/repos/assets_enabled/Gemfile
|
516
527
|
- spec/fixtures/repos/assets_enabled/Gemfile.lock
|
@@ -521,6 +532,7 @@ test_files:
|
|
521
532
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock
|
522
533
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile
|
523
534
|
- spec/fixtures/repos/assets_enabled_in_ey_yml/README
|
535
|
+
- spec/fixtures/repos/assets_in_hook/app/assets/empty
|
524
536
|
- spec/fixtures/repos/assets_in_hook/config/application.rb
|
525
537
|
- spec/fixtures/repos/assets_in_hook/deploy/before_migrate.rb
|
526
538
|
- spec/fixtures/repos/assets_in_hook/Gemfile
|
@@ -570,6 +582,7 @@ test_files:
|
|
570
582
|
- spec/nodejs_deploy_spec.rb
|
571
583
|
- spec/rails31_deploy_spec.rb
|
572
584
|
- spec/restart_spec.rb
|
585
|
+
- spec/rollback_spec.rb
|
573
586
|
- spec/server_spec.rb
|
574
587
|
- spec/services_deploy_spec.rb
|
575
588
|
- spec/shell_spec.rb
|