capistrano-improved-rsync-with-remote-cache 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +8 -42
- data/capistrano-improved-rsync-with-remote-cache.gemspec +5 -4
- data/lib/capistrano/recipes/deploy/strategy/{improved_rsync_with_remote_cache.rb → rsync_with_remote_cache.rb} +18 -13
- metadata +48 -58
- data/test/capistrano_rsync_with_remote_cache_test.rb +0 -288
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c4cd1ead5582ed83075343b425e9c0729999ab2
|
4
|
+
data.tar.gz: 25d135fa8721417936f91baaf07c962e2ba29307
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4823713843c820471b1cc4dfdc745e4b2c2949aefd1db105b0e4b4932b88ceda8e2f3387bb49289082ce9bd79f5f93b45a38d4afa8769bc2fd77dfdecd096a0d
|
7
|
+
data.tar.gz: 7747c1c118ca0a943b0bc758847daf0eb8fe704374b8ee466e32b3cb025d705eb75a80fd46f07226cc7e067fcf676ac0a5fbcb9bc2e0a87d5b1cc46bba077179
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Capistrano
|
1
|
+
= Capistrano 2.0 improved_rsync_with_remote_cache Deployment Strategy
|
2
2
|
|
3
3
|
== Description
|
4
4
|
|
@@ -6,27 +6,24 @@ This gem provides a deployment strategy for Capistrano which combines the
|
|
6
6
|
<tt>rsync</tt> command with a remote cache, allowing fast deployments from SCM
|
7
7
|
repositories behind firewalls.
|
8
8
|
|
9
|
-
==
|
9
|
+
== Aim
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
other SCM systems.
|
11
|
+
The original gem is outdated. In this gem, I have merged all the pull requests
|
12
|
+
that were interesting, such as rsync in parallel, rsh parameters, etc.
|
14
13
|
|
15
|
-
|
16
|
-
remote hosts. It also requires either <tt>svn</tt>, <tt>git</tt>, <tt>hg</tt>
|
17
|
-
or <tt>bzr</tt> on the local host, but not the remote host.
|
14
|
+
== Original gem
|
18
15
|
|
19
|
-
|
16
|
+
For the original gem, visit: https://github.com/vigetlabs/capistrano_rsync_with_remote_cache
|
20
17
|
|
21
18
|
== Installation
|
22
19
|
|
23
|
-
gem install
|
20
|
+
gem install improved_capistrano_rsync_with_remote_cache
|
24
21
|
|
25
22
|
== Usage
|
26
23
|
|
27
24
|
To use this deployment strategy, add this line to your <tt>deploy.rb</tt> file:
|
28
25
|
|
29
|
-
set :deploy_via, :
|
26
|
+
set :deploy_via, :improved_rsync_with_remote_cache
|
30
27
|
|
31
28
|
== Under the Hood
|
32
29
|
|
@@ -63,34 +60,3 @@ replica of the local cache.
|
|
63
60
|
Finally, a copy of the remote cache is made in the appropriate release
|
64
61
|
directory. The end result is the same as if the code had been checked out
|
65
62
|
directly on the remote server, as in the default strategy.
|
66
|
-
|
67
|
-
== Contributors
|
68
|
-
|
69
|
-
Thanks to the people who submitted patches:
|
70
|
-
|
71
|
-
* {S. Brent Faulkner}[http://github.com/sbfaulkner]
|
72
|
-
|
73
|
-
== License
|
74
|
-
|
75
|
-
Copyright (c) 2007 - 2010 Patrick Reagan (patrick.reagan@viget.com) & Mark Cornick
|
76
|
-
|
77
|
-
Permission is hereby granted, free of charge, to any person
|
78
|
-
obtaining a copy of this software and associated documentation
|
79
|
-
files (the "Software"), to deal in the Software without
|
80
|
-
restriction, including without limitation the rights to use,
|
81
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
82
|
-
copies of the Software, and to permit persons to whom the
|
83
|
-
Software is furnished to do so, subject to the following
|
84
|
-
conditions:
|
85
|
-
|
86
|
-
The above copyright notice and this permission notice shall be
|
87
|
-
included in all copies or substantial portions of the Software.
|
88
|
-
|
89
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
91
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
92
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
93
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
94
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
95
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
96
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "capistrano-improved-rsync-with-remote-cache"
|
5
|
-
gem.version = "1.
|
5
|
+
gem.version = "1.1.0"
|
6
6
|
gem.authors = ["Carlos Buenosvinos"]
|
7
|
-
gem.email = ["
|
7
|
+
gem.email = ["carlos.buenosvinos@gmail.com"]
|
8
8
|
gem.homepage = "https://github.com/carlosbuenosvinos/capistrano-improved-rsync-with-remote-cache"
|
9
9
|
gem.summary = %q{Improved version of rsync-with-remote-cache deployment strategy.}
|
10
|
-
gem.description = %q{
|
10
|
+
gem.description = %q{Improved version of rsync-with-remote-cache deployment strategy.}
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($/)
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -15,4 +15,5 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
|
17
17
|
gem.add_dependency('capistrano', '>=2.4.0')
|
18
|
-
|
18
|
+
gem.add_dependency('parallel', '>=0.0.0')
|
19
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'capistrano/recipes/deploy/strategy/remote'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'parallel'
|
3
4
|
|
4
5
|
module Capistrano
|
5
6
|
module Deploy
|
6
7
|
module Strategy
|
7
|
-
class
|
8
|
+
class RsyncWithRemoteCache < Remote
|
8
9
|
|
9
10
|
class InvalidCacheError < Exception; end
|
10
11
|
|
@@ -22,6 +23,8 @@ module Capistrano
|
|
22
23
|
default_attribute :rsync_options, '-az --delete'
|
23
24
|
default_attribute :local_cache, '.rsync_cache'
|
24
25
|
default_attribute :repository_cache, 'cached-copy'
|
26
|
+
default_attribute :rsync_concurrency, 8
|
27
|
+
default_attribute :rsync_in_parallel, true
|
25
28
|
|
26
29
|
def deploy!
|
27
30
|
update_local_cache
|
@@ -29,14 +32,24 @@ module Capistrano
|
|
29
32
|
copy_remote_cache
|
30
33
|
end
|
31
34
|
|
35
|
+
def system!(command)
|
36
|
+
system(command) or raise RuntimeError.new("Command exit with non zero status: #{command}")
|
37
|
+
end
|
38
|
+
|
32
39
|
def update_local_cache
|
33
|
-
system(command)
|
40
|
+
system!(command)
|
34
41
|
mark_local_cache
|
35
42
|
end
|
36
43
|
|
37
44
|
def update_remote_cache
|
38
45
|
finder_options = {:except => { :no_release => true }}
|
39
|
-
|
46
|
+
if rsync_in_parallel
|
47
|
+
Parallel.map(find_servers(finder_options), :in_threads => rsync_concurrency) do |s|
|
48
|
+
system!(rsync_command_for(s))
|
49
|
+
end.all?
|
50
|
+
else
|
51
|
+
find_servers(finder_options).each {|s| system(rsync_command_for(s)) }
|
52
|
+
end
|
40
53
|
end
|
41
54
|
|
42
55
|
def copy_remote_cache
|
@@ -44,10 +57,7 @@ module Capistrano
|
|
44
57
|
end
|
45
58
|
|
46
59
|
def rsync_command_for(server)
|
47
|
-
#
|
48
|
-
ssh_options_string = "-p #{ssh_port(server)}"
|
49
|
-
ssh_options_string << " -i #{ssh_options[:keys]}" if ssh_options[:keys]
|
50
|
-
"rsync #{rsync_options} --rsh='ssh #{ssh_options_string}' #{local_cache_path}/ #{rsync_host(server)}:#{repository_cache_path}/"
|
60
|
+
"rsync #{rsync_options} --rsh='ssh -p #{ssh_port(server)}' #{local_cache_path}/ #{rsync_host(server)}:#{repository_cache_path}/"
|
51
61
|
end
|
52
62
|
|
53
63
|
def mark_local_cache
|
@@ -110,12 +120,7 @@ module Capistrano
|
|
110
120
|
|
111
121
|
def command
|
112
122
|
if local_cache_valid?
|
113
|
-
|
114
|
-
if configuration[:scm] == :none
|
115
|
-
"true"
|
116
|
-
else
|
117
|
-
source.sync(revision, local_cache_path)
|
118
|
-
end
|
123
|
+
source.sync(revision, local_cache_path)
|
119
124
|
elsif !local_cache_exists?
|
120
125
|
"mkdir -p #{local_cache_path} && #{source.checkout(revision, local_cache_path)}"
|
121
126
|
else
|
metadata
CHANGED
@@ -1,87 +1,77 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-improved-rsync-with-remote-cache
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 1.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Carlos Buenosvinos
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.4.0
|
20
|
+
type: :runtime
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
26
24
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 31
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 4
|
32
|
-
- 0
|
25
|
+
- !ruby/object:Gem::Version
|
33
26
|
version: 2.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: parallel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.0
|
34
34
|
type: :runtime
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.0
|
41
|
+
description: Improved version of rsync-with-remote-cache deployment strategy.
|
42
|
+
email:
|
43
|
+
- carlos.buenosvinos@gmail.com
|
39
44
|
executables: []
|
40
|
-
|
41
45
|
extensions: []
|
42
|
-
|
43
46
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
|
46
|
-
- .gitignore
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
47
49
|
- Gemfile
|
48
50
|
- README.rdoc
|
49
51
|
- Rakefile
|
50
52
|
- capistrano-improved-rsync-with-remote-cache.gemspec
|
51
|
-
- lib/capistrano/recipes/deploy/strategy/
|
52
|
-
- test/capistrano_rsync_with_remote_cache_test.rb
|
53
|
+
- lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb
|
53
54
|
homepage: https://github.com/carlosbuenosvinos/capistrano-improved-rsync-with-remote-cache
|
54
55
|
licenses: []
|
55
|
-
|
56
|
+
metadata: {}
|
56
57
|
post_install_message:
|
57
58
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
59
|
+
require_paths:
|
60
60
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
|
63
|
-
requirements:
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
64
63
|
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
version: "0"
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
|
-
requirements:
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
73
68
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
79
71
|
requirements: []
|
80
|
-
|
81
72
|
rubyforge_project:
|
82
|
-
rubygems_version:
|
73
|
+
rubygems_version: 2.4.1
|
83
74
|
signing_key:
|
84
|
-
specification_version:
|
75
|
+
specification_version: 4
|
85
76
|
summary: Improved version of rsync-with-remote-cache deployment strategy.
|
86
|
-
test_files:
|
87
|
-
- test/capistrano_rsync_with_remote_cache_test.rb
|
77
|
+
test_files: []
|
@@ -1,288 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'mocha'
|
4
|
-
require 'shoulda'
|
5
|
-
require 'matchy'
|
6
|
-
require 'tmpdir'
|
7
|
-
|
8
|
-
require 'capistrano/recipes/deploy/strategy/rsync_with_remote_cache'
|
9
|
-
|
10
|
-
class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
11
|
-
|
12
|
-
context "An instance of the CapistranoRsyncWithRemoteCache class" do
|
13
|
-
setup { @strategy = Capistrano::Deploy::Strategy::RsyncWithRemoteCache.new }
|
14
|
-
|
15
|
-
should "know the default rsync options" do
|
16
|
-
@strategy.rsync_options.should == '-az --delete'
|
17
|
-
end
|
18
|
-
|
19
|
-
should "allow overriding of the rsync options" do
|
20
|
-
@strategy.stubs(:configuration).with().returns(:rsync_options => 'new_opts')
|
21
|
-
@strategy.rsync_options.should == 'new_opts'
|
22
|
-
end
|
23
|
-
|
24
|
-
should "know the default local cache name" do
|
25
|
-
@strategy.local_cache.should == '.rsync_cache'
|
26
|
-
end
|
27
|
-
|
28
|
-
should "know the local cache name if it has been configured" do
|
29
|
-
@strategy.stubs(:configuration).with().returns(:local_cache => 'cache')
|
30
|
-
@strategy.local_cache.should == 'cache'
|
31
|
-
end
|
32
|
-
|
33
|
-
should "know the cache path" do
|
34
|
-
@strategy.stubs(:local_cache).with().returns('cache_dir')
|
35
|
-
File.expects(:expand_path).with('cache_dir').returns('local_cache_path')
|
36
|
-
|
37
|
-
@strategy.local_cache_path.should == 'local_cache_path'
|
38
|
-
end
|
39
|
-
|
40
|
-
should "know the repository URL for a subversion repository" do
|
41
|
-
@strategy.stubs(:local_cache_path).with().returns('cache_path')
|
42
|
-
@strategy.stubs(:configuration).with().returns(:scm => :subversion)
|
43
|
-
@strategy.expects(:`).with("cd cache_path && svn info . | sed -n \'s/URL: //p\'").returns("svn_url\n")
|
44
|
-
@strategy.repository_url.should == 'svn_url'
|
45
|
-
end
|
46
|
-
|
47
|
-
should "know the repository URL for a git repository" do
|
48
|
-
@strategy.stubs(:local_cache_path).with().returns('cache_path')
|
49
|
-
@strategy.stubs(:configuration).with().returns(:scm => :git)
|
50
|
-
@strategy.expects(:`).with("cd cache_path && git config remote.origin.url").returns("git_url\n")
|
51
|
-
@strategy.repository_url.should == 'git_url'
|
52
|
-
end
|
53
|
-
|
54
|
-
should "know the repository URL for a mercurial repository" do
|
55
|
-
@strategy.stubs(:local_cache_path).with().returns('cache_path')
|
56
|
-
@strategy.stubs(:configuration).with().returns(:scm => :mercurial)
|
57
|
-
@strategy.expects(:`).with("cd cache_path && hg showconfig paths.default").returns("hg_url\n")
|
58
|
-
@strategy.repository_url.should == 'hg_url'
|
59
|
-
end
|
60
|
-
|
61
|
-
should "know the repository URL for a bzr repository" do
|
62
|
-
@strategy.stubs(:local_cache_path).with().returns('cache_path')
|
63
|
-
@strategy.stubs(:configuration).with().returns(:scm => :bzr)
|
64
|
-
@strategy.expects(:`).with("cd cache_path && bzr info | grep parent | sed \'s/^.*parent branch: //\'").returns("bzr_url\n")
|
65
|
-
@strategy.repository_url.should == 'bzr_url'
|
66
|
-
end
|
67
|
-
|
68
|
-
should "know that the repository URL has not changed" do
|
69
|
-
@strategy.stubs(:repository_url).with().returns('repo_url')
|
70
|
-
@strategy.stubs(:configuration).with().returns(:repository => 'repo_url')
|
71
|
-
|
72
|
-
@strategy.repository_url_changed?.should be(false)
|
73
|
-
end
|
74
|
-
|
75
|
-
should "know that the repository URL has changed" do
|
76
|
-
@strategy.stubs(:repository_url).with().returns('new_repo_url')
|
77
|
-
@strategy.stubs(:configuration).with().returns(:repository => 'old_repo_url')
|
78
|
-
|
79
|
-
@strategy.repository_url_changed?.should be(true)
|
80
|
-
end
|
81
|
-
|
82
|
-
should "be able to remove the local cache" do
|
83
|
-
@strategy.stubs(:logger).with().returns(stub(:trace))
|
84
|
-
@strategy.stubs(:local_cache_path).with().returns('local_cache_path')
|
85
|
-
FileUtils.expects(:rm_rf).with('local_cache_path')
|
86
|
-
|
87
|
-
@strategy.remove_local_cache
|
88
|
-
end
|
89
|
-
|
90
|
-
should "remove the local cache if the repository URL has changed" do
|
91
|
-
@strategy.stubs(:repository_url_changed?).with().returns(true)
|
92
|
-
@strategy.expects(:remove_local_cache).with()
|
93
|
-
|
94
|
-
@strategy.remove_cache_if_repository_url_changed
|
95
|
-
end
|
96
|
-
|
97
|
-
should "not remove the local cache if the repository URL has not changed" do
|
98
|
-
@strategy.stubs(:repository_url_changed?).with().returns(false)
|
99
|
-
@strategy.expects(:remove_local_cache).with().never
|
100
|
-
|
101
|
-
@strategy.remove_cache_if_repository_url_changed
|
102
|
-
end
|
103
|
-
|
104
|
-
should "know the default SSH port" do
|
105
|
-
@strategy.stubs(:ssh_options).with().returns({})
|
106
|
-
server = stub(:port => nil)
|
107
|
-
@strategy.ssh_port(server).should == 22
|
108
|
-
end
|
109
|
-
|
110
|
-
should "be able to override the default SSH port" do
|
111
|
-
@strategy.stubs(:ssh_options).with().returns({:port => 95})
|
112
|
-
server = stub(:port => nil)
|
113
|
-
@strategy.ssh_port(server).should == 95
|
114
|
-
end
|
115
|
-
|
116
|
-
should "be able to override the default SSH port for each server" do
|
117
|
-
@strategy.stubs(:ssh_options).with().returns({:port => 95})
|
118
|
-
server = stub(:port => 123)
|
119
|
-
@strategy.ssh_port(server).should == 123
|
120
|
-
end
|
121
|
-
|
122
|
-
should "know the default repository cache" do
|
123
|
-
@strategy.repository_cache.should == 'cached-copy'
|
124
|
-
end
|
125
|
-
|
126
|
-
should "be able to override the default repository cache" do
|
127
|
-
@strategy.stubs(:configuration).with().returns(:repository_cache => 'other_cache')
|
128
|
-
@strategy.repository_cache.should == 'other_cache'
|
129
|
-
end
|
130
|
-
|
131
|
-
should "know the repository cache path" do
|
132
|
-
@strategy.stubs(:shared_path).with().returns('shared_path')
|
133
|
-
@strategy.stubs(:repository_cache).with().returns('cache_path')
|
134
|
-
|
135
|
-
File.expects(:join).with('shared_path', 'cache_path').returns('path')
|
136
|
-
@strategy.repository_cache_path.should == 'path'
|
137
|
-
end
|
138
|
-
|
139
|
-
should "be able to determine the hostname for the rsync command" do
|
140
|
-
server = stub(:host => 'host.com')
|
141
|
-
@strategy.rsync_host(server).should == 'host.com'
|
142
|
-
end
|
143
|
-
|
144
|
-
should "be able to determine the hostname for the rsync command when a user is configured" do
|
145
|
-
@strategy.stubs(:configuration).with().returns(:user => 'foobar')
|
146
|
-
server = stub(:host => 'host.com')
|
147
|
-
|
148
|
-
@strategy.rsync_host(server).should == 'foobar@host.com'
|
149
|
-
end
|
150
|
-
|
151
|
-
should "know that the local cache exists" do
|
152
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
153
|
-
File.stubs(:exist?).with('path').returns(true)
|
154
|
-
|
155
|
-
@strategy.local_cache_exists?.should be(true)
|
156
|
-
end
|
157
|
-
|
158
|
-
should "know that the local cache does not exist" do
|
159
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
160
|
-
File.stubs(:exist?).with('path').returns(false)
|
161
|
-
|
162
|
-
@strategy.local_cache_exists?.should be(false)
|
163
|
-
end
|
164
|
-
|
165
|
-
should "know that the local cache is not valid if it does not exist" do
|
166
|
-
@strategy.stubs(:local_cache_exists?).with().returns(false)
|
167
|
-
@strategy.local_cache_valid?.should be(false)
|
168
|
-
end
|
169
|
-
|
170
|
-
should "know that the local cache is not valid if it's not a directory" do
|
171
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
172
|
-
@strategy.stubs(:local_cache_exists?).with().returns(true)
|
173
|
-
|
174
|
-
File.stubs(:directory?).with('path').returns(false)
|
175
|
-
@strategy.local_cache_valid?.should be(false)
|
176
|
-
end
|
177
|
-
|
178
|
-
should "know that the local cache is valid" do
|
179
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
180
|
-
@strategy.stubs(:local_cache_exists?).with().returns(true)
|
181
|
-
|
182
|
-
File.stubs(:directory?).with('path').returns(true)
|
183
|
-
@strategy.local_cache_valid?.should be(true)
|
184
|
-
end
|
185
|
-
|
186
|
-
should "know the SCM command when the local cache is valid" do
|
187
|
-
source = mock() {|s| s.expects(:sync).with('revision', 'path').returns('scm_command') }
|
188
|
-
|
189
|
-
@strategy.stubs(:local_cache_valid?).with().returns(true)
|
190
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
191
|
-
@strategy.stubs(:revision).with().returns('revision')
|
192
|
-
@strategy.stubs(:source).with().returns(source)
|
193
|
-
|
194
|
-
@strategy.send(:command).should == 'scm_command'
|
195
|
-
end
|
196
|
-
|
197
|
-
should "know the SCM command when the local cache does not exist" do
|
198
|
-
source = mock() {|s| s.expects(:checkout).with('revision', 'path').returns('scm_command') }
|
199
|
-
|
200
|
-
@strategy.stubs(:local_cache_valid?).with().returns(false)
|
201
|
-
@strategy.stubs(:local_cache_exists?).with().returns(false)
|
202
|
-
@strategy.stubs(:local_cache_path).with().returns('path')
|
203
|
-
@strategy.stubs(:revision).with().returns('revision')
|
204
|
-
@strategy.stubs(:source).with().returns(source)
|
205
|
-
|
206
|
-
@strategy.send(:command).should == 'mkdir -p path && scm_command'
|
207
|
-
end
|
208
|
-
|
209
|
-
should "raise an exception when the local cache is invalid" do
|
210
|
-
@strategy.stubs(:local_cache_valid?).with().returns(false)
|
211
|
-
@strategy.stubs(:local_cache_exists?).with().returns(true)
|
212
|
-
|
213
|
-
lambda {
|
214
|
-
@strategy.send(:command)
|
215
|
-
}.should raise_error(Capistrano::Deploy::Strategy::RsyncWithRemoteCache::InvalidCacheError)
|
216
|
-
end
|
217
|
-
|
218
|
-
should "be able to tag the local cache" do
|
219
|
-
local_cache_path = Dir.tmpdir
|
220
|
-
@strategy.stubs(:revision).with().returns('1')
|
221
|
-
@strategy.stubs(:local_cache_path).with().returns(local_cache_path)
|
222
|
-
|
223
|
-
@strategy.mark_local_cache
|
224
|
-
|
225
|
-
File.read(File.join(local_cache_path, 'REVISION')).should == '1'
|
226
|
-
end
|
227
|
-
|
228
|
-
should "be able to update the local cache" do
|
229
|
-
@strategy.stubs(:command).with().returns('scm_command')
|
230
|
-
@strategy.expects(:system).with('scm_command')
|
231
|
-
@strategy.expects(:mark_local_cache).with()
|
232
|
-
|
233
|
-
@strategy.update_local_cache
|
234
|
-
end
|
235
|
-
|
236
|
-
should "be able to run the rsync command on a server" do
|
237
|
-
server = stub()
|
238
|
-
|
239
|
-
@strategy.stubs(:rsync_host).with(server).returns('rsync_host')
|
240
|
-
|
241
|
-
@strategy.stubs(
|
242
|
-
:rsync_options => 'rsync_options',
|
243
|
-
:ssh_port => 'ssh_port',
|
244
|
-
:local_cache_path => 'local_cache_path',
|
245
|
-
:repository_cache_path => 'repository_cache_path'
|
246
|
-
)
|
247
|
-
|
248
|
-
expected = "rsync rsync_options --rsh='ssh -p ssh_port' local_cache_path/ rsync_host:repository_cache_path/"
|
249
|
-
|
250
|
-
@strategy.rsync_command_for(server).should == expected
|
251
|
-
end
|
252
|
-
|
253
|
-
should "be able to update the remote cache" do
|
254
|
-
server_1, server_2 = [stub(), stub()]
|
255
|
-
@strategy.stubs(:find_servers).with(:except => {:no_release => true}).returns([server_1, server_2])
|
256
|
-
|
257
|
-
@strategy.stubs(:rsync_command_for).with(server_1).returns('server_1_rsync_command')
|
258
|
-
@strategy.stubs(:rsync_command_for).with(server_2).returns('server_2_rsync_command')
|
259
|
-
|
260
|
-
@strategy.expects(:system).with('server_1_rsync_command')
|
261
|
-
@strategy.expects(:system).with('server_2_rsync_command')
|
262
|
-
|
263
|
-
@strategy.update_remote_cache
|
264
|
-
end
|
265
|
-
|
266
|
-
should "be able copy the remote cache into place" do
|
267
|
-
@strategy.stubs(
|
268
|
-
:repository_cache_path => 'repository_cache_path',
|
269
|
-
:configuration => {:release_path => 'release_path'}
|
270
|
-
)
|
271
|
-
|
272
|
-
command = "rsync -a --delete repository_cache_path/ release_path/"
|
273
|
-
@strategy.expects(:run).with(command)
|
274
|
-
|
275
|
-
@strategy.copy_remote_cache
|
276
|
-
end
|
277
|
-
|
278
|
-
should "be able to deploy" do
|
279
|
-
@strategy.expects(:update_local_cache).with()
|
280
|
-
@strategy.expects(:update_remote_cache).with()
|
281
|
-
@strategy.expects(:copy_remote_cache).with()
|
282
|
-
|
283
|
-
@strategy.deploy!
|
284
|
-
end
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|