engineyard-serverside 1.6.5 → 1.7.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside.rb +2 -0
- data/lib/engineyard-serverside/cli.rb +83 -48
- data/lib/engineyard-serverside/configuration.rb +85 -18
- data/lib/engineyard-serverside/deploy.rb +105 -91
- data/lib/engineyard-serverside/deploy_hook.rb +22 -20
- data/lib/engineyard-serverside/deprecation.rb +9 -17
- data/lib/engineyard-serverside/future.rb +10 -4
- data/lib/engineyard-serverside/futures/celluloid.rb +3 -13
- data/lib/engineyard-serverside/futures/dataflow.rb +8 -13
- data/lib/engineyard-serverside/lockfile_parser.rb +1 -1
- data/lib/engineyard-serverside/rails_asset_support.rb +26 -10
- data/lib/engineyard-serverside/server.rb +17 -12
- data/lib/engineyard-serverside/shell.rb +98 -0
- data/lib/engineyard-serverside/shell/formatter.rb +71 -0
- data/lib/engineyard-serverside/shell/helpers.rb +29 -0
- data/lib/engineyard-serverside/strategies/git.rb +33 -63
- data/lib/engineyard-serverside/task.rb +34 -13
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/basic_deploy_spec.rb +15 -50
- data/spec/bundler_deploy_spec.rb +3 -44
- data/spec/configuration_spec.rb +72 -0
- data/spec/custom_deploy_spec.rb +3 -4
- data/spec/deploy_hook_spec.rb +210 -162
- data/spec/deprecation_spec.rb +4 -26
- data/spec/ey_yml_customized_deploy_spec.rb +68 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile +6 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_disabled/README +1 -0
- data/spec/fixtures/repos/assets_disabled/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +6 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_enabled/Gemfile +6 -0
- data/spec/fixtures/repos/assets_enabled/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_enabled/README +1 -0
- data/spec/fixtures/repos/assets_enabled/Rakefile +5 -0
- data/spec/fixtures/repos/assets_enabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +5 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile +6 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_in_hook/README +2 -0
- data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_in_hook/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/default/Gemfile +5 -0
- data/spec/fixtures/repos/default/Gemfile.lock +14 -0
- data/spec/fixtures/repos/default/README +5 -0
- data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml/README +1 -0
- data/spec/fixtures/repos/ey_yml/config/ey.yml +12 -0
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml_alt/README +1 -0
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
- data/spec/fixtures/repos/hook_fails/README +1 -0
- data/spec/fixtures/repos/hook_fails/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/README +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile +4 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +12 -0
- data/spec/fixtures/repos/no_ey_config/README +1 -0
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +5 -0
- data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
- data/spec/fixtures/repos/nodejs/README +1 -0
- data/spec/fixtures/repos/nodejs/package.json +7 -0
- data/spec/fixtures/repos/not_bundled/README +1 -0
- data/spec/fixtures/{gemfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile} +0 -0
- data/spec/fixtures/{lockfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile.lock} +0 -0
- data/spec/fixtures/repos/sqlite3/README +1 -0
- data/spec/git_strategy_spec.rb +11 -2
- data/spec/lockfile_parser_spec.rb +8 -3
- data/spec/nodejs_deploy_spec.rb +1 -26
- data/spec/rails31_deploy_spec.rb +23 -31
- data/spec/services_deploy_spec.rb +41 -100
- data/spec/shell_spec.rb +50 -0
- data/spec/spec_helper.rb +80 -66
- data/spec/sqlite3_deploy_spec.rb +10 -16
- data/spec/support/integration.rb +45 -139
- metadata +233 -78
- data/lib/engineyard-serverside/logged_output.rb +0 -91
- data/spec/logged_output_spec.rb +0 -55
data/spec/rails31_deploy_spec.rb
CHANGED
@@ -3,62 +3,54 @@ require 'spec_helper'
|
|
3
3
|
describe "Deploying a Rails 3.1 application" do
|
4
4
|
context "with default production settings" do
|
5
5
|
before(:all) do
|
6
|
-
deploy_test_application
|
6
|
+
deploy_test_application('assets_enabled')
|
7
7
|
end
|
8
8
|
|
9
9
|
it "precompiles assets" do
|
10
|
-
|
10
|
+
@deploy_dir.join('current', 'precompiled').should exist
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with asset compilation enabled in ey.yml, despite not otherwise being enabled" do
|
15
|
+
before(:all) do
|
16
|
+
deploy_test_application('assets_enabled_in_ey_yml')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "precompiles assets" do
|
20
|
+
@deploy_dir.join('current', 'precompiled').should exist
|
11
21
|
end
|
12
22
|
end
|
13
23
|
|
14
24
|
context "with asset support disabled in its config" do
|
15
25
|
before(:all) do
|
16
|
-
deploy_test_application(
|
26
|
+
deploy_test_application('assets_disabled')
|
17
27
|
end
|
18
28
|
|
19
29
|
it "does not precompile assets" do
|
20
|
-
|
30
|
+
@deploy_dir.join('current', 'precompiled').should_not exist
|
21
31
|
end
|
22
32
|
end
|
23
33
|
|
24
|
-
context "
|
34
|
+
context "with asset compilation disabled in ey.yml, despite all other configuration would enable assets" do
|
25
35
|
before(:all) do
|
26
|
-
|
27
|
-
deploy_test_application(with_assets = false) do
|
28
|
-
deploy_dir = File.join(@config.repository_cache, 'deploy')
|
29
|
-
FileUtils.mkdir_p(deploy_dir)
|
30
|
-
hook = File.join(deploy_dir, 'before_migrate.rb')
|
31
|
-
hook_contents = %Q[raise 'aaaaaaahhhhh']
|
32
|
-
File.open(hook, 'w') {|f| f.puts(hook_contents) }
|
33
|
-
File.chmod(0755, hook)
|
34
|
-
end
|
35
|
-
rescue EY::Serverside::RemoteFailure
|
36
|
-
end
|
36
|
+
deploy_test_application('assets_disabled_in_ey_yml')
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
40
|
-
|
41
|
-
File.directory?(File.join(@deploy_dir, 'releases_failed', release_name)).should be_true
|
39
|
+
it "precompiles assets" do
|
40
|
+
@deploy_dir.join('current', 'precompiled').should_not exist
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
context "with existing precompilation in a deploy hook" do
|
46
45
|
before(:all) do
|
47
|
-
deploy_test_application
|
48
|
-
deploy_dir = File.join(@config.repository_cache, 'deploy')
|
49
|
-
FileUtils.mkdir_p(deploy_dir)
|
50
|
-
hook = File.join(deploy_dir, 'before_migrate.rb')
|
51
|
-
hook_contents = %Q[run 'touch custom_compiled && mkdir public/assets']
|
52
|
-
File.open(hook, 'w') {|f| f.puts(hook_contents) }
|
53
|
-
File.chmod(0755, hook)
|
54
|
-
end
|
46
|
+
deploy_test_application('assets_in_hook')
|
55
47
|
end
|
56
48
|
|
57
49
|
it "does not replace the public/assets directory" do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
@deploy_dir.join('current', 'custom_compiled').should exist
|
51
|
+
@deploy_dir.join('current', 'precompiled').should_not exist
|
52
|
+
@deploy_dir.join('current', 'public', 'assets').should be_directory
|
53
|
+
@deploy_dir.join('current', 'public', 'assets').should_not be_symlink
|
62
54
|
end
|
63
55
|
end
|
64
56
|
end
|
@@ -1,95 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Deploying an application with services" do
|
4
|
-
before(:each) do
|
5
|
-
#$DISABLE_GEMFILE = true # Don't generate Gemfile/Gemfile.lock
|
6
|
-
#$DISABLE_LOCKFILE = true
|
7
|
-
@deploy_dir = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}")
|
8
|
-
|
9
|
-
# set up EY::Serverside::Server like we're on a solo
|
10
|
-
EY::Serverside::Server.reset
|
11
|
-
EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup_deploy
|
15
|
-
# run a deploy
|
16
|
-
config = EY::Serverside::Deploy::Configuration.new({
|
17
|
-
"strategy" => "IntegrationSpec",
|
18
|
-
"deploy_to" => @deploy_dir.to_s,
|
19
|
-
"group" => `id -gn`.strip,
|
20
|
-
"stack" => 'nginx_passenger',
|
21
|
-
"migrate" => nil,
|
22
|
-
'app' => 'foo',
|
23
|
-
'framework_env' => 'staging'
|
24
|
-
})
|
25
|
-
|
26
|
-
EY::Serverside::LoggedOutput.verbose = true
|
27
|
-
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
28
|
-
FullTestDeploy.new(config)
|
29
|
-
end
|
30
|
-
|
31
|
-
def exist
|
32
|
-
be_exist
|
33
|
-
end
|
34
|
-
|
35
4
|
describe "a deploy without ey_config" do
|
36
|
-
before do
|
37
|
-
@deployer = setup_deploy
|
38
|
-
@deployer.mock_gemfile_contents <<-EOF
|
39
|
-
source :rubygems
|
40
|
-
gem 'rake'
|
41
|
-
gem 'pg'
|
42
|
-
EOF
|
43
|
-
@deployer.mock_lockfile_contents <<-EOF
|
44
|
-
GEM
|
45
|
-
remote: http://rubygems.org/
|
46
|
-
specs:
|
47
|
-
pg (0.11.0)
|
48
|
-
rake (0.9.2.2)
|
49
|
-
|
50
|
-
PLATFORMS
|
51
|
-
ruby
|
52
|
-
|
53
|
-
DEPENDENCIES
|
54
|
-
pg
|
55
|
-
rake
|
56
|
-
EOF
|
57
|
-
end
|
58
|
-
|
59
5
|
describe "with services" do
|
60
6
|
before do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
7
|
+
deploy_test_application('no_ey_config') do |deployer|
|
8
|
+
@shared_services_file = deployer.shared_path.join('config', 'ey_services_config_deploy.yml')
|
9
|
+
@services_yml = {"servicio" => {"foo" => "bar"}}.to_yaml
|
10
|
+
deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
11
|
+
end
|
65
12
|
end
|
66
13
|
|
67
14
|
it "warns about missing ey_config" do
|
68
|
-
|
15
|
+
read_stderr.should include("WARNING: Gemfile.lock does not contain ey_config")
|
69
16
|
end
|
70
|
-
|
71
17
|
end
|
18
|
+
|
72
19
|
describe "without services" do
|
73
20
|
before do
|
74
|
-
|
21
|
+
deploy_test_application('no_ey_config')
|
75
22
|
end
|
76
23
|
|
77
24
|
it "works without warnings" do
|
78
|
-
|
25
|
+
read_output.should_not =~ /WARNING/
|
79
26
|
end
|
80
|
-
|
81
27
|
end
|
82
28
|
end
|
83
29
|
|
84
30
|
describe "deploy with invalid yaml ey_services_config_deploy" do
|
85
31
|
before do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
@deployer.deploy
|
32
|
+
deploy_test_application do |deployer|
|
33
|
+
@shared_services_file = deployer.shared_path.join('config', 'ey_services_config_deploy.yml')
|
34
|
+
@symlinked_services_file = deployer.release_path.join('config', 'ey_services_config_deploy.yml')
|
35
|
+
@invalid_services_yml = "42"
|
36
|
+
deployer.mock_services_setup!("echo '#{@invalid_services_yml}' > #{@shared_services_file}")
|
37
|
+
end
|
93
38
|
end
|
94
39
|
|
95
40
|
it "works without warning" do
|
@@ -101,19 +46,19 @@ DEPENDENCIES
|
|
101
46
|
@symlinked_services_file.should be_symlink
|
102
47
|
@shared_services_file.read.should == "#{@invalid_services_yml}\n"
|
103
48
|
|
104
|
-
|
49
|
+
read_output.should_not =~ /WARNING/
|
105
50
|
end
|
106
51
|
end
|
107
52
|
|
108
53
|
describe "a succesful deploy" do
|
109
54
|
before do
|
110
|
-
|
111
|
-
|
112
|
-
|
55
|
+
deploy_test_application do |deployer|
|
56
|
+
@shared_services_file = deployer.shared_path.join('config', 'ey_services_config_deploy.yml')
|
57
|
+
@symlinked_services_file = deployer.release_path.join('config', 'ey_services_config_deploy.yml')
|
58
|
+
@services_yml = {"servicio" => {"foo" => "bar"}}.to_yaml
|
113
59
|
|
114
|
-
|
115
|
-
|
116
|
-
@deployer.deploy
|
60
|
+
deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
61
|
+
end
|
117
62
|
end
|
118
63
|
|
119
64
|
it "creates and symlinks ey_services_config_deploy.yml" do
|
@@ -125,14 +70,14 @@ DEPENDENCIES
|
|
125
70
|
@symlinked_services_file.should be_symlink
|
126
71
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
127
72
|
|
128
|
-
|
73
|
+
read_output.should_not =~ /WARNING/
|
129
74
|
end
|
130
75
|
|
131
76
|
describe "followed by a deploy that can't find the command" do
|
132
77
|
before do
|
133
|
-
|
134
|
-
|
135
|
-
|
78
|
+
redeploy_test_application do |deployer|
|
79
|
+
deployer.mock_services_command_check!("which nonexistatncommand")
|
80
|
+
end
|
136
81
|
end
|
137
82
|
|
138
83
|
it "silently fails" do
|
@@ -144,20 +89,16 @@ DEPENDENCIES
|
|
144
89
|
@symlinked_services_file.should be_symlink
|
145
90
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
146
91
|
|
147
|
-
|
92
|
+
read_output.should_not =~ /WARNING/
|
148
93
|
end
|
149
94
|
|
150
95
|
end
|
151
96
|
|
152
97
|
describe "followed by a deploy that fails to fetch services" do
|
153
|
-
before do
|
154
|
-
@deployer = setup_deploy
|
155
|
-
@deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
|
156
|
-
end
|
157
|
-
|
158
98
|
it "logs a warning and symlinks the existing config file when there is existing services file" do
|
159
|
-
|
160
|
-
|
99
|
+
redeploy_test_application do |deployer|
|
100
|
+
deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
|
101
|
+
end
|
161
102
|
@shared_services_file.should exist
|
162
103
|
@shared_services_file.should_not be_symlink
|
163
104
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
@@ -166,28 +107,29 @@ DEPENDENCIES
|
|
166
107
|
@symlinked_services_file.should be_symlink
|
167
108
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
168
109
|
|
169
|
-
|
110
|
+
read_output.should include('WARNING: External services configuration not updated')
|
170
111
|
end
|
171
112
|
|
172
113
|
it "does not log a warning or symlink a config file when there is no existing services file" do
|
173
|
-
|
174
|
-
|
114
|
+
redeploy_test_application do |deployer|
|
115
|
+
deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
|
116
|
+
@shared_services_file.delete
|
117
|
+
end
|
175
118
|
|
176
119
|
@shared_services_file.should_not exist
|
177
120
|
@symlinked_services_file.should_not exist
|
178
121
|
|
179
|
-
|
122
|
+
read_output.should_not =~ /WARNING/
|
180
123
|
end
|
181
124
|
|
182
125
|
end
|
183
126
|
|
184
127
|
describe "followed by another successfull deploy" do
|
185
128
|
before do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
@deployer.deploy
|
129
|
+
redeploy_test_application do |deployer|
|
130
|
+
@services_yml = {"servicio" => {"foo" => "bar2"}}.to_yaml
|
131
|
+
deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
132
|
+
end
|
191
133
|
end
|
192
134
|
|
193
135
|
it "replaces the config with the new one (and symlinks)" do
|
@@ -199,9 +141,8 @@ DEPENDENCIES
|
|
199
141
|
@symlinked_services_file.should be_symlink
|
200
142
|
@shared_services_file.read.should == "#{@services_yml}\n"
|
201
143
|
|
202
|
-
|
144
|
+
read_output.should_not =~ /WARNING/
|
203
145
|
end
|
204
|
-
|
205
146
|
end
|
206
147
|
|
207
148
|
end
|
data/spec/shell_spec.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'timecop'
|
4
|
+
|
5
|
+
describe EY::Serverside::Shell do
|
6
|
+
it "has a timestamp before each line" do
|
7
|
+
time1 = Time.local(2008, 9, 1, 12, 0, 0)
|
8
|
+
time2 = Time.local(2008, 9, 1, 12, 3, 5)
|
9
|
+
time3 = Time.local(2008, 9, 1, 12, 10, 25)
|
10
|
+
|
11
|
+
@output = StringIO.new
|
12
|
+
@shell = EY::Serverside::Shell.new(:verbose => true, :stdout => @output, :stderr => @output, :log_path => Pathname.new(Dir.tmpdir).join("engineyard-serverside-#{Time.now.to_i}-${$$}.log"), :start_time => time1)
|
13
|
+
|
14
|
+
Timecop.freeze(time1) do
|
15
|
+
@shell.debug('debug')
|
16
|
+
@shell.notice('notice')
|
17
|
+
end
|
18
|
+
Timecop.freeze(time2) do
|
19
|
+
@shell.status('STATUS')
|
20
|
+
@shell.debug("multi\nline\ndebug")
|
21
|
+
@shell.warning("multi\nline\nwarning")
|
22
|
+
end
|
23
|
+
Timecop.freeze(time3) do
|
24
|
+
@shell.substatus("multi\nline\nsubstatus")
|
25
|
+
end
|
26
|
+
|
27
|
+
tstp_1 = "+ 00s "
|
28
|
+
tstp_2 = "+ 3m 05s "
|
29
|
+
tstp_3 = "+10m 25s "
|
30
|
+
notstp = " "
|
31
|
+
@output.rewind
|
32
|
+
@output.read.should == <<-OUTPUT
|
33
|
+
#{notstp} debug
|
34
|
+
|
35
|
+
\e[1m\e[33m#{tstp_1} !> notice
|
36
|
+
\e[0m
|
37
|
+
\e[1m\e[37m#{tstp_2} ~> STATUS
|
38
|
+
\e[0m#{notstp} multi
|
39
|
+
#{notstp} line
|
40
|
+
#{notstp} debug
|
41
|
+
|
42
|
+
\e[1m\e[33m#{tstp_2} !> WARNING: multi
|
43
|
+
#{tstp_2} !> line
|
44
|
+
#{tstp_2} !> warning
|
45
|
+
\e[0m#{notstp} ~ multi
|
46
|
+
#{notstp} ~ line
|
47
|
+
#{notstp} ~ substatus
|
48
|
+
OUTPUT
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
$LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
|
4
|
-
Bundler.require :default, :test
|
5
|
-
else
|
3
|
+
unless defined?(Bundler)
|
6
4
|
require 'rubygems'
|
7
5
|
end
|
8
6
|
|
7
|
+
if ENV['COVERAGE']
|
8
|
+
# Ruby 1.9.x only.
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter "lib/vendor/"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
require 'pp'
|
10
16
|
require 'engineyard-serverside'
|
11
17
|
require File.expand_path('../support/integration', __FILE__)
|
12
18
|
|
19
|
+
FIXTURES_DIR = Pathname.new(__FILE__).dirname.join("fixtures")
|
20
|
+
GROUP = `id -gn`.strip
|
21
|
+
|
13
22
|
module EY
|
14
23
|
module Serverside
|
15
24
|
def self.dna_json=(j)
|
@@ -17,24 +26,12 @@ module EY
|
|
17
26
|
@node = nil
|
18
27
|
end
|
19
28
|
|
20
|
-
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@use_actual_info = false
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.use_actual_info?
|
30
|
-
@use_actual_info
|
31
|
-
end
|
32
|
-
|
33
|
-
alias old_info info
|
34
|
-
def info(*args)
|
35
|
-
if EY::Serverside::LoggedOutput.use_actual_info?
|
36
|
-
old_info(*args)
|
37
|
-
end
|
29
|
+
class Future
|
30
|
+
def inspect
|
31
|
+
<<-EOM
|
32
|
+
#{self.class.name} result below: (run with DEBUG=1 to see the full log)
|
33
|
+
#{result.inspect}
|
34
|
+
EOM
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
@@ -44,29 +41,60 @@ module EY
|
|
44
41
|
end
|
45
42
|
end
|
46
43
|
|
47
|
-
FIXTURES_DIR = File.expand_path("../fixtures", __FILE__)
|
48
|
-
GITREPO_DIR = "#{FIXTURES_DIR}/gitrepo"
|
49
|
-
|
50
|
-
FileUtils.rm_rf GITREPO_DIR if File.exists? GITREPO_DIR
|
51
|
-
Kernel.system "tar xzf #{GITREPO_DIR}.tar.gz -C #{FIXTURES_DIR}"
|
52
|
-
|
53
44
|
Spec::Runner.configure do |config|
|
54
|
-
|
55
|
-
$NPM_INSTALLED = ($? == 0)
|
45
|
+
$NPM_INSTALLED = system('which npm 2>&1')
|
56
46
|
unless $NPM_INSTALLED
|
57
47
|
$stderr.puts "npm not found; skipping Node.js specs."
|
58
48
|
end
|
59
49
|
|
60
50
|
config.before(:all) do
|
61
|
-
$DISABLE_GEMFILE = false
|
62
|
-
$DISABLE_LOCKFILE = false
|
63
51
|
EY::Serverside.dna_json = {}.to_json
|
64
52
|
end
|
65
53
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
54
|
+
class VerboseStringIO < StringIO
|
55
|
+
def <<(str)
|
56
|
+
if ENV['VERBOSE'] || ENV['DEBUG']
|
57
|
+
$stderr << str
|
58
|
+
end
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def stdout
|
64
|
+
@stdout ||= VerboseStringIO.new
|
65
|
+
end
|
66
|
+
|
67
|
+
def stderr
|
68
|
+
@stderr ||= VerboseStringIO.new
|
69
|
+
end
|
70
|
+
|
71
|
+
def read_stdout
|
72
|
+
stdout.rewind
|
73
|
+
stdout.read
|
74
|
+
end
|
75
|
+
|
76
|
+
def read_stderr
|
77
|
+
stderr.rewind
|
78
|
+
stderr.read
|
79
|
+
end
|
80
|
+
|
81
|
+
def read_output
|
82
|
+
read_stdout + "\n" + read_stderr
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_shell
|
86
|
+
log_path = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}.log")
|
87
|
+
EY::Serverside::Shell.new(:verbose => true, :log_path => log_path, :stdout => stdout, :stderr => stderr)
|
88
|
+
end
|
89
|
+
|
90
|
+
def exist
|
91
|
+
be_exist
|
92
|
+
end
|
93
|
+
|
94
|
+
# When a repo fixture name is specified, the files found in the specified
|
95
|
+
# spec/fixtures/repos dir are copied into the test github repository.
|
96
|
+
def deploy_test_application(repo_fixture_name = 'default', extra_config = {}, &block)
|
97
|
+
@deploy_dir = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}")
|
70
98
|
|
71
99
|
# set up EY::Serverside::Server like we're on a solo
|
72
100
|
EY::Serverside::Server.reset
|
@@ -75,47 +103,33 @@ Spec::Runner.configure do |config|
|
|
75
103
|
# run a deploy
|
76
104
|
@config = EY::Serverside::Deploy::Configuration.new({
|
77
105
|
"strategy" => "IntegrationSpec",
|
78
|
-
"deploy_to" => @deploy_dir,
|
79
|
-
"group" =>
|
106
|
+
"deploy_to" => @deploy_dir.to_s,
|
107
|
+
"group" => GROUP,
|
80
108
|
"stack" => 'nginx_passenger',
|
81
109
|
"migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
|
82
110
|
'app' => 'rails31',
|
83
|
-
'
|
84
|
-
|
111
|
+
'environment_name' => 'env',
|
112
|
+
'account_name' => 'acc',
|
113
|
+
'framework_env' => 'staging',
|
114
|
+
'branch' => 'somebranch',
|
115
|
+
'repo' => FIXTURES_DIR.join('repos', repo_fixture_name)
|
116
|
+
}.merge(extra_config))
|
85
117
|
|
86
118
|
# pretend there is a shared bundled_gems directory
|
87
|
-
|
119
|
+
@deploy_dir.join('shared', 'bundled_gems').mkpath
|
88
120
|
%w(RUBY_VERSION SYSTEM_VERSION).each do |name|
|
89
|
-
|
121
|
+
@deploy_dir.join('shared', 'bundled_gems', name).open("w") { |f| f.write("old\n") }
|
90
122
|
end
|
91
123
|
|
92
|
-
# Set up the application directory to have the requested asset options.
|
93
|
-
prepare_rails31_app(assets_enabled)
|
94
|
-
|
95
124
|
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
96
|
-
@deployer = FullTestDeploy.new(@config)
|
97
|
-
@deployer
|
125
|
+
@deployer = FullTestDeploy.new(@config, test_shell)
|
126
|
+
yield @deployer if block_given?
|
127
|
+
@deployer.deploy
|
98
128
|
end
|
99
129
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
module Rails31
|
105
|
-
class Application < Rails::Application
|
106
|
-
config.assets.enabled = #{assets_enabled ? 'true' : 'false'}
|
107
|
-
end
|
108
|
-
end
|
109
|
-
EOF
|
110
|
-
File.open(app_rb, 'w') {|f| f.write(app_rb_contents)}
|
111
|
-
rakefile = File.join(@config.release_path, 'Rakefile')
|
112
|
-
rakefile_contents = <<-EOF
|
113
|
-
desc 'Precompile yar assetz'
|
114
|
-
task 'assets:precompile' do
|
115
|
-
sh 'touch precompiled'
|
116
|
-
end
|
117
|
-
EOF
|
118
|
-
File.open(rakefile, 'w') {|f| f.write(rakefile_contents)}
|
119
|
-
FileUtils.mkdir_p(File.join(@config.release_path, 'app', 'assets'))
|
130
|
+
def redeploy_test_application(&block)
|
131
|
+
raise "Please deploy_test_application first" unless @deployer
|
132
|
+
yield @deployer if block_given?
|
133
|
+
@deployer.deploy
|
120
134
|
end
|
121
135
|
end
|