engineyard-serverside 2.0.7 → 2.1.0.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 (98) hide show
  1. data/lib/engineyard-serverside.rb +0 -1
  2. data/lib/engineyard-serverside/cli.rb +44 -42
  3. data/lib/engineyard-serverside/configuration.rb +55 -4
  4. data/lib/engineyard-serverside/dependency_manager.rb +17 -0
  5. data/lib/engineyard-serverside/dependency_manager/base.rb +65 -0
  6. data/lib/engineyard-serverside/dependency_manager/bundler.rb +124 -0
  7. data/lib/engineyard-serverside/dependency_manager/bundler_lock.rb +155 -0
  8. data/lib/engineyard-serverside/dependency_manager/legacy_helpers.rb +24 -0
  9. data/lib/engineyard-serverside/dependency_manager/npm.rb +16 -0
  10. data/lib/engineyard-serverside/deploy.rb +86 -178
  11. data/lib/engineyard-serverside/deprecation.rb +11 -1
  12. data/lib/engineyard-serverside/paths.rb +6 -0
  13. data/lib/engineyard-serverside/propagator.rb +2 -2
  14. data/lib/engineyard-serverside/rails_assets.rb +152 -0
  15. data/lib/engineyard-serverside/rails_assets/strategy.rb +197 -0
  16. data/lib/engineyard-serverside/server.rb +5 -0
  17. data/lib/engineyard-serverside/servers.rb +19 -7
  18. data/lib/engineyard-serverside/shell.rb +7 -5
  19. data/lib/engineyard-serverside/shell/command_result.rb +1 -1
  20. data/lib/engineyard-serverside/strategies/git.rb +14 -4
  21. data/lib/engineyard-serverside/task.rb +1 -0
  22. data/lib/engineyard-serverside/version.rb +1 -1
  23. data/spec/bundler_deploy_spec.rb +36 -33
  24. data/spec/configuration_spec.rb +5 -4
  25. data/spec/custom_deploy_spec.rb +11 -9
  26. data/spec/deploy_hook_spec.rb +10 -3
  27. data/spec/ey_yml_customized_deploy_spec.rb +1 -1
  28. data/spec/fixtures/lockfiles/1.0-no-bundler +1 -1
  29. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +1 -1
  30. data/spec/fixtures/lockfiles/1.0.18-do_mysql +1 -1
  31. data/spec/fixtures/lockfiles/1.0.18-do_postgres +1 -1
  32. data/spec/fixtures/lockfiles/1.0.18-mysql +1 -1
  33. data/spec/fixtures/lockfiles/1.0.18-mysql2 +1 -1
  34. data/spec/fixtures/lockfiles/1.0.18-pg +1 -1
  35. data/spec/fixtures/lockfiles/1.0.6-no-bundler +2 -2
  36. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +2 -2
  37. data/spec/fixtures/lockfiles/1.0.6-with-bundler +2 -2
  38. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +112 -0
  39. data/spec/fixtures/repos/{assets_enabled → assets_detected}/Gemfile +1 -2
  40. data/spec/fixtures/repos/{assets_enabled → assets_detected}/Gemfile.lock +1 -3
  41. data/spec/fixtures/repos/{assets_enabled → assets_detected}/README +0 -0
  42. data/spec/fixtures/repos/assets_detected/Rakefile +5 -0
  43. data/spec/fixtures/repos/{assets_enabled → assets_detected}/app/assets/empty +0 -0
  44. data/spec/fixtures/repos/{assets_enabled → assets_detected}/config/application.rb +0 -0
  45. data/spec/fixtures/repos/assets_detected/config/ey.yml +3 -0
  46. data/spec/fixtures/repos/assets_disabled/Gemfile +1 -2
  47. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +1 -3
  48. data/spec/fixtures/repos/assets_disabled/Rakefile +1 -0
  49. data/spec/fixtures/repos/assets_disabled/config/ey.yml +3 -0
  50. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +1 -2
  51. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +1 -3
  52. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +1 -0
  53. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +1 -0
  54. data/spec/fixtures/repos/assets_enabled_all/Gemfile +1 -2
  55. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +1 -3
  56. data/spec/fixtures/repos/assets_enabled_all/Rakefile +1 -0
  57. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +1 -0
  58. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +1 -1
  59. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +1 -1
  60. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +1 -0
  61. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +1 -2
  62. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +1 -3
  63. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +1 -0
  64. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +1 -0
  65. data/spec/fixtures/repos/assets_in_hook/Gemfile +1 -2
  66. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +1 -3
  67. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +3 -0
  68. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +1 -1
  69. data/spec/fixtures/repos/bundle_fails/Gemfile +1 -0
  70. data/spec/fixtures/repos/bundle_fails/README +1 -0
  71. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +1 -0
  72. data/spec/fixtures/repos/default/Gemfile +1 -2
  73. data/spec/fixtures/repos/default/Gemfile.lock +1 -3
  74. data/spec/fixtures/repos/default/ey.yml +3 -0
  75. data/spec/fixtures/repos/ey_yml/Gemfile +1 -1
  76. data/spec/fixtures/repos/ey_yml/Gemfile.lock +1 -1
  77. data/spec/fixtures/repos/ey_yml/config/ey.yml +11 -7
  78. data/spec/fixtures/repos/ey_yml_alt/Gemfile +1 -1
  79. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +1 -1
  80. data/spec/fixtures/repos/no_ey_config/Gemfile +1 -2
  81. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +1 -3
  82. data/spec/fixtures/repos/no_ey_config/ey.yml +3 -0
  83. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +1 -2
  84. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +3 -0
  85. data/spec/fixtures/repos/sqlite3/Gemfile +1 -1
  86. data/spec/fixtures/repos/sqlite3/Gemfile.lock +1 -1
  87. data/spec/lockfile_parser_spec.rb +25 -11
  88. data/spec/rails31_deploy_spec.rb +46 -5
  89. data/spec/restart_spec.rb +3 -3
  90. data/spec/services_deploy_spec.rb +89 -86
  91. data/spec/shell_spec.rb +0 -8
  92. data/spec/spec_helper.rb +81 -36
  93. data/spec/sqlite3_deploy_spec.rb +4 -5
  94. data/spec/support/integration.rb +22 -37
  95. metadata +167 -154
  96. data/lib/engineyard-serverside/lockfile_parser.rb +0 -101
  97. data/lib/engineyard-serverside/rails_asset_support.rb +0 -132
  98. data/spec/fixtures/repos/assets_enabled/Rakefile +0 -5
@@ -0,0 +1 @@
1
+ This repo has a bad Gemfile in it and no remote sources.
@@ -0,0 +1 @@
1
+ run 'touch after_bundle.ran'
@@ -1,5 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'pg'
5
4
  gem 'ey_config'
@@ -1,8 +1,7 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  ey_config (0.0.5)
5
- pg (0.13.2)
6
5
  rake (0.9.2.2)
7
6
 
8
7
  PLATFORMS
@@ -10,5 +9,4 @@ PLATFORMS
10
9
 
11
10
  DEPENDENCIES
12
11
  ey_config
13
- pg
14
12
  rake
@@ -0,0 +1,3 @@
1
+ environments:
2
+ env:
3
+ ignore_database_adapter_warning: true
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
  gem 'ey_config'
@@ -1,5 +1,5 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  ey_config (0.0.5)
5
5
  rake (0.9.2.2)
@@ -1,13 +1,17 @@
1
+ defaults:
2
+ copy_exclude:
3
+ - .git
4
+ - README
5
+ migrate: true
6
+ migration_command: 'uh oh'
7
+ bundle_without: only test development
8
+ maintenance_on_migrate: false
9
+ maintenance_on_restart: false
1
10
  environments:
2
11
  env:
3
- copy_exclude:
4
- - .git
5
- - README
6
- migrate: true
7
- migration_command: 'uh oh'
8
12
  branch: branch_from_ey_yml
9
13
  custom: custom_from_ey_yml
10
14
  bundle_without: only test
11
- maintenance_on_migrate: false
12
- maintenance_on_restart: false
13
15
  ignore_database_adapter_warning: true
16
+ env_other:
17
+ bundle_without: only development
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
  gem 'ey_config'
@@ -1,5 +1,5 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  ey_config (0.0.5)
5
5
  rake (0.9.2.2)
@@ -1,4 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'pg'
@@ -1,12 +1,10 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- pg (0.11.0)
5
4
  rake (0.9.2.2)
6
5
 
7
6
  PLATFORMS
8
7
  ruby
9
8
 
10
9
  DEPENDENCIES
11
- pg
12
10
  rake
@@ -0,0 +1,3 @@
1
+ environments:
2
+ env:
3
+ ignore_database_adapter_warning: true
@@ -1,5 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'pg'
5
4
  gem 'ey_config'
@@ -0,0 +1,3 @@
1
+ environments:
2
+ env:
3
+ ignore_database_adapter_warning: true
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '3.1.3'
4
4
  gem 'sqlite3'
@@ -1,5 +1,5 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  actionmailer (3.1.3)
5
5
  actionpack (= 3.1.3)
@@ -6,7 +6,7 @@ describe "the bundler version retrieved from the lockfile" do
6
6
  end
7
7
 
8
8
  def get_parser(file)
9
- EY::Serverside::LockfileParser.new(load_lockfile(file))
9
+ EY::Serverside::DependencyManager::BundlerLock::Lockfile.new(load_lockfile(file))
10
10
  end
11
11
 
12
12
  def get_version(file)
@@ -19,12 +19,12 @@ describe "the bundler version retrieved from the lockfile" do
19
19
  end
20
20
 
21
21
  it "has a default version" do
22
- EY::Serverside::LockfileParser.default_version.should == "1.1.5"
23
- EY::Serverside::LockfileParser::DEFAULT.should == "1.1.5"
22
+ EY::Serverside::DependencyManager::Bundler.default_version.should_not be_nil
23
+ EY::Serverside::DependencyManager::Bundler::DEFAULT_VERSION.should_not be_nil
24
24
  end
25
25
 
26
26
  it "returns the default version for a 1.0 lockfile without a bundler dependency" do
27
- get_version('1.0-no-bundler').should == EY::Serverside::LockfileParser::DEFAULT
27
+ get_version('1.0-no-bundler').should == EY::Serverside::DependencyManager::Bundler.default_version
28
28
  end
29
29
 
30
30
  it "gets the version from a 1.0.0.rc.1 lockfile w/dependency on 1.0.0.rc.1" do
@@ -47,6 +47,16 @@ describe "the bundler version retrieved from the lockfile" do
47
47
  lambda { get_version('not-a-lockfile') }.should raise_error(RuntimeError, /Malformed or pre bundler-1.0.0 Gemfile.lock/)
48
48
  end
49
49
 
50
+ context "rails version" do
51
+ it "retrieves rails version" do
52
+ get_parser('1.3.1-rails-3.2.13').rails_version.should == "3.2.13"
53
+ end
54
+
55
+ it "finds no rails version" do
56
+ get_parser('1.0.18-mysql2').rails_version.should == nil
57
+ end
58
+ end
59
+
50
60
  context "checking for gems in the dependencies" do
51
61
  it "does not have any database adapters in a gemfile lock without them" do
52
62
  get_parser('1.0.6-no-bundler').any_database_adapter?.should be_false
@@ -77,31 +87,35 @@ describe "the bundler version retrieved from the lockfile" do
77
87
  subject { get_parser('1.0.6-no-bundler') }
78
88
 
79
89
  it "uses the default version when there is no bundler version" do
80
- subject.fetch_version(nil, nil).should == EY::Serverside::LockfileParser::DEFAULT
90
+ subject.fetch_version(nil, nil).should == EY::Serverside::DependencyManager::Bundler.default_version
91
+ end
92
+
93
+ it "uses the given version when there is no operator" do
94
+ subject.fetch_version(nil, '1.0.1').should == '1.0.1'
81
95
  end
82
96
 
83
97
  it "uses the given version when the qualifier is `='" do
84
- subject.fetch_version('1.0.1', '=').should == '1.0.1'
98
+ subject.fetch_version('=', '1.0.1').should == '1.0.1'
85
99
  end
86
100
 
87
101
  it "uses the default version when we get a pessimistic qualifier and is lower than the default version" do
88
- subject.fetch_version('1.1.1', '~>').should == EY::Serverside::LockfileParser::DEFAULT
102
+ subject.fetch_version('~>', '1.3.1').should == EY::Serverside::DependencyManager::Bundler.default_version
89
103
  end
90
104
 
91
105
  it "uses the given version when we get a pessimistic qualifier that doesn't match the default version" do
92
- subject.fetch_version('1.0.0', '~>').should == '1.0.0'
106
+ subject.fetch_version('~>', '1.0.0').should == '1.0.0'
93
107
  end
94
108
 
95
109
  it "uses the given version when it's geater of equal than the default version" do
96
- subject.fetch_version('1.2.0', '>=').should == '1.2.0'
110
+ subject.fetch_version('>=', '1.100.0').should == '1.100.0'
97
111
  end
98
112
 
99
113
  it "uses the default version when the given version is lower" do
100
- subject.fetch_version('1.0.1', '>=').should == EY::Serverside::LockfileParser::DEFAULT
114
+ subject.fetch_version('>=', '1.0.1').should == EY::Serverside::DependencyManager::Bundler.default_version
101
115
  end
102
116
 
103
117
  it "selects only the first version expression" do
104
- scan = subject.scan_bundler 'bundler (>=1.0.1, <2.0.0)'
118
+ scan = subject.scan_gem('bundler', 'bundler (>=1.0.1, <2.0.0)')
105
119
  scan.last.should == '1.0.1'
106
120
  end
107
121
  end
@@ -2,12 +2,46 @@ require 'spec_helper'
2
2
 
3
3
  describe "Deploying a Rails 3.1 application" do
4
4
  context "with default production settings" do
5
- before(:all) do
6
- deploy_test_application('assets_enabled')
5
+ it "precompiles assets when asset compilation is detected" do
6
+ deploy_test_application('assets_detected')
7
+ deploy_dir.join('current', 'precompiled').should exist
8
+ deploy_dir.join('current', 'public', 'assets').should exist
9
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
10
+ read_output.should include("Precompiling assets. ('app/assets' exists, 'public/assets' not found, not disabled in config.)")
7
11
  end
8
12
 
9
- it "precompiles assets" do
13
+ it "precompiles assets, then reuses them on the next deploy if nothing has changed" do
14
+ deploy_test_application('assets_enabled_in_ey_yml')
10
15
  deploy_dir.join('current', 'precompiled').should exist
16
+ deploy_dir.join('current', 'public', 'assets').should exist
17
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
18
+
19
+ redeploy_test_application
20
+ deploy_dir.join('current', 'precompiled').should_not exist # doesn't run the task
21
+ deploy_dir.join('current', 'public', 'assets').should exist # but the assets are there
22
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
23
+ read_output.should =~ %r#Reusing existing assets\. \(configured asset_dependencies unchanged from \w{7}..\w{7}\)#
24
+
25
+ redeploy_test_application('config' => {'precompile_unchanged_assets' => 'true'})
26
+ deploy_dir.join('current', 'precompiled').should exist # doesn't run the task
27
+ deploy_dir.join('current', 'public', 'assets').should exist # but the assets are there
28
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
29
+ read_output.should_not include("Reusing existing assets")
30
+ end
31
+
32
+ it "precompile assets again when redeploying a ref with changes" do
33
+ deploy_test_application('assets_enabled_in_ey_yml')
34
+ deploy_dir.join('current', 'precompiled').should exist
35
+ deploy_dir.join('current', 'public', 'assets').should exist
36
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
37
+ read_output.should include("Precompiling assets. (precompile_assets: true)")
38
+
39
+ # changing the ref stands in for actually having assets change (see Strategies::IntegrationSpec#same?)
40
+ redeploy_test_application('branch' => 'somenewref')
41
+ deploy_dir.join('current', 'precompiled').should exist # it does runs the task
42
+ deploy_dir.join('current', 'public', 'assets').should exist
43
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
44
+ read_output.should_not =~ %r#Reusing existing assets#
11
45
  end
12
46
  end
13
47
 
@@ -18,6 +52,7 @@ describe "Deploying a Rails 3.1 application" do
18
52
 
19
53
  it "precompiles assets" do
20
54
  deploy_dir.join('current', 'precompiled').should exist
55
+ read_output.should include("Precompiling assets. (precompile_assets: true)")
21
56
  end
22
57
  end
23
58
 
@@ -28,6 +63,7 @@ describe "Deploying a Rails 3.1 application" do
28
63
 
29
64
  it "precompiles assets" do
30
65
  deploy_dir.join('current', 'precompiled').should_not exist
66
+ read_output.should include("Precompiling assets. (precompile_assets: true)")
31
67
  end
32
68
  end
33
69
 
@@ -38,16 +74,18 @@ describe "Deploying a Rails 3.1 application" do
38
74
 
39
75
  it "precompiles assets" do
40
76
  deploy_dir.join('current', 'precompiled').should exist
77
+ read_output.should include("Precompiling assets. (precompile_assets: true)")
41
78
  end
42
79
  end
43
80
 
44
- context "with asset support disabled in its config" do
81
+ context "with asset support disabled in config/application.rb" do
45
82
  before(:all) do
46
83
  deploy_test_application('assets_disabled')
47
84
  end
48
85
 
49
86
  it "does not precompile assets" do
50
87
  deploy_dir.join('current', 'precompiled').should_not exist
88
+ read_output.should include("Skipping asset precompilation. ('config/application.rb' disables assets.)")
51
89
  end
52
90
  end
53
91
 
@@ -56,8 +94,9 @@ describe "Deploying a Rails 3.1 application" do
56
94
  deploy_test_application('assets_disabled_in_ey_yml')
57
95
  end
58
96
 
59
- it "precompiles assets" do
97
+ it "does not precompile assets" do
60
98
  deploy_dir.join('current', 'precompiled').should_not exist
99
+ read_output.should include("Skipping asset precompilation. (precompile_assets: false)")
61
100
  end
62
101
  end
63
102
 
@@ -71,6 +110,8 @@ describe "Deploying a Rails 3.1 application" do
71
110
  deploy_dir.join('current', 'precompiled').should_not exist
72
111
  deploy_dir.join('current', 'public', 'assets').should be_directory
73
112
  deploy_dir.join('current', 'public', 'assets').should_not be_symlink
113
+ deploy_dir.join('current', 'public', 'assets', 'custom_compiled_asset').should exist
114
+ read_output.should include("Skipping asset precompilation. ('public/assets' directory already exists.)")
74
115
  end
75
116
  end
76
117
  end
data/spec/restart_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- class TestRestartDeploy < EY::Serverside::Deploy
3
+ class TestRestartDeploy < FullTestDeploy
4
4
  attr_reader :call_order
5
5
  def initialize(*a)
6
6
  super
@@ -21,7 +21,7 @@ describe "EY::Serverside::Deploy#restart_with_maintenance_page" do
21
21
 
22
22
  it "puts up the maintenance page if necessary, restarts, and takes down the maintenance page" do
23
23
  config = EY::Serverside::Deploy::Configuration.new('deploy_to' => deploy_dir, 'app' => 'app_name')
24
- deployer = TestRestartWithMaintenancePage.new(test_servers, config, test_shell)
24
+ deployer = TestRestartWithMaintenancePage.realnew(test_servers, config, test_shell)
25
25
  deployer.restart_with_maintenance_page
26
26
  deployer.call_order.should == %w(
27
27
  require_custom_tasks
@@ -36,7 +36,7 @@ describe "glassfish stack" do
36
36
 
37
37
  it "requires a maintenance page" do
38
38
  config = EY::Serverside::Deploy::Configuration.new('deploy_to' => deploy_dir, 'app' => 'app_name', 'stack' => 'glassfish')
39
- deployer = TestRestartDeploy.new(test_servers, config, test_shell)
39
+ deployer = TestRestartDeploy.realnew(test_servers, config, test_shell)
40
40
  deployer.restart_with_maintenance_page
41
41
  deployer.call_order.should include('enable_maintenance_page')
42
42
  end
@@ -1,14 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Deploying an application with services" do
4
- describe "a deploy without ey_config" do
4
+ let(:shared_services_file) { deploy_dir.join('shared', 'config', 'ey_services_config_deploy.yml') }
5
+ let(:symlinked_services_file) { deploy_dir.join('current', 'config', 'ey_services_config_deploy.yml') }
6
+ let(:services_yml) { {"servicio" => {"foo" => "bar"}}.to_yaml }
7
+
8
+ describe "without ey_config" do
5
9
  describe "with services" do
6
10
  before do
7
- deploy_test_application('no_ey_config') do |deployer|
8
- @shared_services_file = deployer.config.paths.shared_config.join('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
11
+ deploy_test_application('no_ey_config', 'config' => {
12
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
13
+ })
12
14
  end
13
15
 
14
16
  it "warns about missing ey_config" do
@@ -29,22 +31,20 @@ describe "Deploying an application with services" do
29
31
 
30
32
  describe "deploy with invalid yaml ey_services_config_deploy" do
31
33
  before do
32
- deploy_test_application do |deployer|
33
- @shared_services_file = deployer.config.paths.shared_config.join('ey_services_config_deploy.yml')
34
- @symlinked_services_file = deployer.config.paths.active_release_config.join('ey_services_config_deploy.yml')
35
- @invalid_services_yml = "42"
36
- deployer.mock_services_setup!("echo '#{@invalid_services_yml}' > #{@shared_services_file}")
37
- end
34
+ @invalid_services_yml = "42"
35
+ deploy_test_application('default', 'config' => {
36
+ 'services_setup_command' => "echo '#{@invalid_services_yml}' > #{shared_services_file}"
37
+ })
38
38
  end
39
39
 
40
40
  it "works without warning" do
41
- @shared_services_file.should exist
42
- @shared_services_file.should_not be_symlink
43
- @shared_services_file.read.should == "#{@invalid_services_yml}\n"
41
+ shared_services_file.should exist
42
+ shared_services_file.should_not be_symlink
43
+ shared_services_file.read.should == "#{@invalid_services_yml}\n"
44
44
 
45
- @symlinked_services_file.should exist
46
- @symlinked_services_file.should be_symlink
47
- @shared_services_file.read.should == "#{@invalid_services_yml}\n"
45
+ symlinked_services_file.should exist
46
+ symlinked_services_file.should be_symlink
47
+ shared_services_file.read.should == "#{@invalid_services_yml}\n"
48
48
 
49
49
  read_output.should_not =~ /WARNING/
50
50
  end
@@ -52,99 +52,102 @@ describe "Deploying an application with services" do
52
52
 
53
53
  describe "a succesful deploy" do
54
54
  before do
55
- deploy_test_application do |deployer|
56
- @shared_services_file = deployer.config.paths.shared_config.join('ey_services_config_deploy.yml')
57
- @symlinked_services_file = deployer.config.paths.active_release_config.join('ey_services_config_deploy.yml')
58
- @services_yml = {"servicio" => {"foo" => "bar"}}.to_yaml
59
-
60
- deployer.mock_services_setup!("echo '#{@services_yml}' > #{@shared_services_file}")
61
- end
55
+ deploy_test_application('default', 'config' => {
56
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
57
+ })
62
58
  end
63
59
 
64
60
  it "creates and symlinks ey_services_config_deploy.yml" do
65
- @shared_services_file.should exist
66
- @shared_services_file.should_not be_symlink
67
- @shared_services_file.read.should == "#{@services_yml}\n"
61
+ shared_services_file.should exist
62
+ shared_services_file.should_not be_symlink
63
+ shared_services_file.read.should == "#{services_yml}\n"
68
64
 
69
- @symlinked_services_file.should exist
70
- @symlinked_services_file.should be_symlink
71
- @shared_services_file.read.should == "#{@services_yml}\n"
65
+ symlinked_services_file.should exist
66
+ symlinked_services_file.should be_symlink
67
+ shared_services_file.read.should == "#{services_yml}\n"
72
68
 
73
69
  read_output.should_not =~ /WARNING/
74
70
  end
71
+ end
75
72
 
76
- describe "followed by a deploy that can't find the command" do
77
- before do
78
- redeploy_test_application do |deployer|
79
- deployer.mock_services_command_check!("which nonexistatncommand")
80
- end
81
- end
82
-
83
- it "silently fails" do
84
- @shared_services_file.should exist
85
- @shared_services_file.should_not be_symlink
86
- @shared_services_file.read.should == "#{@services_yml}\n"
73
+ describe "a successful deploy followed by a deploy that can't find the command" do
74
+ before do
75
+ deploy_test_application('default', 'config' => {
76
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
77
+ })
78
+ redeploy_test_application('config' => {
79
+ 'services_check_command' => 'false'
80
+ })
81
+ end
87
82
 
88
- @symlinked_services_file.should exist
89
- @symlinked_services_file.should be_symlink
90
- @shared_services_file.read.should == "#{@services_yml}\n"
83
+ it "silently fails" do
84
+ shared_services_file.should exist
85
+ shared_services_file.should_not be_symlink
86
+ shared_services_file.read.should == "#{services_yml}\n"
91
87
 
92
- read_output.should_not =~ /WARNING/
93
- end
88
+ symlinked_services_file.should exist
89
+ symlinked_services_file.should be_symlink
90
+ shared_services_file.read.should == "#{services_yml}\n"
94
91
 
92
+ read_output.should_not =~ /WARNING/
95
93
  end
96
94
 
97
- describe "followed by a deploy that fails to fetch services" do
98
- it "logs a warning and symlinks the existing config file when there is existing services file" do
99
- redeploy_test_application do |deployer|
100
- deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
101
- end
102
- @shared_services_file.should exist
103
- @shared_services_file.should_not be_symlink
104
- @shared_services_file.read.should == "#{@services_yml}\n"
95
+ end
105
96
 
106
- @symlinked_services_file.should exist
107
- @symlinked_services_file.should be_symlink
108
- @shared_services_file.read.should == "#{@services_yml}\n"
97
+ describe "a successful followed by a deploy that fails to fetch services" do
98
+ it "logs a warning and symlinks the existing config file when there is existing services file" do
99
+ deploy_test_application('default', 'config' => {
100
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
101
+ })
102
+ redeploy_test_application('config' => {'services_setup_command' => 'false'})
109
103
 
110
- read_output.should include('WARNING: External services configuration not updated')
111
- end
104
+ shared_services_file.should exist
105
+ shared_services_file.should_not be_symlink
106
+ shared_services_file.read.should == "#{services_yml}\n"
112
107
 
113
- it "does not log a warning or symlink a config file when there is no existing services file" do
114
- redeploy_test_application do |deployer|
115
- deployer.mock_services_setup!("notarealcommandsoitwillexitnonzero")
116
- @shared_services_file.delete
117
- end
108
+ symlinked_services_file.should exist
109
+ symlinked_services_file.should be_symlink
110
+ shared_services_file.read.should == "#{services_yml}\n"
118
111
 
119
- @shared_services_file.should_not exist
120
- @symlinked_services_file.should_not exist
112
+ read_output.should include('WARNING: External services configuration not updated')
113
+ end
121
114
 
122
- read_output.should_not =~ /WARNING/
123
- end
115
+ it "does not log a warning or symlink a config file when there is no existing services file" do
116
+ deploy_test_application('default', 'config' => {
117
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
118
+ })
119
+ shared_services_file.delete
120
+ redeploy_test_application('config' => {'services_setup_command' => 'false'})
121
+
122
+ shared_services_file.should_not exist
123
+ symlinked_services_file.should_not exist
124
124
 
125
+ read_output.should_not =~ /WARNING/
125
126
  end
127
+ end
126
128
 
127
- describe "followed by another successfull deploy" do
128
- before do
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
133
- end
129
+ describe "a successful deploy followed by another successfull deploy" do
130
+ before do
131
+ deploy_test_application('default', 'config' => {
132
+ 'services_setup_command' => "echo '#{services_yml}' > #{shared_services_file}"
133
+ })
134
+ @new_services_yml = {"servicio" => {"foo" => "bar2"}}.to_yaml
135
+ redeploy_test_application('config' => {
136
+ 'services_setup_command' => "echo '#{@new_services_yml}' > #{shared_services_file}"
137
+ })
138
+ end
134
139
 
135
- it "replaces the config with the new one (and symlinks)" do
136
- @shared_services_file.should exist
137
- @shared_services_file.should_not be_symlink
138
- @shared_services_file.read.should == "#{@services_yml}\n"
140
+ it "replaces the config with the new one (and symlinks)" do
141
+ shared_services_file.should exist
142
+ shared_services_file.should_not be_symlink
143
+ shared_services_file.read.should == "#{@new_services_yml}\n"
139
144
 
140
- @symlinked_services_file.should exist
141
- @symlinked_services_file.should be_symlink
142
- @shared_services_file.read.should == "#{@services_yml}\n"
145
+ symlinked_services_file.should exist
146
+ symlinked_services_file.should be_symlink
147
+ shared_services_file.read.should == "#{@new_services_yml}\n"
143
148
 
144
- read_output.should_not =~ /WARNING/
145
- end
149
+ read_output.should_not =~ /WARNING/
146
150
  end
147
-
148
151
  end
149
152
 
150
153
  end