m7d-vlad 1.2.0.4
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.
- data/History.txt +49 -0
- data/Manifest.txt +31 -0
- data/README.txt +78 -0
- data/Rakefile +51 -0
- data/considerations.txt +91 -0
- data/doco/faq.txt +75 -0
- data/doco/getting_started.txt +41 -0
- data/doco/migration.txt +43 -0
- data/doco/variables.txt +77 -0
- data/lib/rake_remote_task.rb +566 -0
- data/lib/vlad.rb +91 -0
- data/lib/vlad/core.rb +175 -0
- data/lib/vlad/git.rb +43 -0
- data/lib/vlad/maintenance.rb +23 -0
- data/test/test_rake_remote_task.rb +186 -0
- data/test/test_vlad.rb +211 -0
- data/test/test_vlad_git.rb +39 -0
- data/test/vlad_test_case.rb +71 -0
- metadata +111 -0
data/test/test_vlad.rb
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'test/vlad_test_case'
|
2
|
+
require 'vlad'
|
3
|
+
|
4
|
+
$TESTING = true
|
5
|
+
|
6
|
+
class TestVlad < VladTestCase
|
7
|
+
def test_all_hosts
|
8
|
+
util_set_hosts
|
9
|
+
assert_equal %w[app.example.com db.example.com], @vlad.all_hosts
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_fetch
|
13
|
+
set :foo, 5
|
14
|
+
assert_equal 5, @vlad.fetch(:foo)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_fetch_with_default
|
18
|
+
assert_equal 5, @vlad.fetch(:not_here, 5)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_host
|
22
|
+
@vlad.host "test.example.com", :app, :db
|
23
|
+
expected = {"test.example.com" => {}}
|
24
|
+
assert_equal expected, @vlad.roles[:app]
|
25
|
+
assert_equal expected, @vlad.roles[:db]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_host_invalid
|
29
|
+
assert_raise(ArgumentError) { @vlad.host "", :app, :db }
|
30
|
+
assert_raise(ArgumentError) { @vlad.host nil, :web }
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_host_multiple_hosts
|
34
|
+
@vlad.host "test.example.com", :app, :db
|
35
|
+
@vlad.host "yarr.example.com", :app, :db, :no_release => true
|
36
|
+
|
37
|
+
expected = {
|
38
|
+
"test.example.com" => {},
|
39
|
+
"yarr.example.com" => {:no_release => true}
|
40
|
+
}
|
41
|
+
|
42
|
+
assert_equal expected, @vlad.roles[:app]
|
43
|
+
assert_equal expected, @vlad.roles[:db]
|
44
|
+
assert_not_equal(@vlad.roles[:db]["test.example.com"].object_id,
|
45
|
+
@vlad.roles[:app]["test.example.com"].object_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_hosts_for_array_of_roles
|
49
|
+
util_set_hosts
|
50
|
+
assert_equal %w[app.example.com db.example.com], @vlad.hosts_for([:app, :db])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_hosts_for_one_role
|
54
|
+
util_set_hosts
|
55
|
+
@vlad.host "app2.example.com", :app
|
56
|
+
assert_equal %w[app.example.com app2.example.com], @vlad.hosts_for(:app)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_hosts_for_multiple_roles
|
60
|
+
util_set_hosts
|
61
|
+
assert_equal %w[app.example.com db.example.com], @vlad.hosts_for(:app, :db)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_hosts_for_unique
|
65
|
+
util_set_hosts
|
66
|
+
@vlad.host "app.example.com", :web
|
67
|
+
assert_equal %w[app.example.com db.example.com], @vlad.hosts_for(:app, :db, :web)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_initialize
|
71
|
+
@vlad.set_defaults # ensure these three are virginal
|
72
|
+
assert_raise(Vlad::ConfigurationError) { @vlad.code_repo }
|
73
|
+
assert_raise(Vlad::ConfigurationError) { @vlad.deploy_to }
|
74
|
+
assert_raise(Vlad::ConfigurationError) { @vlad.domain }
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_role
|
78
|
+
@vlad.role :app, "test.example.com"
|
79
|
+
expected = {"test.example.com" => {}}
|
80
|
+
assert_equal expected, @vlad.roles[:app]
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_role_multiple_hosts
|
84
|
+
@vlad.role :app, "test.example.com"
|
85
|
+
@vlad.role :app, "yarr.example.com", :no_release => true
|
86
|
+
expected = {
|
87
|
+
"test.example.com" => {},
|
88
|
+
"yarr.example.com" => {:no_release => true}
|
89
|
+
}
|
90
|
+
assert_equal expected, @vlad.roles[:app]
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_role_multiple_roles
|
94
|
+
@vlad.role :app, "test.example.com", :primary => true
|
95
|
+
@vlad.role :db, "yarr.example.com", :no_release => true
|
96
|
+
expected_db = { "yarr.example.com" => {:no_release => true} }
|
97
|
+
assert_equal expected_db, @vlad.roles[:db]
|
98
|
+
expected_app = { "test.example.com" => {:primary => true} }
|
99
|
+
assert_equal expected_app, @vlad.roles[:app]
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_remote_task
|
103
|
+
t = @vlad.remote_task(:test_task) { 5 }
|
104
|
+
assert_equal @task_count + 1, Rake.application.tasks.size
|
105
|
+
assert_equal Hash.new, t.options
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_remote_task_all_hosts_by_default
|
109
|
+
util_set_hosts
|
110
|
+
t = @vlad.remote_task(:test_task) { 5 }
|
111
|
+
assert_equal %w[app.example.com db.example.com], t.target_hosts
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_remote_task_environment_override
|
115
|
+
old_env_hosts = ENV["HOSTS"]
|
116
|
+
ENV["HOSTS"] = 'other1.example.com, other2.example.com'
|
117
|
+
util_set_hosts
|
118
|
+
t = @vlad.remote_task(:test_task) { 5 }
|
119
|
+
assert_equal %w[other1.example.com other2.example.com], t.target_hosts
|
120
|
+
ensure
|
121
|
+
ENV["HOSTS"] = old_env_hosts
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_remote_task_body_set
|
125
|
+
set(:some_variable, 5)
|
126
|
+
@vlad.host 'www.example.com', :app
|
127
|
+
@vlad.remote_task(:some_task) do $some_task_result = some_variable end
|
128
|
+
|
129
|
+
Rake::Task['some_task'].execute nil
|
130
|
+
assert_equal @vlad.fetch(:some_variable), $some_task_result
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_remote_task_with_options
|
134
|
+
t = @vlad.remote_task :test_task, :roles => [:app, :db] do
|
135
|
+
fail "should not run"
|
136
|
+
end
|
137
|
+
assert_equal({:roles => [:app, :db]}, t.options)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_remote_task_before_host_declaration
|
141
|
+
t = @vlad.remote_task :test_task, :roles => :web do 5 end
|
142
|
+
@vlad.host 'www.example.com', :web
|
143
|
+
assert_equal %w[www.example.com], t.target_hosts
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_remote_task_role_override
|
147
|
+
host "db1", :db
|
148
|
+
host "db2", :db
|
149
|
+
host "db3", :db
|
150
|
+
host "master", :master_db
|
151
|
+
|
152
|
+
remote_task(:migrate_the_db, :roles => [:db]) { flunk "bad!" }
|
153
|
+
task = Rake::Task["migrate_the_db"]
|
154
|
+
assert_equal %w[db1 db2 db3], task.target_hosts
|
155
|
+
|
156
|
+
task.options[:roles] = :master_db
|
157
|
+
assert_equal %w[master], task.target_hosts
|
158
|
+
|
159
|
+
task.options[:roles] = [:master_db]
|
160
|
+
assert_equal %w[master], task.target_hosts
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_set
|
164
|
+
set :test, 5
|
165
|
+
assert_equal 5, @vlad.test
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_set_lazy_block_evaluation
|
169
|
+
set(:test) { fail "lose" }
|
170
|
+
assert_raise(RuntimeError) { @vlad.test }
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_set_with_block
|
174
|
+
x = 1
|
175
|
+
set(:test) { x += 2 }
|
176
|
+
|
177
|
+
assert_equal 3, @vlad.test
|
178
|
+
assert_equal 3, @vlad.test
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_set_with_reference
|
182
|
+
@vlad.instance_eval do
|
183
|
+
set(:var_one) { var_two }
|
184
|
+
set(:var_two) { var_three }
|
185
|
+
set(:var_three) { 5 }
|
186
|
+
end
|
187
|
+
|
188
|
+
assert_equal 5, @vlad.var_one
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_set_with_block_and_value
|
192
|
+
e = assert_raise(ArgumentError) do
|
193
|
+
set(:test, 5) { 6 }
|
194
|
+
end
|
195
|
+
assert_equal "cannot provide both a value and a block", e.message
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_set_with_nil
|
199
|
+
set(:test, nil)
|
200
|
+
assert_equal nil, @vlad.test
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_set_with_reserved_name
|
204
|
+
$TESTING = false
|
205
|
+
e = assert_raise(ArgumentError) { set(:all_hosts, []) }
|
206
|
+
assert_equal "cannot set reserved name: 'all_hosts'", e.message
|
207
|
+
ensure
|
208
|
+
$TESTING = true
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test/vlad_test_case'
|
2
|
+
require 'vlad'
|
3
|
+
require 'vlad/git'
|
4
|
+
|
5
|
+
class TestVladGit < VladTestCase
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@scm = Vlad::Git.new
|
9
|
+
set :code_repo, "git@myhost:/home/john/project1"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_checkout
|
13
|
+
# Checkout to the current directory (which is what the :update task passes)
|
14
|
+
cmd = @scm.checkout 'master', '.'
|
15
|
+
assert_equal 'rm -rf repo && git clone git@myhost:/home/john/project1 repo && cd repo && git checkout -f -b deployed-master master', cmd
|
16
|
+
|
17
|
+
# Mimic :update task
|
18
|
+
# 'head' should become HEAD
|
19
|
+
cmd = @scm.checkout 'head', '.'
|
20
|
+
assert_equal 'rm -rf repo && git clone git@myhost:/home/john/project1 repo && cd repo && git checkout -f -b deployed-HEAD HEAD', cmd
|
21
|
+
|
22
|
+
# Checkout to a relative path
|
23
|
+
cmd = @scm.checkout 'master', 'some/relative/path'
|
24
|
+
assert_equal 'rm -rf some/relative/path && git clone git@myhost:/home/john/project1 some/relative/path && cd some/relative/path && git checkout -f -b deployed-master master', cmd
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_export
|
28
|
+
cmd = @scm.export 'master', 'the/release/path'
|
29
|
+
assert_equal 'mkdir -p the/release/path && git archive --format=tar master | (cd the/release/path && tar xf -)', cmd
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_revision
|
33
|
+
['head', 'HEAD'].each do |head|
|
34
|
+
cmd = @scm.revision(head)
|
35
|
+
expected = "`git rev-parse HEAD`"
|
36
|
+
assert_equal expected, cmd
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'stringio'
|
3
|
+
require 'vlad'
|
4
|
+
|
5
|
+
class StringIO
|
6
|
+
def readpartial(size) read end # suck!
|
7
|
+
end
|
8
|
+
|
9
|
+
module Process
|
10
|
+
def self.expected status
|
11
|
+
@@expected ||= []
|
12
|
+
@@expected << status
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.waitpid2(pid)
|
16
|
+
[ @@expected.shift ]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
class Rake::RemoteTask
|
22
|
+
attr_accessor :commands, :action, :input, :output, :error
|
23
|
+
|
24
|
+
Status = Struct.new :exitstatus
|
25
|
+
|
26
|
+
class Status
|
27
|
+
def success?() exitstatus == 0 end
|
28
|
+
end
|
29
|
+
|
30
|
+
def system *command
|
31
|
+
@commands << command
|
32
|
+
self.action ? self.action[command.join(' ')] : true
|
33
|
+
end
|
34
|
+
|
35
|
+
def popen4 *command
|
36
|
+
@commands << command
|
37
|
+
|
38
|
+
@input = StringIO.new
|
39
|
+
out = StringIO.new @output.shift.to_s
|
40
|
+
err = StringIO.new @error.shift.to_s
|
41
|
+
|
42
|
+
raise if block_given?
|
43
|
+
|
44
|
+
status = self.action ? self.action[command.join(' ')] : 0
|
45
|
+
Process.expected Status.new(status)
|
46
|
+
|
47
|
+
return 42, @input, out, err
|
48
|
+
end
|
49
|
+
|
50
|
+
def select reads, writes, errs, timeout
|
51
|
+
[reads, writes, errs]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
class VladTestCase < Test::Unit::TestCase
|
57
|
+
undef_method :default_test
|
58
|
+
|
59
|
+
def setup
|
60
|
+
@vlad = Rake::RemoteTask
|
61
|
+
@vlad.reset
|
62
|
+
Rake.application.clear
|
63
|
+
@task_count = Rake.application.tasks.size
|
64
|
+
@vlad.set :domain, "example.com"
|
65
|
+
end
|
66
|
+
|
67
|
+
def util_set_hosts
|
68
|
+
@vlad.host "app.example.com", :app
|
69
|
+
@vlad.host "db.example.com", :db
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: m7d-vlad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Davis
|
8
|
+
- Eric Hodel
|
9
|
+
- Wilson Bilkovich
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2009-01-13 00:00:00 -08:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rake
|
19
|
+
type: :runtime
|
20
|
+
version_requirement:
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.0.0
|
26
|
+
version:
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: open4
|
29
|
+
type: :runtime
|
30
|
+
version_requirement:
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.0.0
|
36
|
+
version:
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hoe
|
39
|
+
type: :runtime
|
40
|
+
version_requirement:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.1
|
46
|
+
version:
|
47
|
+
description: "Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync. Impale your application on the heartless spike of the Deployer. == FEATURES/PROBLEMS: * Full deployment automation stack. * Turnkey deployment for mongrel+apache+svn. * Supports single server deployment with just 3 variables defined. * Built on rake. Easy. Engine is small. * Very few dependencies. All simple. * Uses ssh with your ssh settings already in place. * Uses rsync for efficient transfers. * Run remote commands on one or more servers. * Mix and match local and remote tasks. * Compatible with all of your tab completion shell script rake-tastic goodness. * Ships with tests that actually pass in 0.028 seconds! * Does NOT support Windows right now (we think). Coming soon in 1.2."
|
48
|
+
email: ryand-ruby@zenspider.com
|
49
|
+
executables: []
|
50
|
+
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
extra_rdoc_files:
|
54
|
+
- History.txt
|
55
|
+
- Manifest.txt
|
56
|
+
- README.txt
|
57
|
+
- considerations.txt
|
58
|
+
- doco/faq.txt
|
59
|
+
- doco/getting_started.txt
|
60
|
+
- doco/migration.txt
|
61
|
+
- doco/variables.txt
|
62
|
+
files:
|
63
|
+
- History.txt
|
64
|
+
- Manifest.txt
|
65
|
+
- README.txt
|
66
|
+
- Rakefile
|
67
|
+
- considerations.txt
|
68
|
+
- doco/faq.txt
|
69
|
+
- doco/getting_started.txt
|
70
|
+
- doco/migration.txt
|
71
|
+
- doco/variables.txt
|
72
|
+
- lib/rake_remote_task.rb
|
73
|
+
- lib/vlad.rb
|
74
|
+
- lib/vlad/core.rb
|
75
|
+
- lib/vlad/git.rb
|
76
|
+
- lib/vlad/maintenance.rb
|
77
|
+
- test/test_rake_remote_task.rb
|
78
|
+
- test/test_vlad.rb
|
79
|
+
- test/test_vlad_git.rb
|
80
|
+
- test/vlad_test_case.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://rubyhitsquad.com/
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- --main
|
86
|
+
- README.txt
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: "0"
|
100
|
+
version:
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project: hitsquad
|
104
|
+
rubygems_version: 1.2.0
|
105
|
+
signing_key:
|
106
|
+
specification_version: 2
|
107
|
+
summary: Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync.
|
108
|
+
test_files:
|
109
|
+
- test/test_rake_remote_task.rb
|
110
|
+
- test/test_vlad.rb
|
111
|
+
- test/test_vlad_git.rb
|