tdd_deploy 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Capfile +5 -3
- data/lib/tdd_deploy/base.rb +0 -10
- data/lib/tdd_deploy/copy_methods.rb +8 -8
- data/lib/tdd_deploy/deploy_test_methods.rb +14 -19
- data/lib/tdd_deploy/environ.rb +15 -0
- data/lib/tdd_deploy/host_tests/host_connection.rb +2 -2
- data/lib/tdd_deploy/host_tests/remote_ip_tables.rb +2 -2
- data/lib/tdd_deploy/host_tests/remote_monit.rb +2 -2
- data/lib/tdd_deploy/host_tests/remote_nginx.rb +2 -2
- data/lib/tdd_deploy/host_tests/remote_postfix.rb +2 -2
- data/lib/tdd_deploy/host_tests/remote_postgresql.rb +2 -2
- data/lib/tdd_deploy/installer.rb +38 -0
- data/lib/tdd_deploy/local_tests/smoke_test.rb +2 -2
- data/lib/tdd_deploy/run_methods.rb +3 -2
- data/lib/tdd_deploy/server-templates/test_results.html.erb +19 -9
- data/lib/tdd_deploy/server.rb +35 -4
- data/lib/tdd_deploy/site_tests/site_database.rb +2 -2
- data/lib/tdd_deploy/site_tests/site_layout.rb +5 -5
- data/lib/tdd_deploy/site_tests/site_rvm.rb +2 -2
- data/lib/tdd_deploy/site_tests/site_user.rb +2 -2
- data/lib/tdd_deploy/test_base.rb +37 -0
- data/lib/tdd_deploy/version.rb +1 -1
- data/tests/test_base.rb +1 -2
- data/tests/test_copy_methods.rb +23 -23
- data/tests/test_deploy_test_methods.rb +12 -5
- data/tests/test_installer.rb +42 -0
- data/tests/test_run_methods.rb +6 -6
- data/tests/test_server.rb +4 -1
- data/tests/test_test_base.rb +37 -0
- metadata +17 -13
data/Capfile
CHANGED
@@ -6,7 +6,9 @@ role :hosts, "arch"
|
|
6
6
|
#role :hosts, "ubuntu"
|
7
7
|
# role :hosts, 'li371-193.members.linode.com'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
namespace :deploy do
|
10
|
+
desc "Moc deploy:update"
|
11
|
+
task :update do
|
12
|
+
system "echo 'mock deloy:update'"
|
13
|
+
end
|
12
14
|
end
|
data/lib/tdd_deploy/base.rb
CHANGED
@@ -36,15 +36,5 @@ module TddDeploy
|
|
36
36
|
self.env_hash || read_env || reset_env
|
37
37
|
set_env(args.pop) if args.last.is_a? Hash
|
38
38
|
end
|
39
|
-
|
40
|
-
# gather up all descendents so we know what tests to run
|
41
|
-
class <<self
|
42
|
-
attr_accessor :children
|
43
|
-
|
44
|
-
def inherited(child)
|
45
|
-
self.children ||= []
|
46
|
-
self.children << child
|
47
|
-
end
|
48
|
-
end
|
49
39
|
end
|
50
40
|
end
|
@@ -13,7 +13,7 @@ module TddDeploy
|
|
13
13
|
result
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def copy_file_to_remote_hosts_as userid, host_list, src, dst
|
17
17
|
result = true
|
18
18
|
host_list = [host_list] if host_list.is_a? String
|
19
19
|
host_list.uniq.each do |host|
|
@@ -22,8 +22,8 @@ module TddDeploy
|
|
22
22
|
result
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
raise ::ArgumentError.new("
|
25
|
+
def copy_dir_to_remote_hosts_as(userid, host_list, src_dir, dest_dir)
|
26
|
+
raise ::ArgumentError.new("copy_dir_to_remote_hosts_as: src_dir does not exist: #{src_dir}") \
|
27
27
|
unless File.directory? src_dir
|
28
28
|
host_list = [host_list] if host_list.is_a? String
|
29
29
|
result = true
|
@@ -33,7 +33,7 @@ module TddDeploy
|
|
33
33
|
Dir.open(src_dir).each do |fname|
|
34
34
|
next if fname[0] == '.'
|
35
35
|
path = File.join(src_dir, fname)
|
36
|
-
result &=
|
36
|
+
result &= copy_file_to_remote_hosts_as userid, host_list, path, File.join(dest_dir, fname)
|
37
37
|
end
|
38
38
|
result
|
39
39
|
end
|
@@ -47,7 +47,7 @@ module TddDeploy
|
|
47
47
|
result
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def append_file_to_remote_hosts_as userid, host_list, src, dst
|
51
51
|
result = true
|
52
52
|
host_list = [host_list] if host_list.is_a? String
|
53
53
|
host_list.uniq.each do |host|
|
@@ -56,8 +56,8 @@ module TddDeploy
|
|
56
56
|
result
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
raise ::ArgumentError.new("
|
59
|
+
def append_dir_to_remote_hosts_as(userid, host_list, src_dir, dest_dir)
|
60
|
+
raise ::ArgumentError.new("append_dir_to_remote_hosts_as: src_dir does not exist: #{src_dir}") \
|
61
61
|
unless File.directory? src_dir
|
62
62
|
host_list = [host_list] if host_list.is_a? String
|
63
63
|
result = true
|
@@ -67,7 +67,7 @@ module TddDeploy
|
|
67
67
|
Dir.open(src_dir).each do |fname|
|
68
68
|
next if fname[0] == '.'
|
69
69
|
path = File.join(src_dir, fname)
|
70
|
-
result &=
|
70
|
+
result &= append_file_to_remote_hosts_as userid, host_list, path, File.join(dest_dir, fname)
|
71
71
|
end
|
72
72
|
result
|
73
73
|
end
|
@@ -14,12 +14,13 @@ module TddDeploy
|
|
14
14
|
#
|
15
15
|
# the most frequently used are 'deploy_test_process_running_on_hosts_as' and 'deploy_test_file_exists_on_hosts_as'.
|
16
16
|
#
|
17
|
-
# 'deploy_test_on_hosts_as' and '
|
17
|
+
# 'deploy_test_on_hosts_as' and 'deploy_test_on_a_host_as' are more primative and flexible.
|
18
18
|
module DeployTestMethods
|
19
19
|
include TddDeploy::Assertions
|
20
20
|
include TddDeploy::RunMethods
|
21
21
|
|
22
22
|
def deploy_test_process_running_on_hosts_as(userid, host_list, pid_file_path, success_msg = nil)
|
23
|
+
host_list = rationalize_host_list(host_list)
|
23
24
|
success_msg ||= "Process associated with #{pid_file_path} should be running"
|
24
25
|
ret = deploy_test_file_exists_on_hosts_as(userid, host_list, pid_file_path, success_msg + " no such pid file: #{pid_file_path}") ||
|
25
26
|
ret &= deploy_test_on_hosts_as(userid, host_list, /.+\n\s*\d+.*?\d\d:\d\d:\d\d/, "Process for #{pid_file_path} is running") do
|
@@ -40,38 +41,32 @@ module TddDeploy
|
|
40
41
|
# 'match_expr_or_str' can be a Regexp or a string (which will be converted to a Regexp)
|
41
42
|
def deploy_test_on_hosts_as userid, host_list, match_expr_or_str, success_msg, &block
|
42
43
|
ret = true
|
43
|
-
host_list =
|
44
|
+
host_list = rationalize_host_list(host_list)
|
44
45
|
host_list.uniq.each do |host|
|
45
|
-
ret &=
|
46
|
+
ret &= deploy_test_on_a_host_as userid, host, match_expr_or_str, success_msg, &block
|
46
47
|
end
|
47
48
|
ret
|
48
49
|
end
|
49
50
|
|
50
|
-
#
|
51
|
+
# deploy_test_on_a_host_as runs the command(s) return by '&block' on the specified host
|
51
52
|
# as user 'userid'
|
52
53
|
# declares an error if EITHER STDOUT does not match 'match' OR STDERR returns anything
|
53
54
|
# 'match' can be a Regexp or a string (which will be converted to a Regexp)
|
54
|
-
def
|
55
|
+
def deploy_test_on_a_host_as(userid, host, match, success_msg, &block)
|
55
56
|
match = Regexp.new(match) if match.is_a? String
|
56
57
|
raise ArgumentError, 'match expression cannot be empty' if match =~ ''
|
57
58
|
|
58
|
-
rsp, err_rsp, cmd =
|
59
|
-
|
60
|
-
result = err_rsp.nil?
|
61
|
-
|
59
|
+
rsp, err_rsp, cmd = run_on_a_host_as(userid, host, &block)
|
62
60
|
prefix = "user@host: #{userid}@#{host}: #{success_msg}"
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
fail host, "#{prefix}: stdout is empty for command '#{cmd}'"
|
69
|
-
|
70
|
-
|
71
|
-
result &= false
|
62
|
+
if err_rsp
|
63
|
+
return fail host, "#{prefix}: command generated error data:\n" +
|
64
|
+
" command: #{cmd}\n stdout: '#{rsp}'\n stderr: '#{err_rsp}'"
|
65
|
+
elsif rsp.nil?
|
66
|
+
return fail host, "#{prefix}: stdout is empty for command '#{cmd}'"
|
67
|
+
else
|
68
|
+
return assert_match host, match, rsp, prefix
|
72
69
|
end
|
73
|
-
|
74
|
-
result
|
75
70
|
end
|
76
71
|
end
|
77
72
|
end
|
data/lib/tdd_deploy/environ.rb
CHANGED
@@ -392,5 +392,20 @@ module TddDeploy
|
|
392
392
|
def migration_hosts
|
393
393
|
self.capfile.migration_host_list
|
394
394
|
end
|
395
|
+
|
396
|
+
# takes the name of a list (as a string or symbol), a single string, or an array of host names
|
397
|
+
def rationalize_host_list(host_list_or_list_name)
|
398
|
+
if host_list_or_list_name.is_a? String
|
399
|
+
return self.respond_to?(host_list_or_list_name.to_sym) ? self.send(host_list_or_list_name.to_sym) :
|
400
|
+
[host_list_or_list_name]
|
401
|
+
elsif host_list_or_list_name.is_a? Symbol
|
402
|
+
return self.respond_to?(host_list_or_list_name) ? self.send(host_list_or_list_name) :
|
403
|
+
[host_list_or_list_name.to_s]
|
404
|
+
elsif host_list_or_list_name.is_a? Array
|
405
|
+
return host_list_or_list_name.map { |host| host.to_s }
|
406
|
+
else
|
407
|
+
raise ArgumentError.new("rationalize_host_list(#{host_list_or_list_name.inspect}) is invalid")
|
408
|
+
end
|
409
|
+
end
|
395
410
|
end
|
396
411
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::HostConnection
|
5
5
|
#
|
6
6
|
# tests that hosts are pingable and that the current user can log in as both 'host_admin' and 'root'
|
7
|
-
class HostConnection < TddDeploy::
|
7
|
+
class HostConnection < TddDeploy::TestBase
|
8
8
|
# ping - pings all hosts
|
9
9
|
def ping
|
10
10
|
result = true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::RemoteIpTables
|
@@ -6,7 +6,7 @@ module TddDeploy
|
|
6
6
|
# checks to see if iptables is working by attempting to connect to each host on a collection
|
7
7
|
# of 'interesting' ports. the ports probed are: 20, 23, 25, 53, 5432, 2812
|
8
8
|
#
|
9
|
-
class RemoteIpTables < TddDeploy::
|
9
|
+
class RemoteIpTables < TddDeploy::TestBase
|
10
10
|
# tcp_some_blocked_ports - checks TCP ports
|
11
11
|
def tcp_some_blocked_ports
|
12
12
|
self.hosts.each do |host|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::RemoteMonit
|
5
5
|
#
|
6
6
|
# verifies monit executable is present and running on all hosts
|
7
|
-
class RemoteMonit < TddDeploy::
|
7
|
+
class RemoteMonit < TddDeploy::TestBase
|
8
8
|
def test_monit_installed
|
9
9
|
deploy_test_file_exists_on_hosts_as self.host_admin, self.hosts, '/usr/bin/monit', 'monit should be installed'
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::RemoteNginx
|
5
5
|
#
|
6
6
|
# verifies Nginx executable is both present and running on web_hosts + balance_hosts
|
7
|
-
class RemoteNginx < TddDeploy::
|
7
|
+
class RemoteNginx < TddDeploy::TestBase
|
8
8
|
def test_nginx_installed
|
9
9
|
deploy_test_file_exists_on_hosts_as self.host_admin, self.web_hosts + self.balance_hosts, '/usr/sbin/nginx', "nginx should be installed"
|
10
10
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::RemotePostfix
|
5
5
|
#
|
6
6
|
# verifies that postfix executable is installed, running and will accept mail to local_admin_mail
|
7
7
|
# on all hosts
|
8
|
-
class RemotePostfix < TddDeploy::
|
8
|
+
class RemotePostfix < TddDeploy::TestBase
|
9
9
|
def test_postfix_installed
|
10
10
|
deploy_test_file_exists_on_hosts_as 'root', self.hosts, '/usr/sbin/postfix', "postfix should be installed"
|
11
11
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::RemotePostgresql
|
5
5
|
#
|
6
6
|
# verifies that the postgresql exectuable is both installed and running on db_hosts
|
7
|
-
class RemotePostgresql < TddDeploy::
|
7
|
+
class RemotePostgresql < TddDeploy::TestBase
|
8
8
|
def test_postgresql_installed
|
9
9
|
deploy_test_file_exists_on_hosts_as 'root', self.db_hosts, "/usr/bin/postgres", 'postgres should be installed'
|
10
10
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'tdd_deploy/base'
|
2
|
+
require 'tdd_deploy/copy_methods'
|
3
|
+
|
4
|
+
module TddDeploy
|
5
|
+
class Installer < TddDeploy::Base
|
6
|
+
include TddDeploy::CopyMethods
|
7
|
+
|
8
|
+
def install_config_files_on_host_list_as userid, host_list_name
|
9
|
+
raise ::ArgumentError.new("install_config_files_on_host_list_as(userid, host_list_name): invalid host_list_name: #{host_list_name}") \
|
10
|
+
unless self.respond_to? host_list_name.to_sym
|
11
|
+
config_dir = File.join(self.site_doc_root, '..', 'config')
|
12
|
+
src_dir = File.join('tdd_deploy_configs', host_list_name.to_s, 'config')
|
13
|
+
copy_dir_to_remote_hosts_as userid, rationalize_host_list(host_list_name), src_dir, config_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def empty_special_dir userid, host_list_name
|
17
|
+
raise ::ArgumentError.new("install_config_files_on_host_list_as(userid, host_list_name): invalid host_list_name: #{host_list_name}") \
|
18
|
+
unless self.respond_to? host_list_name.to_sym
|
19
|
+
host_list = rationalize_host_list host_list_name
|
20
|
+
run_on_hosts_as(userid, host_list, "rm #{self.site_special_dir}/*")
|
21
|
+
end
|
22
|
+
|
23
|
+
def install_special_files_on_host_list_as userid, host_list_name
|
24
|
+
raise ::ArgumentError.new("install_config_files_on_host_list_as(userid, host_list_name): invalid host_list_name: #{host_list_name}") \
|
25
|
+
unless self.respond_to? host_list_name.to_sym
|
26
|
+
|
27
|
+
host_list = rationalize_host_list host_list_name
|
28
|
+
src_dir = File.join('tdd_deploy_configs', host_list_name.to_s, 'site')
|
29
|
+
append_dir_to_remote_hosts_as userid, host_list, src_dir, self.site_special_dir
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_cap_deploy
|
33
|
+
stdout, stderr, cmd = run_locally { 'cap deploy:update' }
|
34
|
+
return fail if stderr =~ /failed|rolling back/
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::SmokeTest
|
@@ -9,7 +9,7 @@ module TddDeploy
|
|
9
9
|
#
|
10
10
|
# * return_true
|
11
11
|
# * smoke
|
12
|
-
class SmokeTest < TddDeploy::
|
12
|
+
class SmokeTest < TddDeploy::TestBase
|
13
13
|
|
14
14
|
# returns true
|
15
15
|
def return_true
|
@@ -31,17 +31,18 @@ module TddDeploy
|
|
31
31
|
|
32
32
|
# runs supplied command on list of hosts as specified user
|
33
33
|
def run_on_hosts_as userid, host_list, cmd = nil, &block
|
34
|
+
|
34
35
|
host_list = [host_list] if host_list.is_a? String
|
35
36
|
result = {}
|
36
37
|
host_list.uniq.each do |host|
|
37
|
-
result[host] =
|
38
|
+
result[host] = run_on_a_host_as userid, host, cmd, &block
|
38
39
|
end
|
39
40
|
result
|
40
41
|
end
|
41
42
|
|
42
43
|
# Runs the command secified in &block on 'host' as user 'userid'.
|
43
44
|
# Returns an array [stdout, stderr] returned from the command.
|
44
|
-
def
|
45
|
+
def run_on_a_host_as(userid, host, cmd = nil, &block)
|
45
46
|
login = "#{userid}@#{host}"
|
46
47
|
match = Regexp.new(match) if match.is_a? String
|
47
48
|
raise ArgumentError.new('match expression cannot be empty') if match =~ ''
|
@@ -72,7 +72,13 @@ end
|
|
72
72
|
.even { background: #ccc;}
|
73
73
|
.red { color: #800;}
|
74
74
|
.green { color: #080;}
|
75
|
-
.warn {
|
75
|
+
.warn {
|
76
|
+
color: #e0ffff;
|
77
|
+
padding: 5px;
|
78
|
+
border: 1px solid black;
|
79
|
+
font-weight: normal;
|
80
|
+
background: #800000;
|
81
|
+
}
|
76
82
|
</style>
|
77
83
|
<!-- Date: 2011-08-20 -->
|
78
84
|
</head>
|
@@ -81,7 +87,7 @@ end
|
|
81
87
|
<h1>TddDeploy (<%= TddDeploy::VERSION %>) Test Results: site: <%= site %> / hosts: <%= hosts %></h1>
|
82
88
|
|
83
89
|
<% if (failures = total_failures) == 0 %>
|
84
|
-
<p id="test-summary-passed">All Tests Passed</p>
|
90
|
+
<p id="test-summary-passed">All <%= total_tests %> Tests Passed</p>
|
85
91
|
<% else %>
|
86
92
|
<p id="test-summary-failed"><%= failures %> of <%= total_tests %> Tests Failed</p>
|
87
93
|
<% end %>
|
@@ -98,11 +104,15 @@ end
|
|
98
104
|
<td><a href="/?run_configurator">Run Configurator</a></td>
|
99
105
|
<td></td>
|
100
106
|
</tr>
|
101
|
-
|
102
|
-
<th>
|
103
|
-
<td>Site Specials</td>
|
104
|
-
<td>Site Config</td>
|
105
|
-
</tr>
|
107
|
+
<tr class="<%= even_odd %>">
|
108
|
+
<th>Install</th>
|
109
|
+
<td><a href="/?install_special">Site Specials</a></td>
|
110
|
+
<td><a href="/?install_configs">Site Config</a></td>
|
111
|
+
</tr>
|
112
|
+
<tr class="<%= even_odd %>">
|
113
|
+
<th>Capistrano</th>
|
114
|
+
<td><a href="/?run_cap_deploy">run cap deploy:update</a></td>
|
115
|
+
</tr>
|
106
116
|
</table>
|
107
117
|
</div> <!-- test summary -->
|
108
118
|
|
@@ -120,10 +130,10 @@ end
|
|
120
130
|
|
121
131
|
<h3>Capistrano Variables</h3>
|
122
132
|
<% if server_obj.app_hosts.sort != (server_obj.app + server_obj.migration_hosts).uniq.sort %>
|
123
|
-
<p class="warn">'app_hosts' does not match Capistrano 'app' and 'migration_hosts'</p>
|
133
|
+
<p><span class="warn">Warning: 'app_hosts' does not match Capistrano 'app' and 'migration_hosts'</span></p>
|
124
134
|
<% end %>
|
125
135
|
<% if server_obj.db_hosts.uniq.sort != server_obj.db.uniq.sort %>
|
126
|
-
<p class="warn">'db_hosts' does not match Capistrano 'db'</p>
|
136
|
+
<p><span class="warn">Warning: 'db_hosts' does not match Capistrano 'db'</span></p>
|
127
137
|
<% end %>
|
128
138
|
<table>
|
129
139
|
<% reset_even_odd %>
|
data/lib/tdd_deploy/server.rb
CHANGED
@@ -3,6 +3,7 @@ $:.unshift File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
require 'uri'
|
5
5
|
require 'tdd_deploy'
|
6
|
+
require 'tdd_deploy/test_base'
|
6
7
|
|
7
8
|
module TddDeploy
|
8
9
|
# == TddDeploy::Server
|
@@ -60,6 +61,34 @@ module TddDeploy
|
|
60
61
|
configurator = TddDeploy::Configurator.new
|
61
62
|
configurator.make_configuration_files
|
62
63
|
end
|
64
|
+
|
65
|
+
if self.query_hash['install_special']
|
66
|
+
require 'tdd_deploy/installer'
|
67
|
+
installer = TddDeploy::Installer.new
|
68
|
+
[:app_hosts, :balance_hosts, :db_hosts, :web_hosts].each do |host_list|
|
69
|
+
installer.empty_special_dir self.site_user, host_list
|
70
|
+
end
|
71
|
+
[:app_hosts, :balance_hosts, :db_hosts, :web_hosts].each do |host_list|
|
72
|
+
installer.install_special_files_on_host_list_as self.site_user, host_list
|
73
|
+
end
|
74
|
+
query_hash['failed-tests'] = true
|
75
|
+
end
|
76
|
+
|
77
|
+
if self.query_hash['install_configs']
|
78
|
+
require 'tdd_deploy/installer'
|
79
|
+
installer ||= TddDeploy::Installer.new
|
80
|
+
[:app_hosts, :balance_hosts, :db_hosts, :web_hosts].each do |host_list|
|
81
|
+
installer.install_config_files_on_host_list_as self.site_user, host_list
|
82
|
+
end
|
83
|
+
query_hash['failed-tests'] = true
|
84
|
+
end
|
85
|
+
|
86
|
+
if self.query_hash['run_cap_deploy']
|
87
|
+
require 'tdd_deploy/installer'
|
88
|
+
installer ||= TddDeploy::Installer.new
|
89
|
+
installer.run_cap_deploy
|
90
|
+
query_hash['failed-tests'] = true
|
91
|
+
end
|
63
92
|
|
64
93
|
load_all_tests
|
65
94
|
|
@@ -83,21 +112,23 @@ module TddDeploy
|
|
83
112
|
# both host_tests and site_tests are clobbered by the rake install task.
|
84
113
|
# local_tests is safe.
|
85
114
|
def load_all_tests
|
115
|
+
# discard any already defined tests
|
116
|
+
TddDeploy::TestBase.flush_children_methods
|
117
|
+
|
118
|
+
# reload all tests
|
86
119
|
[TddDeploy::Server::HOST_TESTS_DIR, TddDeploy::Server::SITE_TESTS_DIR,
|
87
120
|
TddDeploy::Server::LOCAL_TESTS_DIR].each do |dir|
|
88
121
|
if File.exists?(dir)
|
89
122
|
# puts "gathering tests from #{dir}"
|
90
123
|
Dir.new(dir).each do |fname|
|
91
|
-
|
92
|
-
|
93
|
-
load File.join(dir, fname)
|
124
|
+
load File.join(dir, fname) if fname =~ /\.rb$/
|
94
125
|
end
|
95
126
|
else
|
96
127
|
puts "skipping #{dir} - no such directory"
|
97
128
|
end
|
98
129
|
end
|
99
130
|
|
100
|
-
self.test_classes = TddDeploy::
|
131
|
+
self.test_classes = TddDeploy::TestBase.children
|
101
132
|
|
102
133
|
@test_to_class_map = {}
|
103
134
|
self.test_classes.each do |klass|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::SiteDatabase
|
5
5
|
#
|
6
6
|
# tests to make sure a database named 'site' is defined in postgresql databases
|
7
|
-
class SiteDatabase < TddDeploy::
|
7
|
+
class SiteDatabase < TddDeploy::TestBase
|
8
8
|
|
9
9
|
def test_site_db_defined
|
10
10
|
deploy_test_on_hosts_as self.site_user, self.db_hosts, "#{self.site}\s*\|\s*#{self.site}", "database for #{self.site} should exist" do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# == TddDeploy::SiteLayout
|
@@ -15,21 +15,21 @@ module TddDeploy
|
|
15
15
|
# * '~/site/nginx.conf - an nginx configuratino fragment which tells nginx to proxy the site's *thin* servers
|
16
16
|
# * ~/site/monitrc - a monit configuration fragment which tells monit how to monitor the site's *thin* servers.
|
17
17
|
# * ~/site/one_thin_server - shell script to start a single server instance
|
18
|
-
class SiteLayout < TddDeploy::
|
18
|
+
class SiteLayout < TddDeploy::TestBase
|
19
19
|
def test_site_subdir
|
20
20
|
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{self.site_doc_root}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_releases_subdir
|
24
|
-
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{self.site_doc_root}
|
24
|
+
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{self.site_doc_root}/../../../releases"
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_thin_conf
|
28
|
-
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{site_doc_root}
|
28
|
+
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{site_doc_root}/../config/thin.conf"
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_one_thin_server_conf
|
32
|
-
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{site_doc_root}
|
32
|
+
deploy_test_file_exists_on_hosts_as self.site_user, self.web_hosts, "#{site_doc_root}/../config/one_thin_server.conf"
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_site_dir_exists
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# = TddDeploy::SiteUser
|
5
5
|
#
|
6
6
|
# tests all hosts to make sure that the local user can log on as *site_user*
|
7
|
-
class SiteRvm < TddDeploy::
|
7
|
+
class SiteRvm < TddDeploy::TestBase
|
8
8
|
def test_rvm
|
9
9
|
deploy_test_on_hosts_as self.site_user, self.app_hosts, /RVM is the Ruby/, "rvm should be installed" do
|
10
10
|
'source ~/.rvm/scripts/rvm ; rvm'
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'tdd_deploy/
|
1
|
+
require 'tdd_deploy/test_base'
|
2
2
|
|
3
3
|
module TddDeploy
|
4
4
|
# = TddDeploy::SiteUser
|
5
5
|
#
|
6
6
|
# tests all hosts to make sure that the local user can log on as *site_user*
|
7
|
-
class SiteUser < TddDeploy::
|
7
|
+
class SiteUser < TddDeploy::TestBase
|
8
8
|
def test_login_as_site_user
|
9
9
|
deploy_test_on_hosts_as self.site_user, self.hosts, "/home/#{self.site_user}", "should be able to log into host as #{self.site_user}" do
|
10
10
|
'pwd'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'tdd_deploy/base'
|
2
|
+
|
3
|
+
module TddDeploy
|
4
|
+
# == TddDeploy::TestBase
|
5
|
+
#
|
6
|
+
# provides a base class for host and site tests.
|
7
|
+
class TestBase < TddDeploy::Base
|
8
|
+
|
9
|
+
def initialze
|
10
|
+
super
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
# gather up all descendents so we know what tests to run
|
15
|
+
class <<self
|
16
|
+
attr_writer :children
|
17
|
+
|
18
|
+
def children
|
19
|
+
@children ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
# removes all methods from defined children.
|
23
|
+
def flush_children_methods
|
24
|
+
self.children.each do |child|
|
25
|
+
child.instance_methods(false).each do |meth|
|
26
|
+
child.send :remove_method, meth
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def inherited(child)
|
32
|
+
self.children ||= []
|
33
|
+
self.children << child unless self.children.include? child
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/tdd_deploy/version.rb
CHANGED
data/tests/test_base.rb
CHANGED
@@ -14,7 +14,6 @@ end
|
|
14
14
|
|
15
15
|
class TestBaseTestCase < Test::Unit::TestCase
|
16
16
|
def test_tdd_deploy_base_children
|
17
|
-
|
18
|
-
assert TddDeploy::Base.children.include?(TestBase::Bar), "TddDeploy::Base.children should contain TestBase::Bar"
|
17
|
+
assert_equal TddDeploy::Base, TestBase::Foo.superclass, "Foo is a child of TddDeploy::Base"
|
19
18
|
end
|
20
19
|
end
|
data/tests/test_copy_methods.rb
CHANGED
@@ -25,10 +25,10 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
25
25
|
def test_mkdir_on_remote_as
|
26
26
|
result = mkdir_on_remote_as 'site_user', 'arch', 'test-dir'
|
27
27
|
assert result, "mkdir_on_remote_as site_user on arch returns true"
|
28
|
-
stdout, stderr, cmd =
|
28
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', 'test -d test-dir && echo "success"'
|
29
29
|
assert_equal "success\n", stdout, "deploy_test_file_exists_on_hosts_as says 'test-dir' exists"
|
30
30
|
|
31
|
-
stdout, stderr, cmd =
|
31
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', 'rmdir test-dir ; test -d test-dir || echo "success"'
|
32
32
|
assert_equal "success\n", stdout, "deploy_test_file_exists_on_hosts_as says 'test-dir' removed"
|
33
33
|
end
|
34
34
|
|
@@ -37,14 +37,14 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
37
37
|
result = append_string_to_remote_file_as 'site_user', 'arch', str, 'test-file'
|
38
38
|
assert result, "append_string_to_remote_file_as returns true on success"
|
39
39
|
|
40
|
-
stdout, stderr, cmd =
|
40
|
+
stdout, stderr, cmd = run_on_a_host_as('site_user', 'arch', 'cat test-file')
|
41
41
|
assert_equal str, stdout, "test-file should exist on arch"
|
42
42
|
assert_nil stderr, "stderr should be nil"
|
43
43
|
|
44
44
|
result = append_string_to_remote_file_as 'site_user', 'arch', "another line\n", 'test-file'
|
45
45
|
assert result, "append_string_to_remote_file_as returns true on success"
|
46
46
|
|
47
|
-
stdout, stderr, cmd =
|
47
|
+
stdout, stderr, cmd = run_on_a_host_as('site_user', 'arch', 'cat test-file')
|
48
48
|
assert_match /line 1/, stdout, "output should contain 'line 1'"
|
49
49
|
assert_match /another line/, stdout, "output should contain 'another line'"
|
50
50
|
assert_equal 4, stdout.split("\n").length, "output should contain 4 lines"
|
@@ -55,7 +55,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
55
55
|
result = copy_string_to_remote_file_as 'site_user', 'arch', str, 'test-file'
|
56
56
|
assert result, "copy_string_to_remote_file_as returns true on success"
|
57
57
|
|
58
|
-
stdout, stderr, cmd =
|
58
|
+
stdout, stderr, cmd = run_on_a_host_as('site_user', 'arch', 'cat test-file')
|
59
59
|
assert_equal str, stdout, "test-file should exist on arch"
|
60
60
|
assert_nil stderr, "stderr should be nil"
|
61
61
|
end
|
@@ -69,7 +69,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
69
69
|
tmp_file.close
|
70
70
|
result = copy_file_to_remote_as 'site_user', 'arch', tmp_file.path, 'test-file'
|
71
71
|
|
72
|
-
stdout, stderr, cmd =
|
72
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', 'cat test-file'
|
73
73
|
assert_equal input_text, stdout, "remote file should contain input_text"
|
74
74
|
|
75
75
|
assert result, "copy should return true"
|
@@ -91,11 +91,11 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
91
91
|
tmp2_file.write input2_text
|
92
92
|
tmp2_file.close
|
93
93
|
assert append_file_to_remote_file_as('site_user', 'arch', tmp_file.path, 'test-file'), 'copy file should work'
|
94
|
-
stdout, stderr, cmd =
|
94
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', 'cat test-file'
|
95
95
|
assert_equal input_text, stdout, "remote file should contain input_text"
|
96
96
|
|
97
97
|
assert append_file_to_remote_file_as('site_user', 'arch', tmp2_file.path, 'test-file'), 'append should return true'
|
98
|
-
stdout, stderr, cmd =
|
98
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', 'cat test-file'
|
99
99
|
assert_equal input_text + input2_text, stdout, "remote file should contain input_text + input2_text"
|
100
100
|
ensure
|
101
101
|
tmp_file.unlink
|
@@ -103,7 +103,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
def
|
106
|
+
def test_copy_string_to_remote_hosts_as
|
107
107
|
host_list = ['arch']
|
108
108
|
str = "line 1\nline 2\nline 3\n"
|
109
109
|
result = copy_string_to_remote_file_on_hosts_as 'site_user', host_list, str, 'test-file'
|
@@ -116,7 +116,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
116
116
|
end
|
117
117
|
|
118
118
|
|
119
|
-
def
|
119
|
+
def test_copy_string_to_remote_hosts_as_with_host_list_as_str
|
120
120
|
host_list = 'arch'
|
121
121
|
str = "line 1\nline 2\nline 3\n"
|
122
122
|
result = copy_string_to_remote_file_on_hosts_as 'site_user', host_list, str, 'test-file'
|
@@ -129,7 +129,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
|
131
131
|
|
132
|
-
def
|
132
|
+
def test_copy_file_to_remote_hosts_as
|
133
133
|
host_list = ['arch']
|
134
134
|
require 'tempfile'
|
135
135
|
tmp_file = Tempfile.new('foo')
|
@@ -137,7 +137,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
137
137
|
input_text = "line one\nline two\nline 3\n"
|
138
138
|
tmp_file.write input_text
|
139
139
|
tmp_file.close
|
140
|
-
result =
|
140
|
+
result = copy_file_to_remote_hosts_as 'site_user', host_list, tmp_file.path, 'test-file'
|
141
141
|
|
142
142
|
results = run_on_hosts_as 'site_user', host_list, 'cat test-file'
|
143
143
|
assert_equal input_text, results['arch'][0], "remote file should contain input_text"
|
@@ -148,7 +148,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
def
|
151
|
+
def test_copy_dir_to_remote_hosts_as
|
152
152
|
host_list = ['arch']
|
153
153
|
dir_name = 'test-dir'
|
154
154
|
Dir.mkdir dir_name unless File.exists? dir_name
|
@@ -159,7 +159,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
159
159
|
f.close
|
160
160
|
end
|
161
161
|
|
162
|
-
assert
|
162
|
+
assert copy_dir_to_remote_hosts_as('site_user', host_list, dir_name, dir_name), 'copy directory should work'
|
163
163
|
|
164
164
|
result_hash = run_on_hosts_as 'site_user', host_list, "ls"
|
165
165
|
assert_match Regexp.new(dir_name), result_hash['arch'][0], "ls of home should contain directory name"
|
@@ -171,12 +171,12 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
171
171
|
end
|
172
172
|
['foo', 'bar', 'baz'].each do |fname|
|
173
173
|
path = File.join dir_name, fname
|
174
|
-
stdout, stderr, cmd =
|
174
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', "cat #{path}"
|
175
175
|
assert_equal "This is a file named #{fname}\n", stdout, "copy_dir... should copy file contents of #{fname}"
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
def
|
179
|
+
def test_append_string_to_remote_hosts_as_with_host_list_as_str
|
180
180
|
host_list = 'arch'
|
181
181
|
str = "line 1\nline 2\nline 3\n"
|
182
182
|
result = append_string_to_remote_file_on_hosts_as 'site_user', host_list, str, 'test-file'
|
@@ -195,7 +195,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
195
195
|
end
|
196
196
|
|
197
197
|
|
198
|
-
def
|
198
|
+
def test_append_file_to_remote_hosts_as
|
199
199
|
host_list = ['arch']
|
200
200
|
require 'tempfile'
|
201
201
|
tmp_file = Tempfile.new('foo')
|
@@ -203,8 +203,8 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
203
203
|
input_text = "line one\nline two\nline 3\n"
|
204
204
|
tmp_file.write input_text
|
205
205
|
tmp_file.close
|
206
|
-
assert
|
207
|
-
assert
|
206
|
+
assert append_file_to_remote_hosts_as('site_user', host_list, tmp_file.path, 'test-file'), 'should work'
|
207
|
+
assert append_file_to_remote_hosts_as('site_user', host_list, tmp_file.path, 'test-file'), 'should work'
|
208
208
|
|
209
209
|
results = run_on_hosts_as 'site_user', host_list, 'cat test-file'
|
210
210
|
assert_equal input_text * 2, results['arch'][0], "remote file should contain input_text"
|
@@ -213,7 +213,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
|
-
def
|
216
|
+
def test_append_dir_to_remote_hosts_as
|
217
217
|
host_list = ['arch']
|
218
218
|
dir_name = 'test-dir'
|
219
219
|
Dir.mkdir dir_name unless File.exists? dir_name
|
@@ -224,8 +224,8 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
224
224
|
f.close
|
225
225
|
end
|
226
226
|
|
227
|
-
assert
|
228
|
-
assert
|
227
|
+
assert append_dir_to_remote_hosts_as('site_user', host_list, dir_name, dir_name), 'append directory should work'
|
228
|
+
assert append_dir_to_remote_hosts_as('site_user', host_list, dir_name, dir_name), 'append directory should work'
|
229
229
|
|
230
230
|
result_hash = run_on_hosts_as 'site_user', host_list, "ls"
|
231
231
|
assert_match Regexp.new(dir_name), result_hash['arch'][0], "ls of home should contain directory name"
|
@@ -237,7 +237,7 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
237
237
|
end
|
238
238
|
['foo', 'bar', 'baz'].each do |fname|
|
239
239
|
path = File.join dir_name, fname
|
240
|
-
stdout, stderr, cmd =
|
240
|
+
stdout, stderr, cmd = run_on_a_host_as 'site_user', 'arch', "cat #{path}"
|
241
241
|
assert_equal "This is a file named #{fname}\nThis is a file named #{fname}\n", stdout, "append_dir... should append file contents of #{fname}"
|
242
242
|
end
|
243
243
|
end
|
@@ -29,6 +29,13 @@ class DeployTestMethodsTestCase < Test::Unit::TestCase
|
|
29
29
|
def teardown
|
30
30
|
@tester = nil
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_rationalize_host_list
|
34
|
+
assert_equal ['arch'], @tester.send(:rationalize_host_list, 'arch'), "rationalize_host_list should translate arch to ['arch']"
|
35
|
+
assert_equal ['arch'], @tester.send(:rationalize_host_list, :web_hosts), "rationalize_host_list should translate :web_hosts to ['arch']"
|
36
|
+
assert_equal ['arch'], @tester.send(:rationalize_host_list, [:arch]), "rationalize_host_list should translate [:arch] to ['arch']"
|
37
|
+
assert_equal ['arch'], @tester.send(:rationalize_host_list, ['arch']), "rationalize_host_list should translate ['arch'] to ['arch']"
|
38
|
+
end
|
32
39
|
|
33
40
|
def test_default_env
|
34
41
|
@tester.reset_env
|
@@ -48,28 +55,28 @@ class DeployTestMethodsTestCase < Test::Unit::TestCase
|
|
48
55
|
end
|
49
56
|
|
50
57
|
def test_force_failure
|
51
|
-
result = @tester.
|
58
|
+
result = @tester.deploy_test_on_a_host_as 'no-user', @tester.hosts.first, '/home/no-user', 'should fail with bad user' do
|
52
59
|
'pwd'
|
53
60
|
end
|
54
61
|
refute result, "refute version: should fail with bad userid #{result}"
|
55
62
|
end
|
56
63
|
|
57
|
-
def
|
64
|
+
def test_deploy_test_on_a_host_as
|
58
65
|
assert_raises ArgumentError do
|
59
|
-
@tester.
|
66
|
+
@tester.deploy_test_on_a_host_as 'root', @tester.hosts.first, '', 'session catches empty match expression' do
|
60
67
|
'uname -a'
|
61
68
|
end
|
62
69
|
@tester.reset_tests
|
63
70
|
end
|
64
71
|
|
65
|
-
tmp = @tester.
|
72
|
+
tmp = @tester.deploy_test_on_a_host_as 'root', @tester.hosts.first, 'no-file-exists', 'generate an error' do
|
66
73
|
'ls /usr/no-file-exists'
|
67
74
|
end
|
68
75
|
# @tester.announce_formatted_test_results
|
69
76
|
@tester.reset_tests
|
70
77
|
refute tmp, "run as root should fail when accessing a non-existent file"
|
71
78
|
|
72
|
-
tmp = @tester.
|
79
|
+
tmp = @tester.deploy_test_on_a_host_as 'root', @tester.hosts.first, "/root", "should run as root on host #{@tester.hosts.first}" do
|
73
80
|
'pwd'
|
74
81
|
end
|
75
82
|
# @tester.announce_formatted_test_results
|
@@ -0,0 +1,42 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
require 'test_helpers'
|
3
|
+
require 'tdd_deploy/installer'
|
4
|
+
|
5
|
+
class TestTddDeployInstallerTestCase < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@helper = TddDeploy::Installer.new
|
9
|
+
@helper.set_env :site_user => 'site_user', :app_hosts => ['arch']
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_install_special_files
|
13
|
+
assert @helper.install_special_files_on_host_list_as('site_user', 'app_hosts'), "install_special_files_on_host_as should copy stuff to app_hosts"
|
14
|
+
stdout, stderr, cmd = @helper.run_on_a_host_as 'site_user', 'arch', "ls #{@helper.site_special_dir}"
|
15
|
+
assert_match /monitrc/, stdout, "special dir should contain monitrc"
|
16
|
+
assert_nil stderr, "test command should run w/o errors"
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_empty_special_dir
|
20
|
+
@helper.run_on_a_host_as @helper.site_user, 'arch', "echo 'this is a string' >#{@helper.site_special_dir}/foo"
|
21
|
+
stdout, stderr, cmd = @helper.run_on_a_host_as @helper.site_user, 'arch', "ls #{@helper.site_special_dir}"
|
22
|
+
assert_match /foo/, stdout, "should be able to create file 'foo'"
|
23
|
+
|
24
|
+
assert @helper.empty_special_dir(@helper.site_user, :app_hosts), "empty_special_dir should return true"
|
25
|
+
stdout, stderr, cmd = @helper.run_on_a_host_as @helper.site_user, 'arch', "ls #{@helper.site_special_dir}"
|
26
|
+
assert stdout !~ /foo/, "foo file should be gone"
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_install_config_files
|
30
|
+
assert @helper.install_config_files_on_host_list_as('site_user', 'app_hosts'), 'install config_files should return true'
|
31
|
+
|
32
|
+
config_dir = File.join @helper.site_doc_root, '..', 'config'
|
33
|
+
|
34
|
+
stdout, stderr, cmd = @helper.run_on_a_host_as 'site_user', 'arch', "ls #{config_dir}"
|
35
|
+
assert_match /one_thin_server.conf/, stdout, "config dir should contain one_thin_server.conf"
|
36
|
+
assert_nil stderr, "test command should run w/o errors"
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_run_cap_deploy
|
40
|
+
assert @helper.run_cap_deploy, "running cap deploy should succeed"
|
41
|
+
end
|
42
|
+
end
|
data/tests/test_run_methods.rb
CHANGED
@@ -19,24 +19,24 @@ class RunMethodsTestCase < Test::Unit::TestCase
|
|
19
19
|
refute ping_host('non-existent-host'), 'cannot ping non-existent-host'
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
stdout, stderr, cmd =
|
22
|
+
def test_run_on_a_host_as
|
23
|
+
stdout, stderr, cmd = run_on_a_host_as 'mike', 'arch', 'pwd'
|
24
24
|
assert_equal "/home/mike\n", stdout, "should be able to run as mike on host arch"
|
25
25
|
assert_nil stderr, "should not return error if can connect to host"
|
26
26
|
assert_equal 'pwd', cmd, 'cmd should be pwd'
|
27
27
|
|
28
|
-
stdout, stderr =
|
28
|
+
stdout, stderr = run_on_a_host_as 'mike', 'no-host', 'pwd'
|
29
29
|
refute_equal "/home/mike\n", stdout, "should not return home directory for bad host name"
|
30
30
|
refute_nil stderr, "should return an error message for bad host name"
|
31
31
|
assert_equal 'pwd', cmd, 'cmd should be pwd'
|
32
32
|
|
33
|
-
stdout, stderr =
|
33
|
+
stdout, stderr = run_on_a_host_as 'no-user', 'arch', 'pwd'
|
34
34
|
refute_equal "/home/mike\n", stdout, "should not return home directory for bad user name"
|
35
35
|
refute_nil stderr, "should return an error message for bad user name"
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
stdout, stderr, cmd =
|
38
|
+
def test_run_on_a_host_as
|
39
|
+
stdout, stderr, cmd = run_on_a_host_as 'mike', 'arch' do
|
40
40
|
'pwd'
|
41
41
|
end
|
42
42
|
assert_equal "/home/mike\n", stdout, "should be able to run as mike on host arch"
|
data/tests/test_server.rb
CHANGED
@@ -3,6 +3,7 @@ $:.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'tdd_deploy/environ'
|
5
5
|
require 'tdd_deploy/server'
|
6
|
+
require 'tdd_deploy/test_base'
|
6
7
|
|
7
8
|
class TestServerTestCase < Test::Unit::TestCase
|
8
9
|
GEM_ROOT = File.expand_path('../..', __FILE__)
|
@@ -24,8 +25,10 @@ class TestServerTestCase < Test::Unit::TestCase
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def teardown
|
27
|
-
@tester = nil
|
28
28
|
system('rm -f site_host_setup.env')
|
29
|
+
TddDeploy::TestBase.flush_children_methods
|
30
|
+
@tester.load_all_tests
|
31
|
+
@tester = nil
|
29
32
|
end
|
30
33
|
|
31
34
|
def test_env_file_detection
|
@@ -0,0 +1,37 @@
|
|
1
|
+
$:.unshift File.expand_path('../', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'test_helpers'
|
5
|
+
require 'tdd_deploy/test_base'
|
6
|
+
require 'tdd_deploy/server'
|
7
|
+
|
8
|
+
class TestBaseTestCase < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
TddDeploy::Server.new.load_all_tests
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
TddDeploy::Server.new.load_all_tests
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_require_subclass
|
18
|
+
assert TddDeploy::TestBase.children.include?(TddDeploy::HostConnection), "children must contain TddDeploy::HostConnection"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_flush_children_methods
|
22
|
+
children_before = TddDeploy::TestBase.children
|
23
|
+
TddDeploy::TestBase.children.each do |child|
|
24
|
+
assert_not_equal [], child.instance_methods(false), "child #{child} should have methods"
|
25
|
+
end
|
26
|
+
TddDeploy::TestBase.flush_children_methods
|
27
|
+
assert_equal children_before, TddDeploy::TestBase.children, "flush_children should not change children Array"
|
28
|
+
TddDeploy::TestBase.children.each do |child|
|
29
|
+
assert_equal [], child.instance_methods(false), "Each child should not have any methods"
|
30
|
+
end
|
31
|
+
|
32
|
+
TddDeploy::Server.new.load_all_tests
|
33
|
+
TddDeploy::TestBase.children.each do |child|
|
34
|
+
assert_not_equal [], child.instance_methods(false), "child #{child} should have methods after reloading"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdd_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-08-16 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153638900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153638900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: net-ping
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153638200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153638200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: net-ssh
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153637600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153637600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153637000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153637000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: ZenTest
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153636080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 4.5.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153636080
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: autotest-growl
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153623700 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153623700
|
80
80
|
description: Test driven support for host provisioning & Capistrano deployment - for
|
81
81
|
those who don't want to bother learning too much
|
82
82
|
email: ! ' mike@clove.com '
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/tdd_deploy/host_tests/remote_nginx.rb
|
105
105
|
- lib/tdd_deploy/host_tests/remote_postfix.rb
|
106
106
|
- lib/tdd_deploy/host_tests/remote_postgresql.rb
|
107
|
+
- lib/tdd_deploy/installer.rb
|
107
108
|
- lib/tdd_deploy/local_tests/smoke_test.rb
|
108
109
|
- lib/tdd_deploy/railengine.rb
|
109
110
|
- lib/tdd_deploy/run_methods.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- lib/tdd_deploy/site_tests/site_layout.rb
|
113
114
|
- lib/tdd_deploy/site_tests/site_rvm.rb
|
114
115
|
- lib/tdd_deploy/site_tests/site_user.rb
|
116
|
+
- lib/tdd_deploy/test_base.rb
|
115
117
|
- lib/tdd_deploy/version.rb
|
116
118
|
- lib/tdd_deploy.rb
|
117
119
|
- tests/test_assertions.rb
|
@@ -123,6 +125,7 @@ files:
|
|
123
125
|
- tests/test_environ.rb
|
124
126
|
- tests/test_helpers.rb
|
125
127
|
- tests/test_host_tests.rb
|
128
|
+
- tests/test_installer.rb
|
126
129
|
- tests/test_remote_ip_tables.rb
|
127
130
|
- tests/test_remote_monit.rb
|
128
131
|
- tests/test_remote_nginx.rb
|
@@ -136,6 +139,7 @@ files:
|
|
136
139
|
- tests/test_tdd_deploy.rb
|
137
140
|
- tests/test_tdd_deploy_context.rb
|
138
141
|
- tests/test_tdd_deploy_server.rb
|
142
|
+
- tests/test_test_base.rb
|
139
143
|
- lib/tasks/tdd_deploy.rake
|
140
144
|
- lib/tdd_deploy/server-templates/test_results.html.erb
|
141
145
|
- lib/tdd_deploy/site-erb/app_hosts/config/one_thin_server.conf.erb
|