engineyard-serverside 1.5.24 → 1.5.25
Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,7 @@ module EY
|
|
30
30
|
create_revision_file
|
31
31
|
run_with_callbacks(:bundle)
|
32
32
|
setup_services
|
33
|
+
check_for_ey_config
|
33
34
|
symlink_configs
|
34
35
|
conditionally_enable_maintenance_page
|
35
36
|
run_with_callbacks(:migrate)
|
@@ -52,6 +53,23 @@ module EY
|
|
52
53
|
raise
|
53
54
|
end
|
54
55
|
|
56
|
+
def parse_configured_services
|
57
|
+
result = YAML.load_file "#{c.shared_path}/config/ey_services_config_deploy.yml"
|
58
|
+
return {} unless result.is_a?(Hash)
|
59
|
+
result
|
60
|
+
rescue
|
61
|
+
{}
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_for_ey_config
|
65
|
+
if gemfile? && lockfile
|
66
|
+
configured_services = parse_configured_services
|
67
|
+
if !configured_services.empty? && !lockfile.has_ey_config?
|
68
|
+
warning "Gemfile.lock does not contain ey_config. Add it to get EY::Config access to: #{configured_services.keys.join(', ')}."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
55
73
|
def check_repository
|
56
74
|
if gemfile?
|
57
75
|
info "~> Gemfile found."
|
@@ -286,6 +304,7 @@ WRAP
|
|
286
304
|
|
287
305
|
def setup_services
|
288
306
|
info "~> Setting up external services."
|
307
|
+
previously_configured_services = parse_configured_services
|
289
308
|
begin
|
290
309
|
sudo(services_command_check)
|
291
310
|
rescue StandardError => e
|
@@ -294,11 +313,13 @@ WRAP
|
|
294
313
|
end
|
295
314
|
sudo(services_setup_command)
|
296
315
|
rescue StandardError => e
|
297
|
-
|
316
|
+
unless previously_configured_services.empty?
|
317
|
+
warning <<-WARNING
|
298
318
|
External services configuration not updated. Using previous version.
|
299
319
|
Deploy again if your services configuration appears incomplete or out of date.
|
300
320
|
#{e}
|
301
|
-
|
321
|
+
WARNING
|
322
|
+
end
|
302
323
|
end
|
303
324
|
|
304
325
|
def symlink_configs(release_to_link=c.release_path)
|
@@ -15,6 +15,10 @@ module EY
|
|
15
15
|
parse
|
16
16
|
end
|
17
17
|
|
18
|
+
def has_ey_config?
|
19
|
+
@contents.index(/^\s+ey_config\s\([^\)]+\)$/)
|
20
|
+
end
|
21
|
+
|
18
22
|
def any_database_adapter?
|
19
23
|
any_ruby_adapter = %w[mysql2 mysql do_mysql pg do_postgres].any? do |type|
|
20
24
|
@contents.index(/^\s+#{type}\s\([^\)]+\)$/)
|
File without changes
|
@@ -32,24 +32,98 @@ describe "Deploying an application with services" do
|
|
32
32
|
be_exist
|
33
33
|
end
|
34
34
|
|
35
|
+
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
|
+
describe "with services" do
|
60
|
+
before do
|
61
|
+
@shared_services_file = @deploy_dir.join('shared', 'config', 'ey_services_config_deploy.yml')
|
62
|
+
@services_yml = {"servicio" => {"foo" => "bar"}}.to_yaml
|
63
|
+
@deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
64
|
+
@deployer.deploy
|
65
|
+
end
|
66
|
+
|
67
|
+
it "warns about missing ey_config" do
|
68
|
+
@deployer.infos.should be_any { |info| info =~ /WARNING: Gemfile.lock does not contain ey_config/ }
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
describe "without services" do
|
73
|
+
before do
|
74
|
+
@deployer.deploy
|
75
|
+
end
|
76
|
+
|
77
|
+
it "works without warnings" do
|
78
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "deploy with invalid yaml ey_services_config_deploy" do
|
85
|
+
before do
|
86
|
+
@shared_services_file = @deploy_dir.join('shared', 'config', 'ey_services_config_deploy.yml')
|
87
|
+
@symlinked_services_file = @deploy_dir.join('current', 'config', 'ey_services_config_deploy.yml')
|
88
|
+
@invalid_services_yml = "42"
|
89
|
+
|
90
|
+
@deployer = setup_deploy
|
91
|
+
@deployer.mock_services_setup!("echo '#{@invalid_services_yml}' > #{@shared_services_file}")
|
92
|
+
@deployer.deploy
|
93
|
+
end
|
94
|
+
|
95
|
+
it "works without warning" do
|
96
|
+
@shared_services_file.should exist
|
97
|
+
@shared_services_file.should_not be_symlink
|
98
|
+
@shared_services_file.read.should == "#{@invalid_services_yml}\n"
|
99
|
+
|
100
|
+
@symlinked_services_file.should exist
|
101
|
+
@symlinked_services_file.should be_symlink
|
102
|
+
@shared_services_file.read.should == "#{@invalid_services_yml}\n"
|
103
|
+
|
104
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
35
108
|
describe "a succesful deploy" do
|
36
109
|
before do
|
37
110
|
@shared_services_file = @deploy_dir.join('shared', 'config', 'ey_services_config_deploy.yml')
|
38
111
|
@symlinked_services_file = @deploy_dir.join('current', 'config', 'ey_services_config_deploy.yml')
|
112
|
+
@services_yml = {"servicio" => {"foo" => "bar"}}.to_yaml
|
39
113
|
|
40
114
|
@deployer = setup_deploy
|
41
|
-
@deployer.mock_services_setup!("echo '
|
115
|
+
@deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
42
116
|
@deployer.deploy
|
43
117
|
end
|
44
118
|
|
45
119
|
it "creates and symlinks ey_services_config_deploy.yml" do
|
46
120
|
@shared_services_file.should exist
|
47
121
|
@shared_services_file.should_not be_symlink
|
48
|
-
@shared_services_file.read.should == "
|
122
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
49
123
|
|
50
124
|
@symlinked_services_file.should exist
|
51
125
|
@symlinked_services_file.should be_symlink
|
52
|
-
@shared_services_file.read.should == "
|
126
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
53
127
|
|
54
128
|
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
55
129
|
end
|
@@ -64,11 +138,11 @@ describe "Deploying an application with services" do
|
|
64
138
|
it "silently fails" do
|
65
139
|
@shared_services_file.should exist
|
66
140
|
@shared_services_file.should_not be_symlink
|
67
|
-
@shared_services_file.read.should == "
|
141
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
68
142
|
|
69
143
|
@symlinked_services_file.should exist
|
70
144
|
@symlinked_services_file.should be_symlink
|
71
|
-
@shared_services_file.read.should == "
|
145
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
72
146
|
|
73
147
|
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
74
148
|
end
|
@@ -79,38 +153,51 @@ describe "Deploying an application with services" do
|
|
79
153
|
before do
|
80
154
|
@deployer = setup_deploy
|
81
155
|
@deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
|
82
|
-
@deployer.deploy
|
83
156
|
end
|
84
157
|
|
85
|
-
it "logs a warning and symlinks the existing config file" do
|
158
|
+
it "logs a warning and symlinks the existing config file when there is existing services file" do
|
159
|
+
@deployer.deploy
|
160
|
+
|
86
161
|
@shared_services_file.should exist
|
87
162
|
@shared_services_file.should_not be_symlink
|
88
|
-
@shared_services_file.read.should == "
|
163
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
89
164
|
|
90
165
|
@symlinked_services_file.should exist
|
91
166
|
@symlinked_services_file.should be_symlink
|
92
|
-
@shared_services_file.read.should == "
|
167
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
93
168
|
|
94
169
|
@deployer.infos.should be_any { |info| info =~ /WARNING: External services configuration not updated/ }
|
95
170
|
end
|
96
171
|
|
172
|
+
it "does not log a warning or symlink a config file when there is no existing services file" do
|
173
|
+
FileUtils.rm(@shared_services_file)
|
174
|
+
@deployer.deploy
|
175
|
+
|
176
|
+
@shared_services_file.should_not exist
|
177
|
+
@symlinked_services_file.should_not exist
|
178
|
+
|
179
|
+
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
180
|
+
end
|
181
|
+
|
97
182
|
end
|
98
183
|
|
99
184
|
describe "followed by another successfull deploy" do
|
100
185
|
before do
|
101
186
|
@deployer = setup_deploy
|
102
|
-
@
|
187
|
+
@services_yml = {"servicio" => {"foo" => "bar2"}}.to_yaml
|
188
|
+
|
189
|
+
@deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
|
103
190
|
@deployer.deploy
|
104
191
|
end
|
105
192
|
|
106
193
|
it "replaces the config with the new one (and symlinks)" do
|
107
194
|
@shared_services_file.should exist
|
108
195
|
@shared_services_file.should_not be_symlink
|
109
|
-
@shared_services_file.read.should == "
|
196
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
110
197
|
|
111
198
|
@symlinked_services_file.should exist
|
112
199
|
@symlinked_services_file.should be_symlink
|
113
|
-
@shared_services_file.read.should == "
|
200
|
+
@shared_services_file.read.should == "#{@services_yml}\n"
|
114
201
|
|
115
202
|
@deployer.infos.should_not be_any { |info| info =~ /WARNING/ }
|
116
203
|
end
|
data/spec/support/integration.rb
CHANGED
@@ -6,6 +6,8 @@ class FullTestDeploy < EY::Serverside::Deploy
|
|
6
6
|
@infos = []
|
7
7
|
@debugs = []
|
8
8
|
@commands = []
|
9
|
+
@gemfile_contents = nil
|
10
|
+
@lockfile_contents = nil
|
9
11
|
end
|
10
12
|
|
11
13
|
# stfu
|
@@ -84,6 +86,14 @@ class FullTestDeploy < EY::Serverside::Deploy
|
|
84
86
|
@mock_services_setup_command = value
|
85
87
|
end
|
86
88
|
|
89
|
+
def mock_gemfile_contents(gemfile_contents)
|
90
|
+
@gemfile_contents = gemfile_contents
|
91
|
+
end
|
92
|
+
|
93
|
+
def mock_lockfile_contents(lockfile_contents)
|
94
|
+
@lockfile_contents = lockfile_contents
|
95
|
+
end
|
96
|
+
|
87
97
|
end
|
88
98
|
|
89
99
|
module EY::Serverside::Strategies::IntegrationSpec
|
@@ -119,21 +129,23 @@ module EY::Serverside::Strategies::IntegrationSpec
|
|
119
129
|
end
|
120
130
|
|
121
131
|
def gemfile_contents
|
122
|
-
<<-EOF
|
132
|
+
@gemfile_contents || <<-EOF
|
123
133
|
source :rubygems
|
124
134
|
gem 'rake'
|
125
135
|
gem 'pg'
|
136
|
+
gem 'ey_config'
|
126
137
|
EOF
|
127
138
|
end
|
128
139
|
|
129
140
|
# Generated using Bundler v1.0.21
|
130
141
|
def lockfile_contents
|
131
|
-
<<-EOF
|
142
|
+
@lockfile_contents || <<-EOF
|
132
143
|
GEM
|
133
144
|
remote: http://rubygems.org/
|
134
145
|
specs:
|
135
146
|
pg (0.11.0)
|
136
147
|
rake (0.9.2.2)
|
148
|
+
ey_config (0.0.1)
|
137
149
|
|
138
150
|
PLATFORMS
|
139
151
|
ruby
|
@@ -141,6 +153,7 @@ PLATFORMS
|
|
141
153
|
DEPENDENCIES
|
142
154
|
pg
|
143
155
|
rake
|
156
|
+
ey_config
|
144
157
|
EOF
|
145
158
|
end
|
146
159
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-serverside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 25
|
10
|
+
version: 1.5.25
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- EY Cloud Team
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -284,6 +284,7 @@ files:
|
|
284
284
|
- spec/custom_deploy_spec.rb
|
285
285
|
- spec/deploy_hook_spec.rb
|
286
286
|
- spec/deprecation_spec.rb
|
287
|
+
- spec/fixtures/gitrepo/bar
|
287
288
|
- spec/fixtures/gitrepo/foo
|
288
289
|
- spec/fixtures/gitrepo.tar.gz
|
289
290
|
- spec/fixtures/invalid_hook.rb
|
@@ -351,6 +352,7 @@ test_files:
|
|
351
352
|
- spec/custom_deploy_spec.rb
|
352
353
|
- spec/deploy_hook_spec.rb
|
353
354
|
- spec/deprecation_spec.rb
|
355
|
+
- spec/fixtures/gitrepo/bar
|
354
356
|
- spec/fixtures/gitrepo/foo
|
355
357
|
- spec/fixtures/gitrepo.tar.gz
|
356
358
|
- spec/fixtures/invalid_hook.rb
|