isst-vlad 2.0.1

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.
@@ -0,0 +1,209 @@
1
+ require 'test_case'
2
+
3
+ $TESTING = true
4
+
5
+ class TestVlad < Rake::TestCase
6
+ def test_all_hosts
7
+ util_set_hosts
8
+ assert_equal %w[app.example.com db.example.com], @rake.all_hosts
9
+ end
10
+
11
+ def test_fetch
12
+ set :foo, 5
13
+ assert_equal 5, @rake.fetch(:foo)
14
+ end
15
+
16
+ def test_fetch_with_default
17
+ assert_equal 5, @rake.fetch(:not_here, 5)
18
+ end
19
+
20
+ def test_host
21
+ @rake.host "test.example.com", :app, :db
22
+ expected = {"test.example.com" => {}}
23
+ assert_equal expected, @rake.roles[:app]
24
+ assert_equal expected, @rake.roles[:db]
25
+ end
26
+
27
+ def test_host_invalid
28
+ assert_raises(ArgumentError) { @rake.host nil, :web }
29
+ end
30
+
31
+ def test_host_multiple_hosts
32
+ @rake.host "test.example.com", :app, :db
33
+ @rake.host "yarr.example.com", :app, :db, :no_release => true
34
+
35
+ expected = {
36
+ "test.example.com" => {},
37
+ "yarr.example.com" => {:no_release => true}
38
+ }
39
+
40
+ assert_equal expected, @rake.roles[:app]
41
+ assert_equal expected, @rake.roles[:db]
42
+ refute_equal(@rake.roles[:db]["test.example.com"].object_id,
43
+ @rake.roles[:app]["test.example.com"].object_id)
44
+ end
45
+
46
+ def test_hosts_for_array_of_roles
47
+ util_set_hosts
48
+ assert_equal %w[app.example.com db.example.com], @rake.hosts_for([:app, :db])
49
+ end
50
+
51
+ def test_hosts_for_one_role
52
+ util_set_hosts
53
+ @rake.host "app2.example.com", :app
54
+ assert_equal %w[app.example.com app2.example.com], @rake.hosts_for(:app)
55
+ end
56
+
57
+ def test_hosts_for_multiple_roles
58
+ util_set_hosts
59
+ assert_equal %w[app.example.com db.example.com], @rake.hosts_for(:app, :db)
60
+ end
61
+
62
+ def test_hosts_for_unique
63
+ util_set_hosts
64
+ @rake.host "app.example.com", :web
65
+ assert_equal %w[app.example.com db.example.com], @rake.hosts_for(:app, :db, :web)
66
+ end
67
+
68
+ def test_initialize
69
+ @rake.set_defaults # ensure these three are virginal
70
+ assert_raises(Rake::ConfigurationError) { @rake.repository }
71
+ assert_raises(Rake::ConfigurationError) { @rake.deploy_to }
72
+ assert_raises(Rake::ConfigurationError) { @rake.domain }
73
+ end
74
+
75
+ def test_role
76
+ @rake.role :app, "test.example.com"
77
+ expected = {"test.example.com" => {}}
78
+ assert_equal expected, @rake.roles[:app]
79
+ end
80
+
81
+ def test_role_multiple_hosts
82
+ @rake.role :app, "test.example.com"
83
+ @rake.role :app, "yarr.example.com", :no_release => true
84
+ expected = {
85
+ "test.example.com" => {},
86
+ "yarr.example.com" => {:no_release => true}
87
+ }
88
+ assert_equal expected, @rake.roles[:app]
89
+ end
90
+
91
+ def test_role_multiple_roles
92
+ @rake.role :app, "test.example.com", :primary => true
93
+ @rake.role :db, "yarr.example.com", :no_release => true
94
+ expected_db = { "yarr.example.com" => {:no_release => true} }
95
+ assert_equal expected_db, @rake.roles[:db]
96
+ expected_app = { "test.example.com" => {:primary => true} }
97
+ assert_equal expected_app, @rake.roles[:app]
98
+ end
99
+
100
+ def test_remote_task
101
+ t = @rake.remote_task(:test_task) { 5 }
102
+ assert_equal @task_count + 1, Rake.application.tasks.size
103
+ assert_equal({ :roles => [] }, t.options)
104
+ end
105
+
106
+ def test_remote_task_all_hosts_by_default
107
+ util_set_hosts
108
+ t = @rake.remote_task(:test_task) { 5 }
109
+ assert_equal %w[app.example.com db.example.com], t.target_hosts
110
+ end
111
+
112
+ def test_remote_task_environment_override
113
+ old_env_hosts = ENV["HOSTS"]
114
+ ENV["HOSTS"] = 'other1.example.com, other2.example.com'
115
+ util_set_hosts
116
+ t = @rake.remote_task(:test_task) { 5 }
117
+ assert_equal %w[other1.example.com other2.example.com], t.target_hosts
118
+ ensure
119
+ ENV["HOSTS"] = old_env_hosts
120
+ end
121
+
122
+ def test_remote_task_body_set
123
+ set(:some_variable, 5)
124
+ @rake.host 'www.example.com', :app
125
+ @rake.remote_task(:some_task) do $some_task_result = some_variable end
126
+
127
+ Rake::Task['some_task'].execute nil
128
+ assert_equal @rake.fetch(:some_variable), $some_task_result
129
+ end
130
+
131
+ def test_remote_task_with_options
132
+ t = @rake.remote_task :test_task, :roles => [:app, :db] do
133
+ fail "should not run"
134
+ end
135
+ assert_equal({:roles => [:app, :db]}, t.options)
136
+ end
137
+
138
+ def test_remote_task_before_host_declaration
139
+ t = @rake.remote_task :test_task, :roles => :web do 5 end
140
+ @rake.host 'www.example.com', :web
141
+ assert_equal %w[www.example.com], t.target_hosts
142
+ end
143
+
144
+ def test_remote_task_role_override
145
+ host "db1", :db
146
+ host "db2", :db
147
+ host "db3", :db
148
+ host "master", :master_db
149
+
150
+ remote_task(:migrate_the_db, :roles => [:db]) { flunk "bad!" }
151
+ task = Rake::Task["migrate_the_db"]
152
+ assert_equal %w[db1 db2 db3], task.target_hosts
153
+
154
+ task.options[:roles] = :master_db
155
+ assert_equal %w[master], task.target_hosts
156
+
157
+ task.options[:roles] = [:master_db]
158
+ assert_equal %w[master], task.target_hosts
159
+ end
160
+
161
+ def test_set
162
+ set :win, 5
163
+ assert_equal 5, @rake.win
164
+ end
165
+
166
+ def test_set_lazy_block_evaluation
167
+ set(:lose) { raise "lose" }
168
+ assert_raises(RuntimeError) { @rake.lose }
169
+ end
170
+
171
+ def test_set_with_block
172
+ x = 1
173
+ set(:win) { x += 2 }
174
+
175
+ assert_equal 3, @rake.win
176
+ assert_equal 3, @rake.win
177
+ end
178
+
179
+ def test_set_with_reference
180
+ @rake.instance_eval do
181
+ set(:var_one) { var_two }
182
+ set(:var_two) { var_three }
183
+ set(:var_three) { 5 }
184
+ end
185
+
186
+ assert_equal 5, @rake.var_one
187
+ end
188
+
189
+ def test_set_with_block_and_value
190
+ e = assert_raises(ArgumentError) do
191
+ set(:loser, 5) { 6 }
192
+ end
193
+ assert_equal "cannot provide both a value and a block", e.message
194
+ end
195
+
196
+ def test_set_with_nil
197
+ set(:win, nil)
198
+ assert_equal nil, @rake.win
199
+ end
200
+
201
+ def test_set_with_reserved_name
202
+ $TESTING = false
203
+ e = assert_raises(ArgumentError) { set(:all_hosts, []) }
204
+ assert_equal "cannot set reserved name: 'all_hosts'", e.message
205
+ ensure
206
+ $TESTING = true
207
+ end
208
+ end
209
+
@@ -0,0 +1,65 @@
1
+ require 'test_case'
2
+ require 'vlad'
3
+ require 'vlad/git'
4
+ require 'mocha'
5
+
6
+ class TestVladGit < Rake::TestCase
7
+ def setup
8
+ super
9
+ @scm = Vlad::Git.new
10
+ @scm.stubs(:fast_checkout_applicable?).returns(false)
11
+
12
+ @scm_fast = Vlad::Git.new
13
+ @scm_fast.stubs(:fast_checkout_applicable?).returns(true)
14
+
15
+ set :repository, "git@myhost:/home/john/project1"
16
+ end
17
+
18
+ # Checkout the way the default :update task invokes the method
19
+ def test_checkout
20
+ cmd = @scm.checkout 'head', '/the/scm/path'
21
+ assert_equal 'rm -rf /the/scm/path/repo && git clone git@myhost:/home/john/project1 /the/scm/path/repo && cd /the/scm/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-HEAD HEAD && cd -', cmd
22
+ end
23
+
24
+ # (fast-mode) Checkout the way the default :update task invokes the method
25
+ def test_checkout_fast
26
+ cmd = @scm_fast.checkout 'head', '/the/scm/path'
27
+ assert_equal 'cd /the/scm/path/repo && git checkout -q origin && git fetch && git reset --hard HEAD && git submodule init && git submodule update && git branch -f deployed-HEAD HEAD && git checkout deployed-HEAD && cd -', cmd
28
+ end
29
+
30
+ # This is not how the :update task invokes the method
31
+ def test_checkout_revision
32
+ # Checkout to the current directory
33
+ cmd = @scm.checkout 'master', '.'
34
+ assert_equal 'rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd
35
+
36
+ # Checkout to a relative path
37
+ cmd = @scm.checkout 'master', 'some/relative/path'
38
+ assert_equal 'rm -rf some/relative/path/repo && git clone git@myhost:/home/john/project1 some/relative/path/repo && cd some/relative/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd
39
+ end
40
+
41
+ # (fast-mode) This is not how the :update task invokes the method
42
+ def test_checkout_revision_fast
43
+ # Checkout to the current directory
44
+ cmd = @scm_fast.checkout 'master', '.'
45
+ assert_equal 'cd ./repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
46
+
47
+ cmd = @scm_fast.checkout 'master', 'some/relative/path'
48
+ assert_equal 'cd some/relative/path/repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
49
+ end
50
+
51
+ def test_export
52
+ # default mode
53
+ cmd = @scm.export 'master', 'the/release/path'
54
+ assert_equal "mkdir -p the/release/path && cd repo && git archive --format=tar deployed-master | (cd the/release/path && tar xf -) && git submodule foreach 'git archive --format=tar \$sha1 | (cd the/release/path/\$path && tar xf -)' && cd - && cd ..", cmd
55
+ end
56
+
57
+ def test_revision
58
+ ['head', 'HEAD'].each do |head|
59
+ cmd = @scm.revision(head)
60
+ expected = "`git rev-parse HEAD`"
61
+ assert_equal expected, cmd
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,26 @@
1
+ require 'vlad'
2
+ require 'vlad/subversion'
3
+
4
+ class TestVladSubversion < MiniTest::Unit::TestCase
5
+ def setup
6
+ super
7
+ @scm = Vlad::Subversion.new
8
+ set :repository, "svn+ssh://repo/myproject"
9
+ end
10
+
11
+ def test_checkout
12
+ cmd = @scm.checkout 'HEAD', '/the/place'
13
+ assert_equal 'svn co -r HEAD svn+ssh://repo/myproject /the/place', cmd
14
+ end
15
+
16
+ def test_export
17
+ cmd = @scm.export 'HEAD', '/the/place'
18
+ assert_equal 'svn export -r HEAD svn+ssh://repo/myproject /the/place', cmd
19
+ end
20
+
21
+ def test_revision
22
+ cmd = @scm.revision('HEAD')
23
+ expected = "`svn info svn+ssh://repo/myproject | grep 'Revision:' | cut -f2 -d\\ `"
24
+ assert_equal expected, cmd
25
+ end
26
+ end
@@ -0,0 +1,97 @@
1
+ #!/bin/bash
2
+
3
+ N=$1; shift
4
+
5
+ killall mongrel svnserve 2> /dev/null
6
+
7
+ rm -rf ~/demo
8
+ mkdir ~/demo
9
+ cd ~/demo
10
+
11
+ pause() {
12
+ echo -n "waiting... hit return... "
13
+ read
14
+ echo
15
+ }
16
+
17
+ echo "Starting demo from scratch"
18
+ echo " This step creates a subversion repository and imports a new rails app"
19
+ echo " It modifies the Rakefile to load Vlad and creates config/deploy.rb"
20
+ echo
21
+ pause
22
+
23
+ svnadmin create svnrepo
24
+ echo "anon-access = write" >> svnrepo/conf/svnserve.conf
25
+
26
+ svnserve -d --foreground -r svnrepo --listen-host localhost &
27
+
28
+ echo "cd ~/demo
29
+ rm -rf website_*
30
+ svnserve -d --foreground -r svnrepo --listen-host localhost &
31
+
32
+ cd mydemoapp
33
+ ruby -I ~/Work/p4/zss/src/vlad/dev/lib -S rake -t vlad:setup vlad:update
34
+
35
+ kill %1" > go.sh
36
+ chmod u+x go.sh
37
+
38
+ rails mydemoapp
39
+
40
+ cd mydemoapp
41
+
42
+ echo "require 'rubygems'
43
+ require 'vlad'
44
+ Vlad.load" >> Rakefile
45
+
46
+ echo "set :repository, 'svn://localhost/blah'
47
+ set :domain, 'localhost'
48
+ set :web_command, 'sudo apachectl'" > config/deploy.rb
49
+
50
+ # TODO: add a knob
51
+ if [ -n "$N" ]; then
52
+ echo "set(:deploy_to, :per_thread) {
53
+ File.expand_path(\"~/demo/website_#{target_host}\")
54
+ }
55
+
56
+ %w(current_path current_release latest_release
57
+ previous_release releases_path release_path
58
+ scm_path shared_path).each do |name|
59
+ Rake::RemoteTask.per_thread[name] = true
60
+ end
61
+
62
+ (1..$N).each do |n|
63
+ host 'localhost%02d' % n, :web, :app
64
+ end" >> config/deploy.rb
65
+ else
66
+ echo "set :deploy_to, File.expand_path('~/demo/website')" >> config/deploy.rb
67
+ fi
68
+
69
+ svn import -m Added . svn://localhost/blah
70
+
71
+ echo
72
+ echo "Here is your config:"
73
+ cat config/deploy.rb
74
+ echo
75
+ echo "Here are the tasks available:"
76
+ echo
77
+
78
+ ruby -I ~/Work/p4/zss/src/vlad/dev/lib -S rake -T vlad
79
+
80
+ echo
81
+ echo "The next step deploys and fires up the application"
82
+ echo
83
+ pause
84
+
85
+ ruby -I ~/Work/p4/zss/src/vlad/dev/lib -S rake -t vlad:setup vlad:update vlad:start
86
+
87
+ open http://localhost:8000/
88
+
89
+ echo
90
+ echo "done! check it out"
91
+ echo
92
+ pause
93
+
94
+ ruby -I ~/Work/p4/zss/src/vlad/dev/lib -S rake vlad:stop
95
+
96
+ kill %1
97
+
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isst-vlad
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 1
10
+ version: 2.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Davis
14
+ - Eric Hodel
15
+ - Wilson Bilkovich
16
+ - Aaron Suggs
17
+ - Ryan Richins
18
+ autorequire:
19
+ bindir: bin
20
+ cert_chain: []
21
+
22
+ date: 2010-06-06 00:00:00 -04:00
23
+ default_executable:
24
+ dependencies:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ prerelease: false
28
+ requirement: &id001 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ hash: 63
34
+ segments:
35
+ - 0
36
+ - 8
37
+ - 0
38
+ version: 0.8.0
39
+ type: :runtime
40
+ version_requirements: *id001
41
+ - !ruby/object:Gem::Dependency
42
+ name: open4
43
+ prerelease: false
44
+ requirement: &id002 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 59
50
+ segments:
51
+ - 0
52
+ - 9
53
+ - 0
54
+ version: 0.9.0
55
+ type: :runtime
56
+ version_requirements: *id002
57
+ description: |
58
+
59
+ Vlad the Deployer is pragmatic application deployment automation,
60
+ without mercy. Much like Capistrano, but with 1/10th the
61
+ complexity. Vlad integrates seamlessly with Rake, and uses familiar
62
+ and standard tools like ssh and rsync. This is a fork of vlad maintained by
63
+ NETO ISS Tools (Dudes at Comcast). See PATCHES.txt for more info""
64
+
65
+ email:
66
+ - ryand-ruby@zenspider.com
67
+ - drbrain@segment7.net
68
+ - wilson@supremetyrant.com
69
+ - aaron@ktheory.com
70
+ - Ryan_Richins@cable.comcast.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files:
76
+ - README.txt
77
+ files:
78
+ - .autotest
79
+ - History.txt
80
+ - PATCHES.txt
81
+ - README.txt
82
+ - Rakefile
83
+ - VERSION
84
+ - considerations.txt
85
+ - doco/deploying-merb-with-vlad.txt
86
+ - doco/deploying-sinatra-with-vlad.txt
87
+ - doco/faq.txt
88
+ - doco/getting_started.txt
89
+ - doco/migration.txt
90
+ - doco/perforce.txt
91
+ - doco/variables.txt
92
+ - isst-vlad.gemspec
93
+ - lib/remote_task.rb
94
+ - lib/test_case.rb
95
+ - lib/vlad.rb
96
+ - lib/vlad/apache.rb
97
+ - lib/vlad/core.rb
98
+ - lib/vlad/git.rb
99
+ - lib/vlad/maintenance.rb
100
+ - lib/vlad/merb.rb
101
+ - lib/vlad/nginx.rb
102
+ - lib/vlad/passenger.rb
103
+ - lib/vlad/rails.rb
104
+ - lib/vlad/sequel.rb
105
+ - lib/vlad/sinatra.rb
106
+ - lib/vlad/subversion.rb
107
+ - lib/vlad/thin.rb
108
+ - test/test_remote_task.rb
109
+ - test/test_vlad.rb
110
+ - test/test_vlad_git.rb
111
+ - test/test_vlad_subversion.rb
112
+ - vladdemo.sh
113
+ has_rdoc: true
114
+ homepage: http://github.com/netoisstools/isst-vlad
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options:
119
+ - --charset=UTF-8
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.7
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Vlad the Deployer is pragmatic application deployment automation, without mercy [isst fork]
147
+ test_files:
148
+ - test/test_remote_task.rb
149
+ - test/test_vlad.rb
150
+ - test/test_vlad_git.rb
151
+ - test/test_vlad_subversion.rb