engineyard-serverside 1.5.27.pre3 → 1.5.27.pre4

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.
@@ -32,6 +32,7 @@ module EY
32
32
  setup_services
33
33
  check_for_ey_config
34
34
  symlink_configs
35
+ setup_sqlite3_if_necessary
35
36
  conditionally_enable_maintenance_page
36
37
  run_with_callbacks(:migrate)
37
38
  run_with_callbacks(:compile_assets) # defined in RailsAssetSupport
@@ -323,6 +324,33 @@ Deploy again if your services configuration appears incomplete or out of date.
323
324
  end
324
325
  end
325
326
 
327
+ def setup_sqlite3_if_necessary
328
+ if gemfile? && lockfile && lockfile.uses_sqlite3?
329
+ [
330
+ ["Create databases directory if needed", "mkdir -p #{c.shared_path}/databases"],
331
+ ["Creating SQLite database if needed", "touch #{c.shared_path}/databases/#{c.framework_env}.sqlite3"],
332
+ ["Create config directory if needed", "mkdir -p #{c.release_path}/config"],
333
+ ["Generating SQLite config", <<-WRAP],
334
+ cat > #{c.shared_path}/config/database.sqlite3.yml<<'YML'
335
+ #{c.framework_env}:
336
+ adapter: sqlite3
337
+ database: #{c.shared_path}/databases/#{c.framework_env}.sqlite3
338
+ pool: 5
339
+ timeout: 5000
340
+ YML
341
+ WRAP
342
+ ["Symlink database.yml", "ln -nfs #{c.shared_path}/config/database.sqlite3.yml #{c.release_path}/config/database.yml"],
343
+ ].each do |what, cmd|
344
+ info "~> #{what}"
345
+ run(cmd)
346
+ end
347
+
348
+ owner = [c.user, c.group].join(':')
349
+ info "~> Setting ownership to #{owner}"
350
+ sudo "chown -R #{owner} #{c.release_path}"
351
+ end
352
+ end
353
+
326
354
  def symlink_configs(release_to_link=c.release_path)
327
355
  info "~> Preparing shared resources for release."
328
356
  symlink_tasks(release_to_link).each do |what, cmd|
@@ -31,6 +31,10 @@ module EY
31
31
  any_ruby_adapter || any_jruby_adapter
32
32
  end
33
33
 
34
+ def uses_sqlite3?
35
+ !any_database_adapter? && @contents.index(/^\s+sqlite3\s\([^\)]+\)$/)
36
+ end
37
+
34
38
  def parse
35
39
  parse_from_metadata ||
36
40
  parse_from_dependencies ||
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module Serverside
3
- VERSION = '1.5.27.pre3'
3
+ VERSION = '1.5.27.pre4'
4
4
  end
5
5
  end
@@ -91,4 +91,3 @@ module Celluloid
91
91
  end
92
92
  end
93
93
  end
94
-
@@ -1,11 +1,11 @@
1
1
  module Celluloid
2
2
  # Exceptional system events which need to be processed out of band
3
3
  class SystemEvent < Exception; end
4
-
4
+
5
5
  # An actor has exited for the given reason
6
6
  class ExitEvent < SystemEvent
7
7
  attr_reader :actor, :reason
8
-
8
+
9
9
  def initialize(actor, reason = nil)
10
10
  @actor, @reason = actor, reason
11
11
  super reason.to_s
@@ -2,15 +2,15 @@ module Celluloid
2
2
  # Responses to calls
3
3
  class Response
4
4
  attr_reader :call_id, :value
5
-
5
+
6
6
  def initialize(call_id, value)
7
7
  @call_id, @value = call_id, value
8
8
  end
9
9
  end
10
-
10
+
11
11
  # Call completed successfully
12
12
  class SuccessResponse < Response; end
13
-
13
+
14
14
  # Call was aborted due to caller error
15
15
  class ErrorResponse < Response
16
16
  def value
@@ -4,7 +4,7 @@ describe "Deploying an application without Bundler" do
4
4
  before(:all) do
5
5
  $DISABLE_GEMFILE = true # Don't generate Gemfile/Gemfile.lock
6
6
  $DISABLE_LOCKFILE = true
7
- @deploy_dir = Pathname.new(Dir.mktmpdir("serverside-deploy-#{Time.now.to_i}-#{$$}"))
7
+ @deploy_dir = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}")
8
8
 
9
9
  # set up EY::Serverside::Server like we're on a solo
10
10
  EY::Serverside::Server.reset
@@ -7,7 +7,7 @@ describe "Deploying an application that uses Bundler" do
7
7
  end
8
8
 
9
9
  def deploy_test_application
10
- @deploy_dir = Dir.mktmpdir("serverside-deploy-#{Time.now.to_i}-#{$$}")
10
+ @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
11
11
 
12
12
  # set up EY::Serverside::Server like we're on a solo
13
13
  EY::Serverside::Server.reset
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.1.3'
4
+ gem 'sqlite3'
@@ -0,0 +1,89 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.3)
5
+ actionpack (= 3.1.3)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.3)
8
+ activemodel (= 3.1.3)
9
+ activesupport (= 3.1.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.5)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.3)
18
+ activemodel (3.1.3)
19
+ activesupport (= 3.1.3)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.3)
23
+ activemodel (= 3.1.3)
24
+ activesupport (= 3.1.3)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.3)
28
+ activemodel (= 3.1.3)
29
+ activesupport (= 3.1.3)
30
+ activesupport (3.1.3)
31
+ multi_json (~> 1.0)
32
+ arel (2.2.1)
33
+ builder (3.0.0)
34
+ erubis (2.7.0)
35
+ hike (1.2.1)
36
+ i18n (0.6.0)
37
+ json (1.6.5)
38
+ mail (2.3.0)
39
+ i18n (>= 0.4.0)
40
+ mime-types (~> 1.16)
41
+ treetop (~> 1.4.8)
42
+ mime-types (1.17.2)
43
+ multi_json (1.0.4)
44
+ polyglot (0.3.3)
45
+ rack (1.3.6)
46
+ rack-cache (1.1)
47
+ rack (>= 0.4)
48
+ rack-mount (0.8.3)
49
+ rack (>= 1.0.0)
50
+ rack-ssl (1.3.2)
51
+ rack
52
+ rack-test (0.6.1)
53
+ rack (>= 1.0)
54
+ rails (3.1.3)
55
+ actionmailer (= 3.1.3)
56
+ actionpack (= 3.1.3)
57
+ activerecord (= 3.1.3)
58
+ activeresource (= 3.1.3)
59
+ activesupport (= 3.1.3)
60
+ bundler (~> 1.0)
61
+ railties (= 3.1.3)
62
+ railties (3.1.3)
63
+ actionpack (= 3.1.3)
64
+ activesupport (= 3.1.3)
65
+ rack-ssl (~> 1.3.2)
66
+ rake (>= 0.8.7)
67
+ rdoc (~> 3.4)
68
+ thor (~> 0.14.6)
69
+ rake (0.9.2.2)
70
+ rdoc (3.12)
71
+ json (~> 1.4)
72
+ sprockets (2.0.3)
73
+ hike (~> 1.2)
74
+ rack (~> 1.0)
75
+ tilt (~> 1.1, != 1.3.0)
76
+ sqlite3 (1.3.5)
77
+ thor (0.14.6)
78
+ tilt (1.3.3)
79
+ treetop (1.4.10)
80
+ polyglot
81
+ polyglot (>= 0.3.1)
82
+ tzinfo (0.3.31)
83
+
84
+ PLATFORMS
85
+ ruby
86
+
87
+ DEPENDENCIES
88
+ rails (= 3.1.3)
89
+ sqlite3
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe "Deploying an application that uses Node.js and NPM" do
4
4
  def deploy_test_application
5
- @deploy_dir = Dir.mktmpdir( "serverside-deploy-#{Time.now.to_i}-#{$$}")
5
+ @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
6
6
 
7
7
  # set up EY::Serverside::Server like we're on a solo
8
8
  EY::Serverside::Server.reset
@@ -1,62 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Deploying a Rails 3.1 application" do
4
- def deploy_test_application(assets_enabled = true, &block)
5
- $DISABLE_GEMFILE = false
6
- $DISABLE_LOCKFILE = false
7
- @deploy_dir = Dir.mktmpdir("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
-
13
- # run a deploy
14
- @config = EY::Serverside::Deploy::Configuration.new({
15
- "strategy" => "IntegrationSpec",
16
- "deploy_to" => @deploy_dir,
17
- "group" => `id -gn`.strip,
18
- "stack" => 'nginx_passenger',
19
- "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
20
- 'app' => 'rails31',
21
- 'framework_env' => 'staging'
22
- })
23
-
24
- # pretend there is a shared bundled_gems directory
25
- FileUtils.mkdir_p(File.join(@deploy_dir, 'shared', 'bundled_gems'))
26
- %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
27
- File.open(File.join(@deploy_dir, 'shared', 'bundled_gems', name), "w") { |f| f.write("old\n") }
28
- end
29
-
30
- # Set up the application directory to have the requested asset options.
31
- prepare_rails31_app(assets_enabled)
32
-
33
- @binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
34
- @deployer = FullTestDeploy.new(@config)
35
- @deployer.deploy(&block)
36
- end
37
-
38
- def prepare_rails31_app(assets_enabled)
39
- FileUtils.mkdir_p(File.join(@config.release_path, 'config'))
40
- app_rb = File.join(@config.release_path, 'config', 'application.rb')
41
- app_rb_contents = <<-EOF
42
- module Rails31
43
- class Application < Rails::Application
44
- config.assets.enabled = #{assets_enabled ? 'true' : 'false'}
45
- end
46
- end
47
- EOF
48
- File.open(app_rb, 'w') {|f| f.write(app_rb_contents)}
49
- rakefile = File.join(@config.release_path, 'Rakefile')
50
- rakefile_contents = <<-EOF
51
- desc 'Precompile yar assetz'
52
- task 'assets:precompile' do
53
- sh 'touch precompiled'
54
- end
55
- EOF
56
- File.open(rakefile, 'w') {|f| f.write(rakefile_contents)}
57
- FileUtils.mkdir_p(File.join(@config.release_path, 'app', 'assets'))
58
- end
59
-
60
4
  context "with default production settings" do
61
5
  before(:all) do
62
6
  deploy_test_application
@@ -4,7 +4,7 @@ describe "Deploying an application with services" do
4
4
  before(:each) do
5
5
  #$DISABLE_GEMFILE = true # Don't generate Gemfile/Gemfile.lock
6
6
  #$DISABLE_LOCKFILE = true
7
- @deploy_dir = Pathname.new(Dir.mktmpdir("serverside-deploy-#{Time.now.to_i}-#{$$}"))
7
+ @deploy_dir = Pathname.new(Dir.tmpdir).join("serverside-deploy-#{Time.now.to_i}-#{$$}")
8
8
 
9
9
  # set up EY::Serverside::Server like we're on a solo
10
10
  EY::Serverside::Server.reset
data/spec/spec_helper.rb CHANGED
@@ -75,4 +75,60 @@ Spec::Runner.configure do |config|
75
75
  $DISABLE_LOCKFILE = false
76
76
  EY::Serverside.dna_json = {}.to_json
77
77
  end
78
+
79
+ def deploy_test_application(assets_enabled = true, &block)
80
+ $DISABLE_GEMFILE = false
81
+ $DISABLE_LOCKFILE = false
82
+ @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
83
+
84
+ # set up EY::Serverside::Server like we're on a solo
85
+ EY::Serverside::Server.reset
86
+ EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
87
+
88
+ # run a deploy
89
+ @config = EY::Serverside::Deploy::Configuration.new({
90
+ "strategy" => "IntegrationSpec",
91
+ "deploy_to" => @deploy_dir,
92
+ "group" => `id -gn`.strip,
93
+ "stack" => 'nginx_passenger',
94
+ "migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
95
+ 'app' => 'rails31',
96
+ 'framework_env' => 'staging'
97
+ })
98
+
99
+ # pretend there is a shared bundled_gems directory
100
+ FileUtils.mkdir_p(File.join(@deploy_dir, 'shared', 'bundled_gems'))
101
+ %w(RUBY_VERSION SYSTEM_VERSION).each do |name|
102
+ File.open(File.join(@deploy_dir, 'shared', 'bundled_gems', name), "w") { |f| f.write("old\n") }
103
+ end
104
+
105
+ # Set up the application directory to have the requested asset options.
106
+ prepare_rails31_app(assets_enabled)
107
+
108
+ @binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
109
+ @deployer = FullTestDeploy.new(@config)
110
+ @deployer.deploy(&block)
111
+ end
112
+
113
+ def prepare_rails31_app(assets_enabled)
114
+ FileUtils.mkdir_p(File.join(@config.release_path, 'config'))
115
+ app_rb = File.join(@config.release_path, 'config', 'application.rb')
116
+ app_rb_contents = <<-EOF
117
+ module Rails31
118
+ class Application < Rails::Application
119
+ config.assets.enabled = #{assets_enabled ? 'true' : 'false'}
120
+ end
121
+ end
122
+ EOF
123
+ File.open(app_rb, 'w') {|f| f.write(app_rb_contents)}
124
+ rakefile = File.join(@config.release_path, 'Rakefile')
125
+ rakefile_contents = <<-EOF
126
+ desc 'Precompile yar assetz'
127
+ task 'assets:precompile' do
128
+ sh 'touch precompiled'
129
+ end
130
+ EOF
131
+ File.open(rakefile, 'w') {|f| f.write(rakefile_contents)}
132
+ FileUtils.mkdir_p(File.join(@config.release_path, 'app', 'assets'))
133
+ end
78
134
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Deploying an application with sqlite3 as the only DB adapter in the Gemfile.lock" do
4
+ before do
5
+ @release_path = nil
6
+ @shared_path = nil
7
+ @framework_env = nil
8
+
9
+ deploy_test_application do |deployer|
10
+ gemfile = File.expand_path('../fixtures/gemfiles/1.0.21-rails-31-with-sqlite', __FILE__)
11
+ lockfile = File.expand_path('../fixtures/lockfiles/1.0.21-rails-31-with-sqlite', __FILE__)
12
+ deployer.gemfile_contents = File.read(gemfile)
13
+ deployer.lockfile_contents = File.read(lockfile)
14
+
15
+ @shared_path = deployer.shared_path
16
+ @release_path = deployer.release_path
17
+ @framework_env = deployer.framework_env
18
+ end
19
+ end
20
+
21
+
22
+ it 'should symlink database.sqlite3.yml' do
23
+ File.exist?(File.join(@release_path, 'config', 'database.yml')).should be_true
24
+ end
25
+
26
+ it 'should create database.sqlite3.yml in a shared location' do
27
+ File.exist?(File.join(@shared_path, 'config', 'database.sqlite3.yml')).should be_true
28
+ end
29
+
30
+ it 'should put a reference to a shared database in database.sqlite3.yml' do
31
+ contents = File.read(File.join(@release_path, 'config', 'database.yml'))
32
+ contents.should include(File.expand_path(File.join(@shared_path, 'databases', "#{@framework_env}.sqlite3")))
33
+ end
34
+
35
+ it 'should create the shared database' do
36
+ File.exist?(File.join(@shared_path, 'databases', "#{@framework_env}.sqlite3")).should be_true
37
+ end
38
+
39
+ end
@@ -66,7 +66,7 @@ class FullTestDeploy < EY::Serverside::Deploy
66
66
  end
67
67
 
68
68
  def deploy
69
- yield if block_given?
69
+ yield(self) if block_given?
70
70
  super
71
71
  end
72
72
 
@@ -99,6 +99,7 @@ end
99
99
  module EY::Serverside::Strategies::IntegrationSpec
100
100
  module Helpers
101
101
 
102
+
102
103
  def update_repository_cache
103
104
  cached_copy = c.repository_cache
104
105
 
@@ -120,6 +121,18 @@ module EY::Serverside::Strategies::IntegrationSpec
120
121
  generate_gemfile_in(cached_copy)
121
122
  end
122
123
 
124
+ def release_path
125
+ c.release_path
126
+ end
127
+
128
+ def shared_path
129
+ c.shared_path
130
+ end
131
+
132
+ def framework_env
133
+ c.framework_env
134
+ end
135
+
123
136
  def create_revision_file_command
124
137
  "echo 'revision, yo' > #{c.release_path}/REVISION"
125
138
  end
@@ -128,6 +141,10 @@ module EY::Serverside::Strategies::IntegrationSpec
128
141
  "FONDLED THE CODE"
129
142
  end
130
143
 
144
+ def gemfile_contents=(contents)
145
+ @gemfile_contents = contents
146
+ end
147
+
131
148
  def gemfile_contents
132
149
  @gemfile_contents || <<-EOF
133
150
  source :rubygems
@@ -137,7 +154,12 @@ gem 'ey_config'
137
154
  EOF
138
155
  end
139
156
 
157
+ def lockfile_contents=(contents)
158
+ @lockfile_contents = contents
159
+ end
160
+
140
161
  # Generated using Bundler v1.0.21
162
+
141
163
  def lockfile_contents
142
164
  @lockfile_contents || <<-EOF
143
165
  GEM
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: 2511085049
4
+ hash: 2326528959
5
5
  prerelease: 7
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 27
10
10
  - pre
11
- - 3
12
- version: 1.5.27.pre3
11
+ - 4
12
+ version: 1.5.27.pre4
13
13
  platform: ruby
14
14
  authors:
15
15
  - EY Cloud Team
@@ -327,6 +327,7 @@ files:
327
327
  - spec/custom_deploy_spec.rb
328
328
  - spec/deploy_hook_spec.rb
329
329
  - spec/deprecation_spec.rb
330
+ - spec/fixtures/gemfiles/1.0.21-rails-31-with-sqlite
330
331
  - spec/fixtures/gitrepo/foo
331
332
  - spec/fixtures/gitrepo.tar.gz
332
333
  - spec/fixtures/invalid_hook.rb
@@ -339,6 +340,7 @@ files:
339
340
  - spec/fixtures/lockfiles/1.0.18-mysql
340
341
  - spec/fixtures/lockfiles/1.0.18-mysql2
341
342
  - spec/fixtures/lockfiles/1.0.18-pg
343
+ - spec/fixtures/lockfiles/1.0.21-rails-31-with-sqlite
342
344
  - spec/fixtures/lockfiles/1.0.6-no-bundler
343
345
  - spec/fixtures/lockfiles/1.0.6-with-any-bundler
344
346
  - spec/fixtures/lockfiles/1.0.6-with-bundler
@@ -353,6 +355,7 @@ files:
353
355
  - spec/server_spec.rb
354
356
  - spec/services_deploy_spec.rb
355
357
  - spec/spec_helper.rb
358
+ - spec/sqlite3_deploy_spec.rb
356
359
  - spec/support/integration.rb
357
360
  homepage: http://github.com/engineyard/engineyard-serverside
358
361
  licenses: []
@@ -395,6 +398,7 @@ test_files:
395
398
  - spec/custom_deploy_spec.rb
396
399
  - spec/deploy_hook_spec.rb
397
400
  - spec/deprecation_spec.rb
401
+ - spec/fixtures/gemfiles/1.0.21-rails-31-with-sqlite
398
402
  - spec/fixtures/gitrepo/foo
399
403
  - spec/fixtures/gitrepo.tar.gz
400
404
  - spec/fixtures/invalid_hook.rb
@@ -407,6 +411,7 @@ test_files:
407
411
  - spec/fixtures/lockfiles/1.0.18-mysql
408
412
  - spec/fixtures/lockfiles/1.0.18-mysql2
409
413
  - spec/fixtures/lockfiles/1.0.18-pg
414
+ - spec/fixtures/lockfiles/1.0.21-rails-31-with-sqlite
410
415
  - spec/fixtures/lockfiles/1.0.6-no-bundler
411
416
  - spec/fixtures/lockfiles/1.0.6-with-any-bundler
412
417
  - spec/fixtures/lockfiles/1.0.6-with-bundler
@@ -421,4 +426,5 @@ test_files:
421
426
  - spec/server_spec.rb
422
427
  - spec/services_deploy_spec.rb
423
428
  - spec/spec_helper.rb
429
+ - spec/sqlite3_deploy_spec.rb
424
430
  - spec/support/integration.rb