engineyard-serverside 1.4.3.nodestack → 1.4.7.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. data/lib/core-ext/README.md +3 -0
  2. data/lib/core-ext/string.rb +9 -0
  3. data/lib/engineyard-serverside.rb +3 -1
  4. data/lib/engineyard-serverside/cli.rb +3 -2
  5. data/lib/engineyard-serverside/configuration.rb +1 -1
  6. data/lib/engineyard-serverside/deploy.rb +117 -23
  7. data/lib/engineyard-serverside/lockfile_parser.rb +3 -3
  8. data/lib/engineyard-serverside/logged_output.rb +0 -5
  9. data/lib/engineyard-serverside/task.rb +1 -0
  10. data/lib/engineyard-serverside/version.rb +1 -1
  11. data/lib/vendor/ruby_1.8.6_openssl.patch +7 -0
  12. data/spec/custom_deploy_spec.rb +14 -7
  13. data/spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile +5 -0
  14. data/spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile.lock +29 -0
  15. data/spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile +5 -0
  16. data/spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile.lock +29 -0
  17. data/spec/fixtures/gemfiles/activerecord_mysql/Gemfile +5 -0
  18. data/spec/fixtures/gemfiles/activerecord_mysql/Gemfile.lock +25 -0
  19. data/spec/fixtures/gemfiles/activerecord_mysql2/Gemfile +5 -0
  20. data/spec/fixtures/gemfiles/activerecord_mysql2/Gemfile.lock +25 -0
  21. data/spec/fixtures/gemfiles/activerecord_pg/Gemfile +5 -0
  22. data/spec/fixtures/gemfiles/activerecord_pg/Gemfile.lock +25 -0
  23. data/spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile +5 -0
  24. data/spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile.lock +25 -0
  25. data/spec/fixtures/gemfiles/diy_database_yml/Gemfile +5 -0
  26. data/spec/fixtures/gemfiles/diy_database_yml/Gemfile.lock +25 -0
  27. data/spec/fixtures/gemfiles/diy_database_yml/config/database.yml +7 -0
  28. data/spec/generate_configs_spec.rb +228 -0
  29. data/spec/lib/full_test_deploy.rb +86 -0
  30. data/spec/real_deploy_spec.rb +42 -121
  31. data/spec/spec_helper.rb +62 -1
  32. metadata +75 -9
  33. data/spec/fixtures/gitrepo/bar +0 -0
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require File.dirname(__FILE__) + '/lib/full_test_deploy'
2
3
 
3
- module EY::Serverside::Strategies::IntegrationSpec
4
+ module EY::Serverside::Strategies::DeployIntegrationSpec
4
5
  module Helpers
5
6
 
6
7
  def update_repository_cache
@@ -19,7 +20,6 @@ module EY::Serverside::Strategies::IntegrationSpec
19
20
 
20
21
  FileUtils.mkdir_p(File.join(c.shared_path, 'config'))
21
22
 
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,125 +61,44 @@ EOF
76
61
  end
77
62
 
78
63
  describe "deploying an application" do
79
- class FullTestDeploy < EY::Serverside::Deploy
80
- attr_reader :infos, :debugs, :commands
81
-
82
- def initialize(*)
83
- super
84
- @infos = []
85
- @debugs = []
86
- @commands = []
87
- end
88
-
89
- # stfu
90
- def info(msg)
91
- @infos << msg
92
- end
93
-
94
- # no really, stfu
95
- def debug(msg)
96
- @debugs << msg
97
- end
98
-
99
- # passwordless sudo is neither guaranteed nor desired
100
- def sudo(cmd)
101
- run(cmd)
102
- end
103
-
104
- def run(cmd)
105
- @commands << cmd
106
- super
107
- end
108
-
109
- def version_specifier
110
- # Normally, the deploy task invokes the hook task by executing
111
- # the rubygems-generated wrapper (it's what's in $PATH). It
112
- # specifies the version to make sure that the pieces don't get
113
- # out of sync. However, in test mode, there's no
114
- # rubygems-generated wrapper, and so the hook task doesn't get
115
- # run because thor thinks we're trying to invoke the _$VERSION_
116
- # task instead, which doesn't exist.
117
- #
118
- # By stripping that out, we can get the hooks to actually run
119
- # inside this test.
120
- nil
121
- end
122
-
123
- def restart
124
- FileUtils.touch("#{c.release_path}/restart")
125
- end
126
-
127
- # we're probably running this spec under bundler, but a real
128
- # deploy does not
129
- def bundle
130
- my_env = ENV.to_hash
131
-
132
- ENV.delete("BUNDLE_GEMFILE")
133
- ENV.delete("BUNDLE_BIN_PATH")
134
-
135
- result = super
136
-
137
- ENV.replace(my_env)
138
- result
139
- end
140
-
141
- def get_bundler_installer(lockfile)
142
- installer = super
143
- installer.options << ' --quiet' # stfu already!
144
- installer
145
- end
146
-
147
- end
148
64
 
149
65
  before(:all) do
150
66
  @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
67
+ FileUtils.mkdir_p(@deploy_dir)
151
68
 
152
69
  # set up EY::Serverside::Server like we're on a solo
153
70
  EY::Serverside::Server.reset
154
71
  EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
155
72
 
73
+ setup_dna_json
74
+
156
75
  # run a deploy
157
76
  config = EY::Serverside::Deploy::Configuration.new({
158
- "strategy" => "IntegrationSpec",
77
+ "strategy" => "DeployIntegrationSpec",
159
78
  "deploy_to" => @deploy_dir,
160
79
  "group" => `id -gn`.strip,
161
80
  "stack" => 'nginx_passenger',
162
81
  "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
163
- 'app' => 'foo',
82
+ 'app' => 'myfirstapp',
164
83
  'framework_env' => 'staging'
165
84
  })
166
85
 
167
86
  # pretend there is a shared bundled_gems directory
168
87
  FileUtils.mkdir_p(File.join(@deploy_dir, 'shared', 'bundled_gems'))
169
- %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
88
+ %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
170
89
  File.open(File.join(@deploy_dir, 'shared', 'bundled_gems', name), "w") { |f| f.write("old\n") }
171
90
  end
172
91
 
173
92
  @binpath = $0 = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
93
+
174
94
  @deployer = FullTestDeploy.new(config)
175
95
  @deployer.deploy
176
96
  end
177
97
 
178
- it "runs the right bundler command" do
179
- install_bundler_command_ran = @deployer.commands.detect{ |command| command.index("install_bundler") }
180
- install_bundler_command_ran.should_not be_nil
181
- install_bundler_command_ran.should == "#{@binpath} _#{EY::Serverside::VERSION}_ install_bundler 1.0.10"
182
- end
183
-
184
98
  it "creates a REVISION file" do
185
99
  File.exist?(File.join(@deploy_dir, 'current', 'REVISION')).should be_true
186
100
  end
187
101
 
188
- it "restarts the app servers" do
189
- File.exist?(File.join(@deploy_dir, 'current', 'restart')).should be_true
190
- end
191
-
192
- it "runs 'bundle install' with --deployment" do
193
- bundle_install_cmd = @deployer.commands.grep(/bundle _\S+_ install/).first
194
- bundle_install_cmd.should_not be_nil
195
- bundle_install_cmd.should include('--deployment')
196
- end
197
-
198
102
  it "creates a ruby version file" do
199
103
  File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'RUBY_VERSION')).should be_true
200
104
  end
@@ -203,27 +107,40 @@ describe "deploying an application" do
203
107
  File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'SYSTEM_VERSION')).should be_true
204
108
  end
205
109
 
206
- it "removes bundled_gems directory if the ruby version changed" do
207
- clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
208
- clear_bundle_cmd.should_not be_nil
209
- end
110
+ if RUBY_VERSION != '1.8.6'
111
+ it "runs the right bundler command" do
112
+ install_bundler_command_ran = @deployer.commands.detect{ |command| command.index("install_bundler") }
113
+ install_bundler_command_ran.should_not be_nil
114
+ install_bundler_command_ran.should == "#{@binpath} _#{EY::Serverside::VERSION}_ install_bundler 1.0.10"
115
+ end
210
116
 
211
- it "removes bundled_gems directory if the system version changed" do
212
- clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
213
- clear_bundle_cmd.should_not be_nil
214
- end
117
+ it "runs 'bundle install' with --deployment" do
118
+ bundle_install_cmd = @deployer.commands.grep(/bundle _\S+_ install/).first
119
+ bundle_install_cmd.should_not be_nil
120
+ bundle_install_cmd.should include('--deployment')
121
+ end
215
122
 
216
- it "runs 'npm install'" do
217
- bundle_install_cmd = @deployer.commands.grep(/npm install/).first
218
- bundle_install_cmd.should_not be_nil
219
- end
123
+ it "creates binstubs somewhere out of the way" do
124
+ File.exist?(File.join(@deploy_dir, 'current', 'ey_bundler_binstubs', 'rake')).should be_true
125
+ end
220
126
 
221
- it "creates binstubs somewhere out of the way" do
222
- File.exist?(File.join(@deploy_dir, 'current', 'ey_bundler_binstubs', 'rake')).should be_true
127
+ it "has the binstubs in the path when migrating" do
128
+ File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
129
+ end
130
+
131
+ it "removes bundled_gems directory if the ruby version changed" do
132
+ clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
133
+ clear_bundle_cmd.should_not be_nil
134
+ end
135
+
136
+ it "removes bundled_gems directory if the system version changed" do
137
+ clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
138
+ clear_bundle_cmd.should_not be_nil
139
+ end
223
140
  end
224
141
 
225
- it "has the binstubs in the path when migrating" do
226
- File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
142
+ it "generates a database.yml file" do
143
+ File.exist?(File.join(@deploy_dir, 'current', 'config', 'database.yml')).should be_true
227
144
  end
228
145
 
229
146
  it "runs all the hooks" do
@@ -236,4 +153,8 @@ describe "deploying an application" do
236
153
  File.exist?(File.join(@deploy_dir, 'current', 'before_restart.ran')).should be_true
237
154
  File.exist?(File.join(@deploy_dir, 'current', 'after_restart.ran' )).should be_true
238
155
  end
156
+
157
+ it "restarts the app servers" do
158
+ File.exist?(File.join(@deploy_dir, 'current', 'restart')).should be_true
159
+ end
239
160
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  $LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__))
2
2
 
3
- Bundler.require :default, :test
3
+ # Bundler.require :default, :test - FIXME when we return to ruby 1.8.7+
4
+ require 'rubygems'
5
+ require 'spec'
4
6
  require 'pp'
7
+ require 'tmpdir'
5
8
  require 'engineyard-serverside'
6
9
 
7
10
  module EY
@@ -32,6 +35,64 @@ GITREPO_DIR = "#{FIXTURES_DIR}/gitrepo"
32
35
  FileUtils.rm_rf GITREPO_DIR if File.exists? GITREPO_DIR
33
36
  Kernel.system "tar xzf #{GITREPO_DIR}.tar.gz -C #{FIXTURES_DIR}"
34
37
 
38
+ def setup_dna_json(options = {})
39
+ EY::Serverside.dna_json = {
40
+ 'environment' => {
41
+ "framework_env" => "production",
42
+ },
43
+ 'engineyard' => {
44
+ "environment" => {
45
+ "apps" => [{
46
+ "name" => "myfirstapp",
47
+ "database_name" => "myfirstapp",
48
+ "type" => "rack"
49
+ }],
50
+ "instances" => dna_instances_for(options[:cluster_type] || :solo),
51
+ "components" => [{"key" => "ruby_187"}],
52
+ "framework_env" => "production",
53
+ "stack_name" => "nginx_passenger",
54
+ "ssh_username" => "deploy",
55
+ "ssh_password" => "12345678",
56
+ "db_stack_name" => options[:db_stack_name] || "mysql",
57
+ "db_host" => "localhost"
58
+ }
59
+ }
60
+ }.to_json
61
+ end
62
+ def dna_instances_for(cluster_type = :solo)
63
+ case cluster_type
64
+ when :solo
65
+ [{
66
+ "public_hostname" => "solo.compute-1.amazonaws.com",
67
+ "role" => "solo",
68
+ "private_hostname" => "solo.compute-1.internal"
69
+ }]
70
+ when :slaves
71
+ [
72
+ {
73
+ "public_hostname" => "app_master.compute-1.amazonaws.com",
74
+ "role" => "app_master",
75
+ "private_hostname" => "app_master.ec2.internal"
76
+ },
77
+ {
78
+ "public_hostname" => "db_master.compute-1.amazonaws.com",
79
+ "role" => "db_master",
80
+ "private_hostname" => "db_master.ec2.internal"
81
+ },
82
+ {
83
+ "public_hostname" => "db_slave1.compute-1.amazonaws.com",
84
+ "role" => "db_slave",
85
+ "private_hostname" => "db_slave1.ec2.internal",
86
+ },
87
+ {
88
+ "public_hostname" => "db_slave2.compute-1.amazonaws.com",
89
+ "role" => "db_slave",
90
+ "private_hostname" => "db_slave2.ec2.internal",
91
+ }
92
+ ]
93
+ end
94
+ end
95
+
35
96
  Spec::Runner.configure do |config|
36
97
  config.before(:all) do
37
98
  EY::Serverside.dna_json = {}.to_json
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1757219187
4
+ hash: 961916008
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 3
10
- - nodestack
11
- version: 1.4.3.nodestack
9
+ - 7
10
+ - pre
11
+ version: 1.4.7.pre
12
12
  platform: ruby
13
13
  authors:
14
14
  - EY Cloud Team
@@ -16,9 +16,40 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-31 00:00:00 Z
20
- dependencies: []
21
-
19
+ date: 2011-09-07 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ hash: 49
28
+ segments:
29
+ - 0
30
+ - 8
31
+ - 7
32
+ version: 0.8.7
33
+ version_requirements: *id001
34
+ name: rake
35
+ type: :development
36
+ prerelease: false
37
+ - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 1
46
+ - 3
47
+ - 0
48
+ version: 1.3.0
49
+ version_requirements: *id002
50
+ name: rspec
51
+ type: :development
52
+ prerelease: false
22
53
  description:
23
54
  email: cloud@engineyard.com
24
55
  executables:
@@ -29,6 +60,8 @@ extra_rdoc_files: []
29
60
 
30
61
  files:
31
62
  - bin/engineyard-serverside
63
+ - lib/core-ext/README.md
64
+ - lib/core-ext/string.rb
32
65
  - lib/engineyard-serverside/bundle_installer.rb
33
66
  - lib/engineyard-serverside/cli.rb
34
67
  - lib/engineyard-serverside/configuration.rb
@@ -199,6 +232,7 @@ files:
199
232
  - lib/vendor/json_pure/tools/server.rb
200
233
  - lib/vendor/json_pure/VERSION
201
234
  - lib/vendor/open4/lib/open4.rb
235
+ - lib/vendor/ruby_1.8.6_openssl.patch
202
236
  - lib/vendor/thor/bin/rake2thor
203
237
  - lib/vendor/thor/bin/thor
204
238
  - lib/vendor/thor/CHANGELOG.rdoc
@@ -237,12 +271,28 @@ files:
237
271
  - spec/custom_deploy_spec.rb
238
272
  - spec/deploy_hook_spec.rb
239
273
  - spec/deprecation_spec.rb
240
- - spec/fixtures/gitrepo/bar
274
+ - spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile
275
+ - spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile.lock
276
+ - spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile
277
+ - spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile.lock
278
+ - spec/fixtures/gemfiles/activerecord_mysql/Gemfile
279
+ - spec/fixtures/gemfiles/activerecord_mysql/Gemfile.lock
280
+ - spec/fixtures/gemfiles/activerecord_mysql2/Gemfile
281
+ - spec/fixtures/gemfiles/activerecord_mysql2/Gemfile.lock
282
+ - spec/fixtures/gemfiles/activerecord_pg/Gemfile
283
+ - spec/fixtures/gemfiles/activerecord_pg/Gemfile.lock
284
+ - spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile
285
+ - spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile.lock
286
+ - spec/fixtures/gemfiles/diy_database_yml/config/database.yml
287
+ - spec/fixtures/gemfiles/diy_database_yml/Gemfile
288
+ - spec/fixtures/gemfiles/diy_database_yml/Gemfile.lock
241
289
  - spec/fixtures/gitrepo/foo
242
290
  - spec/fixtures/gitrepo.tar.gz
243
291
  - spec/fixtures/invalid_hook.rb
244
292
  - spec/fixtures/valid_hook.rb
293
+ - spec/generate_configs_spec.rb
245
294
  - spec/git_strategy_spec.rb
295
+ - spec/lib/full_test_deploy.rb
246
296
  - spec/lockfile_parser_spec.rb
247
297
  - spec/real_deploy_spec.rb
248
298
  - spec/restart_spec.rb
@@ -296,12 +346,28 @@ test_files:
296
346
  - spec/custom_deploy_spec.rb
297
347
  - spec/deploy_hook_spec.rb
298
348
  - spec/deprecation_spec.rb
299
- - spec/fixtures/gitrepo/bar
349
+ - spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile
350
+ - spec/fixtures/gemfiles/activerecord_jdbcmysql/Gemfile.lock
351
+ - spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile
352
+ - spec/fixtures/gemfiles/activerecord_jdbcpostgresql/Gemfile.lock
353
+ - spec/fixtures/gemfiles/activerecord_mysql/Gemfile
354
+ - spec/fixtures/gemfiles/activerecord_mysql/Gemfile.lock
355
+ - spec/fixtures/gemfiles/activerecord_mysql2/Gemfile
356
+ - spec/fixtures/gemfiles/activerecord_mysql2/Gemfile.lock
357
+ - spec/fixtures/gemfiles/activerecord_pg/Gemfile
358
+ - spec/fixtures/gemfiles/activerecord_pg/Gemfile.lock
359
+ - spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile
360
+ - spec/fixtures/gemfiles/activerecord_sqlite3/Gemfile.lock
361
+ - spec/fixtures/gemfiles/diy_database_yml/config/database.yml
362
+ - spec/fixtures/gemfiles/diy_database_yml/Gemfile
363
+ - spec/fixtures/gemfiles/diy_database_yml/Gemfile.lock
300
364
  - spec/fixtures/gitrepo/foo
301
365
  - spec/fixtures/gitrepo.tar.gz
302
366
  - spec/fixtures/invalid_hook.rb
303
367
  - spec/fixtures/valid_hook.rb
368
+ - spec/generate_configs_spec.rb
304
369
  - spec/git_strategy_spec.rb
370
+ - spec/lib/full_test_deploy.rb
305
371
  - spec/lockfile_parser_spec.rb
306
372
  - spec/real_deploy_spec.rb
307
373
  - spec/restart_spec.rb
File without changes