engineyard-serverside 2.6.15.pre → 2.6.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/engineyard-serverside/configuration.rb +1 -0
- data/lib/engineyard-serverside/dependency_manager/bundler.rb +1 -1
- data/lib/engineyard-serverside/rails_assets.rb +2 -1
- data/lib/engineyard-serverside/version.rb +1 -1
- metadata +4 -378
- data/spec/archive_deploy_spec.rb +0 -53
- data/spec/basic_deploy_spec.rb +0 -26
- data/spec/bundler_deploy_spec.rb +0 -160
- data/spec/configuration_spec.rb +0 -205
- data/spec/custom_deploy_spec.rb +0 -128
- data/spec/deploy_hook_spec.rb +0 -362
- data/spec/deprecation_spec.rb +0 -23
- data/spec/ey_yml_customized_deploy_spec.rb +0 -99
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/spec/fixtures/invalid_hook.rb +0 -1
- data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
- data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
- data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
- data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
- data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
- data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
- data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
- data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
- data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
- data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
- data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
- data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
- data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
- data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
- data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_detected/README +0 -1
- data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
- data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled/README +0 -1
- data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
- data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
- data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_all/README +0 -1
- data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
- data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
- data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
- data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_in_hook/README +0 -2
- data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
- data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
- data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
- data/spec/fixtures/repos/bundle_fails/README +0 -1
- data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
- data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
- data/spec/fixtures/repos/bundler_disabled/README +0 -1
- data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
- data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
- data/spec/fixtures/repos/bundler_old/README +0 -1
- data/spec/fixtures/repos/default/Gemfile +0 -4
- data/spec/fixtures/repos/default/Gemfile.lock +0 -12
- data/spec/fixtures/repos/default/README +0 -5
- data/spec/fixtures/repos/default/ey.yml +0 -3
- data/spec/fixtures/repos/executable_hooks/README +0 -1
- data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
- data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
- data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
- data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml/README +0 -1
- data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml_alt/README +0 -1
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
- data/spec/fixtures/repos/hook_fails/README +0 -1
- data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/README +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
- data/spec/fixtures/repos/multi_dep_manager/README +0 -1
- data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
- data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
- data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
- data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
- data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
- data/spec/fixtures/repos/no_ey_config/README +0 -1
- data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
- data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
- data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
- data/spec/fixtures/repos/nodejs/README +0 -1
- data/spec/fixtures/repos/nodejs/package.json +0 -7
- data/spec/fixtures/repos/not_bundled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/npm_disabled/package.json +0 -7
- data/spec/fixtures/repos/php_composer_disabled/README +0 -1
- data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
- data/spec/fixtures/repos/php_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
- data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/public_system/Gemfile +0 -4
- data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
- data/spec/fixtures/repos/public_system/README +0 -5
- data/spec/fixtures/repos/public_system/ey.yml +0 -3
- data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
- data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
- data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
- data/spec/fixtures/repos/sqlite3/README +0 -1
- data/spec/fixtures/retwisj.war +0 -0
- data/spec/fixtures/valid_hook.rb +0 -1
- data/spec/git_strategy_spec.rb +0 -34
- data/spec/lockfile_parser_spec.rb +0 -126
- data/spec/maintenance_spec.rb +0 -44
- data/spec/multi_dependency_manager_spec.rb +0 -25
- data/spec/nodejs_deploy_spec.rb +0 -30
- data/spec/php_deploy_spec.rb +0 -81
- data/spec/platform_configure_spec.rb +0 -61
- data/spec/rails31_deploy_spec.rb +0 -164
- data/spec/restart_spec.rb +0 -43
- data/spec/rollback_spec.rb +0 -87
- data/spec/server_spec.rb +0 -70
- data/spec/services_deploy_spec.rb +0 -153
- data/spec/shell_spec.rb +0 -57
- data/spec/source/archive_spec.rb +0 -33
- data/spec/source/git_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -360
- data/spec/sqlite3_deploy_spec.rb +0 -38
- data/spec/support/integration.rb +0 -103
- data/spec/support/source_doubles.rb +0 -28
- data/spec/support/timecop.rb +0 -5
- data/spec/symlink_spec.rb +0 -15
data/spec/shell_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'timecop'
|
4
|
-
|
5
|
-
describe EY::Serverside::Shell do
|
6
|
-
let(:output) { StringIO.new }
|
7
|
-
|
8
|
-
if "".respond_to?(:force_encoding)
|
9
|
-
it "status works for ut8" do
|
10
|
-
shell = EY::Serverside::Shell.new(:verbose => true, :stdout => output, :stderr => output, :log_path => tmpdir.join("engineyard-serverside-#{Time.now.to_i}-#{$$}.log"), :start_time => Time.local(2008, 9, 1, 12, 10, 25))
|
11
|
-
shell.status("\u2603".force_encoding("binary"))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has a timestamp before each line" do
|
16
|
-
time1 = Time.local(2008, 9, 1, 12, 0, 0)
|
17
|
-
time2 = Time.local(2008, 9, 1, 12, 3, 5)
|
18
|
-
time3 = Time.local(2008, 9, 1, 12, 10, 25)
|
19
|
-
|
20
|
-
@shell = EY::Serverside::Shell.new(:verbose => true, :stdout => output, :stderr => output, :log_path => tmpdir.join("engineyard-serverside-#{Time.now.to_i}-#{$$}.log"), :start_time => time1)
|
21
|
-
|
22
|
-
Timecop.freeze(time1) do
|
23
|
-
@shell.debug('debug')
|
24
|
-
@shell.notice('notice')
|
25
|
-
end
|
26
|
-
Timecop.freeze(time2) do
|
27
|
-
@shell.status('STATUS')
|
28
|
-
@shell.debug("multi\nline\ndebug")
|
29
|
-
@shell.warning("multi\nline\nwarning")
|
30
|
-
end
|
31
|
-
Timecop.freeze(time3) do
|
32
|
-
@shell.substatus("multi\nline\nsubstatus")
|
33
|
-
end
|
34
|
-
|
35
|
-
tstp_1 = "+ 00s "
|
36
|
-
tstp_2 = "+ 3m 05s "
|
37
|
-
tstp_3 = "+10m 25s "
|
38
|
-
output.rewind
|
39
|
-
expect(output.read).to eq <<-OUTPUT
|
40
|
-
#{tstp_1} debug
|
41
|
-
|
42
|
-
\e[1m\e[33m#{tstp_1} !> notice
|
43
|
-
\e[0m
|
44
|
-
\e[1m\e[37m#{tstp_2} ~> STATUS
|
45
|
-
\e[0m#{tstp_2} multi
|
46
|
-
#{tstp_2} line
|
47
|
-
#{tstp_2} debug
|
48
|
-
|
49
|
-
\e[1m\e[33m#{tstp_2} !> WARNING: multi
|
50
|
-
#{tstp_2} !> line
|
51
|
-
#{tstp_2} !> warning
|
52
|
-
\e[0m#{tstp_3} ~ multi
|
53
|
-
#{tstp_3} ~ line
|
54
|
-
#{tstp_3} ~ substatus
|
55
|
-
OUTPUT
|
56
|
-
end
|
57
|
-
end
|
data/spec/source/archive_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EY::Serverside::Source::Archive do
|
4
|
-
before do
|
5
|
-
allow_any_instance_of(described_class).to receive(:runner) { RunnerDouble }
|
6
|
-
end
|
7
|
-
|
8
|
-
context "source" do
|
9
|
-
let(:shell) { ShellDouble.new }
|
10
|
-
subject {
|
11
|
-
described_class.new(shell,
|
12
|
-
:uri => "http://server.com/app.war",
|
13
|
-
:repository_cache => TMPDIR)
|
14
|
-
}
|
15
|
-
|
16
|
-
it "cleans cache" do
|
17
|
-
expect(subject).to respond_to(:gc_repository_cache)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "compares revisions" do
|
21
|
-
expect(subject.same?("1", "1")).to be
|
22
|
-
end
|
23
|
-
|
24
|
-
it "understands short log message" do
|
25
|
-
expect(subject).to respond_to(:short_log_message)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "updates the cache" do
|
29
|
-
subject.update_repository_cache
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
data/spec/source/git_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EY::Serverside::Source::Git do
|
4
|
-
before do
|
5
|
-
allow_any_instance_of(described_class).to receive(:runner) { RunnerDouble }
|
6
|
-
end
|
7
|
-
|
8
|
-
it "errors when required options are not used" do
|
9
|
-
expect { described_class.new(nil, {}) }.to raise_error(ArgumentError)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "source" do
|
13
|
-
let(:shell) { ShellDouble.new }
|
14
|
-
subject {
|
15
|
-
described_class.new(shell,
|
16
|
-
:uri => "engineyard/engineyard-serverside.git",
|
17
|
-
:ref => "",
|
18
|
-
:repository_cache => "cache_dir")
|
19
|
-
}
|
20
|
-
|
21
|
-
it "creates the correct reivison file command" do
|
22
|
-
expect(subject.create_revision_file_command("directory/REVISION")).to eq(
|
23
|
-
"git --git-dir cache_dir/.git --work-tree cache_dir show --pretty=format:\"%H\" | head -1 > \"directory/REVISION\""
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "runs gc" do
|
28
|
-
expect(subject.gc_repository_cache.output).to eq("git --git-dir cache_dir/.git --work-tree cache_dir gc")
|
29
|
-
expect(shell.messages.last).to eq("Garbage collecting cached git repository to reduce disk usage.")
|
30
|
-
end
|
31
|
-
|
32
|
-
it "checks if it is the same revision" do
|
33
|
-
expect(subject.same?("", "")).to be
|
34
|
-
end
|
35
|
-
|
36
|
-
it "runs a short log message" do
|
37
|
-
expect(subject.short_log_message("rev")).to eq(
|
38
|
-
"git --git-dir cache_dir/.git --work-tree cache_dir log --pretty=oneline --abbrev-commit -n 1 'rev'"
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,360 +0,0 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
unless defined?(Bundler)
|
4
|
-
require 'rubygems'
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
unless RUBY_VERSION =~ /^1\.8\./
|
9
|
-
require 'simplecov'
|
10
|
-
SimpleCov.coverage_dir 'coverage/outside'
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter '/spec/'
|
13
|
-
add_filter '/features/'
|
14
|
-
add_filter '/mock/'
|
15
|
-
add_filter '/lib/vendor/'
|
16
|
-
add_group 'CLI Workflows', 'lib/engineyard-serverside/cli/workflows/'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'pp'
|
21
|
-
require 'engineyard-serverside'
|
22
|
-
require 'engineyard-serverside-adapter'
|
23
|
-
require 'support/integration'
|
24
|
-
require 'support/source_doubles'
|
25
|
-
require 'support/timecop'
|
26
|
-
|
27
|
-
FIXTURES_DIR = Pathname.new(__FILE__).dirname.join("fixtures")
|
28
|
-
TMPDIR = Pathname.new(__FILE__).dirname.parent.join('tmp')
|
29
|
-
GROUP = `id -gn`.strip
|
30
|
-
INTERNAL_KEY = Pathname.new("~/.ssh/id_rsa").expand_path
|
31
|
-
|
32
|
-
module EY
|
33
|
-
module Serverside
|
34
|
-
def self.dna_json=(j)
|
35
|
-
@dna_json = j
|
36
|
-
@node = nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
module SpecDependencyHelpers
|
42
|
-
$NPM_INSTALLED = system('which npm 2>&1')
|
43
|
-
unless $NPM_INSTALLED
|
44
|
-
$stderr.puts "npm not found; skipping Node.js specs."
|
45
|
-
end
|
46
|
-
|
47
|
-
def with_npm_mocked(&block)
|
48
|
-
context("mocked") { yield true }
|
49
|
-
context("unmocked") { yield false } if $NPM_INSTALLED
|
50
|
-
end
|
51
|
-
|
52
|
-
$COMPOSER_INSTALLED = system('command -v composer > /dev/null')
|
53
|
-
if $COMPOSER_INSTALLED
|
54
|
-
$stderr.puts "composer found; skipping tests that expect it to be missing."
|
55
|
-
else
|
56
|
-
$stderr.puts "composer not found; skipping tests that expect it to be available."
|
57
|
-
end
|
58
|
-
|
59
|
-
def with_composer_mocked(&block)
|
60
|
-
context("mocked") { yield true }
|
61
|
-
context("unmocked") { yield false } if $COMPOSER_INSTALLED
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
RSpec.configure do |config|
|
66
|
-
config.extend SpecDependencyHelpers
|
67
|
-
|
68
|
-
config.before(:all) do
|
69
|
-
make_tmpdir
|
70
|
-
EY::Serverside.dna_json = MultiJson.dump({})
|
71
|
-
end
|
72
|
-
|
73
|
-
config.after(:all) do
|
74
|
-
delete_tmpdir
|
75
|
-
end
|
76
|
-
|
77
|
-
class VerboseStringIO < StringIO
|
78
|
-
def <<(str)
|
79
|
-
if ENV['VERBOSE'] || ENV['DEBUG']
|
80
|
-
STDERR << str
|
81
|
-
end
|
82
|
-
super
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def tmpdir
|
87
|
-
TMPDIR
|
88
|
-
end
|
89
|
-
|
90
|
-
def make_tmpdir
|
91
|
-
tmpdir.mkpath
|
92
|
-
end
|
93
|
-
|
94
|
-
def delete_tmpdir
|
95
|
-
tmpdir.exist? && tmpdir.rmtree
|
96
|
-
end
|
97
|
-
|
98
|
-
def stdout
|
99
|
-
@stdout ||= VerboseStringIO.new
|
100
|
-
end
|
101
|
-
|
102
|
-
def stderr
|
103
|
-
@stderr ||= VerboseStringIO.new
|
104
|
-
end
|
105
|
-
|
106
|
-
def read_stdout
|
107
|
-
stdout.rewind
|
108
|
-
stdout.read
|
109
|
-
end
|
110
|
-
|
111
|
-
def read_stderr
|
112
|
-
stderr.rewind
|
113
|
-
stderr.read
|
114
|
-
end
|
115
|
-
|
116
|
-
def read_output
|
117
|
-
read_stdout + "\n" + read_stderr
|
118
|
-
end
|
119
|
-
|
120
|
-
def capture
|
121
|
-
begin
|
122
|
-
$stdout = @stdout = VerboseStringIO.new
|
123
|
-
$stderr = @stderr = VerboseStringIO.new
|
124
|
-
yield
|
125
|
-
ensure
|
126
|
-
$stdout, $stderr = STDOUT, STDERR
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_shell(verbose=true)
|
131
|
-
@test_shell ||= begin
|
132
|
-
@log_path = tmpdir.join("serverside-deploy-#{Time.now.to_f}-#{$$}.log")
|
133
|
-
EY::Serverside::Shell.new(:verbose => verbose, :log_path => @log_path, :stdout => stdout, :stderr => stderr)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def exist
|
138
|
-
be_exist
|
139
|
-
end
|
140
|
-
|
141
|
-
def bindir
|
142
|
-
@bindir ||= begin
|
143
|
-
dir = tmpdir.join("ey_test_cmds_#{Time.now.to_f}_#{$$}")
|
144
|
-
dir.mkpath
|
145
|
-
dir
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def mock_command(cmd, contents, &block)
|
150
|
-
bindir.join(cmd).open('w') do |f|
|
151
|
-
f.write contents
|
152
|
-
f.chmod(0755)
|
153
|
-
end
|
154
|
-
with_mocked_commands(&block) if block_given?
|
155
|
-
end
|
156
|
-
|
157
|
-
def mock_bundler(failure = false, &block)
|
158
|
-
mock_command('bundle', <<-SCRIPT, &block)
|
159
|
-
#!#{`which ruby`}
|
160
|
-
puts "Bundling gems"
|
161
|
-
$stdout.flush
|
162
|
-
#{failure && '$stderr.puts "bundle install failure"; exit 1'}
|
163
|
-
SCRIPT
|
164
|
-
end
|
165
|
-
|
166
|
-
def mock_npm(&block)
|
167
|
-
mock_command('npm', <<-SCRIPT, &block)
|
168
|
-
#!/bin/bash
|
169
|
-
echo "Running npm with $@"
|
170
|
-
SCRIPT
|
171
|
-
end
|
172
|
-
|
173
|
-
def mock_composer(&block)
|
174
|
-
mock_command('composer', <<-SCRIPT, &block)
|
175
|
-
#!/bin/bash
|
176
|
-
echo "Running composer with $@"
|
177
|
-
SCRIPT
|
178
|
-
end
|
179
|
-
|
180
|
-
def mock_sudo(&block)
|
181
|
-
mock_command('sudo', <<-SCRIPT, &block)
|
182
|
-
#!/bin/bash
|
183
|
-
echo "$@"
|
184
|
-
exec "$@"
|
185
|
-
SCRIPT
|
186
|
-
end
|
187
|
-
|
188
|
-
def with_mocked_commands(&block)
|
189
|
-
with_env('PATH' => "#{bindir}:#{ENV['PATH']}", &block)
|
190
|
-
end
|
191
|
-
|
192
|
-
def with_env(new_env_vars)
|
193
|
-
raise ArgumentError, "with_env takes a block" unless block_given?
|
194
|
-
|
195
|
-
old_env_vars = {}
|
196
|
-
new_env_vars.each do |k, v|
|
197
|
-
if ENV.has_key?(k)
|
198
|
-
old_env_vars[k] = ENV[k]
|
199
|
-
end
|
200
|
-
ENV[k] = v if v
|
201
|
-
end
|
202
|
-
|
203
|
-
yield
|
204
|
-
ensure
|
205
|
-
new_env_vars.keys.each do |k|
|
206
|
-
if old_env_vars.has_key?(k)
|
207
|
-
ENV[k] = old_env_vars[k]
|
208
|
-
else
|
209
|
-
ENV.delete(k)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
|
215
|
-
def deploy_dir
|
216
|
-
@deploy_dir ||= tmpdir.join("serverside-deploy-#{Time.now.to_f}-#{$$}")
|
217
|
-
end
|
218
|
-
|
219
|
-
def whoami
|
220
|
-
ENV['USER']
|
221
|
-
end
|
222
|
-
|
223
|
-
# set up EY::Serverside::Server like we're on a solo
|
224
|
-
def test_servers
|
225
|
-
@test_servers ||= EY::Serverside::Servers.from_hashes([{:hostname => 'localhost', :roles => %w[solo], :user => whoami}], test_shell)
|
226
|
-
end
|
227
|
-
|
228
|
-
def default_configuration
|
229
|
-
{
|
230
|
-
"source_class" => "IntegrationSpec",
|
231
|
-
"deploy_to" => deploy_dir.to_s,
|
232
|
-
"group" => GROUP,
|
233
|
-
"stack" => 'nginx_passenger',
|
234
|
-
"migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{deploy_dir}/path-when-migrating",
|
235
|
-
"app" => 'rails31',
|
236
|
-
"environment_name" => 'env',
|
237
|
-
"account_name" => 'acc',
|
238
|
-
"framework_env" => 'staging',
|
239
|
-
"branch" => 'somebranch',
|
240
|
-
"verbose" => true,
|
241
|
-
"git" => FIXTURES_DIR.join('repos', 'default'),
|
242
|
-
}
|
243
|
-
end
|
244
|
-
|
245
|
-
def test_adapter(repo_fixture_name = 'default', extra_config = {})
|
246
|
-
options = default_configuration.merge({ "git" => FIXTURES_DIR.join('repos', repo_fixture_name)}).merge(extra_config)
|
247
|
-
|
248
|
-
# pretend there is a shared bundled_gems directory
|
249
|
-
deploy_dir.join('shared', 'bundled_gems').mkpath
|
250
|
-
%w(RUBY_VERSION SYSTEM_VERSION).each do |name|
|
251
|
-
deploy_dir.join('shared', 'bundled_gems', name).open("w") { |f| f.write("old\n") }
|
252
|
-
end
|
253
|
-
|
254
|
-
EY::Serverside::Adapter.new do |args|
|
255
|
-
args.app = options['app']
|
256
|
-
args.environment_name = options['environment_name']
|
257
|
-
args.account_name = options['account_name']
|
258
|
-
args.migrate = options['migrate']
|
259
|
-
args.ref = options['branch']
|
260
|
-
args.git = options['git']
|
261
|
-
args.serverside_version = Gem::Version.create(EY::Serverside::VERSION.dup).release
|
262
|
-
args.config = {
|
263
|
-
"services_check_command" => "which echo",
|
264
|
-
"services_setup_command" => "echo 'services setup command'",
|
265
|
-
"source_class" => options["source_class"],
|
266
|
-
"deploy_to" => options["deploy_to"],
|
267
|
-
"group" => options["group"],
|
268
|
-
}.merge(options['config'] || {})
|
269
|
-
args.framework_env = options['framework_env']
|
270
|
-
args.stack = options['stack']
|
271
|
-
args.verbose = options['verbose']
|
272
|
-
args.clean = options['clean']
|
273
|
-
args.instances = test_servers.map {|s| {:hostname => s.hostname, :roles => s.roles.to_a, :name => s.name} }
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
# When a repo fixture name is specified, the files found in the specified
|
278
|
-
# spec/fixtures/repos dir are copied into the test github repository.
|
279
|
-
def deploy_test_application(repo_fixture_name = 'default', extra_config = {}, &block)
|
280
|
-
Timecop.travel(1)
|
281
|
-
@adapter = test_adapter(repo_fixture_name, extra_config)
|
282
|
-
@argv = @adapter.deploy.commands.last.to_argv[2..-1]
|
283
|
-
|
284
|
-
FullTestDeploy.on_create_callback = block
|
285
|
-
|
286
|
-
mock_bundler(extra_config['bundle_install_fails'])
|
287
|
-
with_mocked_commands do
|
288
|
-
capture do
|
289
|
-
EY::Serverside::CLI::App.start(@argv)
|
290
|
-
end
|
291
|
-
end
|
292
|
-
ensure
|
293
|
-
@deployer = EY::Serverside::Deploy.deployer
|
294
|
-
@config = EY::Serverside::Deploy.config
|
295
|
-
end
|
296
|
-
|
297
|
-
def redeploy_test_application(extra_config = {}, &block)
|
298
|
-
Timecop.travel(1)
|
299
|
-
raise "Please deploy_test_application first" unless @argv
|
300
|
-
bundle_install_fails = extra_config.delete('bundle_install_fails')
|
301
|
-
|
302
|
-
@action = @adapter.deploy do |args|
|
303
|
-
extra_config.each do |key,val|
|
304
|
-
case key
|
305
|
-
when 'branch' then args.ref = val
|
306
|
-
when 'config' then args.config = args.config.merge(val || {})
|
307
|
-
else args.send("#{key}=", val)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
@argv = @action.commands.last.to_argv[2..-1]
|
313
|
-
|
314
|
-
FullTestDeploy.on_create_callback = block
|
315
|
-
|
316
|
-
mock_bundler(bundle_install_fails)
|
317
|
-
|
318
|
-
with_mocked_commands do
|
319
|
-
capture do
|
320
|
-
EY::Serverside::CLI::App.start(@argv)
|
321
|
-
end
|
322
|
-
end
|
323
|
-
ensure
|
324
|
-
@deployer = EY::Serverside::Deploy.deployer
|
325
|
-
@config = EY::Serverside::Deploy.config
|
326
|
-
end
|
327
|
-
|
328
|
-
def enable_maintenance(extra_adapter_config = {})
|
329
|
-
@adapter = test_adapter("default", extra_adapter_config)
|
330
|
-
@argv = @adapter.enable_maintenance.commands.last.to_argv[2..-1]
|
331
|
-
|
332
|
-
with_mocked_commands do
|
333
|
-
capture do
|
334
|
-
EY::Serverside::CLI::App.start(@argv)
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
def disable_maintenance(extra_adapter_config = {})
|
340
|
-
@adapter = test_adapter("default", extra_adapter_config)
|
341
|
-
@argv = @adapter.disable_maintenance.commands.last.to_argv[2..-1]
|
342
|
-
|
343
|
-
with_mocked_commands do
|
344
|
-
capture do
|
345
|
-
EY::Serverside::CLI::App.start(@argv)
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
def maintenance_status(extra_adapter_config = {})
|
351
|
-
@adapter = test_adapter("default", extra_adapter_config)
|
352
|
-
@argv = @adapter.maintenance_status.commands.last.to_argv[2..-1]
|
353
|
-
|
354
|
-
with_mocked_commands do
|
355
|
-
capture do
|
356
|
-
EY::Serverside::CLI::App.start(@argv)
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|