tdd_deploy 0.0.1 → 0.0.3

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.
@@ -11,8 +11,8 @@ module TddDeploy
11
11
  # For each host, an error is declared if EITHER STDOUT does not match 'match_expr_or_str'
12
12
  # OR if the command returns anything on STDERR.
13
13
  # 'match_expr_or_str' can be a Regexp or a string (which will be converted to a Regexp)
14
- def deploy_test_on_all_hosts(match_expr_or_str, err_msg, &block)
15
- deploy_test_on_all_hosts_as self.host_admin, match_expr_or_str, err_msg, &block
14
+ def deploy_test_on_all_hosts(match_expr_or_str, success_msg, &block)
15
+ deploy_test_on_all_hosts_as self.host_admin, match_expr_or_str, success_msg, &block
16
16
  end
17
17
 
18
18
  # deploy_test_on_all_hosts_as runs the command(s) return by '&block' on all hosts in self.hosts
@@ -20,27 +20,27 @@ module TddDeploy
20
20
  # For each host, an error is declared if EITHER STDOUT does not match 'match_expr_or_str'
21
21
  # OR if the command returns anything on STDERR.
22
22
  # 'match_expr_or_str' can be a Regexp or a string (which will be converted to a Regexp)
23
- def deploy_test_on_all_hosts_as(userid, match_expr_or_str, err_msg, &block)
23
+ def deploy_test_on_all_hosts_as(userid, match_expr_or_str, success_msg, &block)
24
24
  ret = true
25
25
  self.hosts.each do |host|
26
- ret &= deploy_test_in_ssh_session_as userid, host, match_expr_or_str, err_msg, &block
26
+ ret &= deploy_test_in_ssh_session_as userid, host, match_expr_or_str, success_msg, &block
27
27
  end
28
28
  ret
29
29
  end
30
30
 
31
- # deploy_test_in_ssh_session host, match_exp_or_string, err_msg, &block runs the command
31
+ # deploy_test_in_ssh_session host, match_exp_or_string, success_msg, &block runs the command
32
32
  # returned by 'block.call' on the specified host as user 'self.host_admin'.
33
33
  # declares an error if EITHER STDOUT does not match 'match' OR STDERR returns anything
34
34
  # 'match' can be a Regexp or a string (which will be converted to a Regexp)
35
- def deploy_test_in_ssh_session(host, match, err_msg, &block)
36
- deploy_test_in_ssh_session_as(self.host_admin, host, match, err_msg, &block)
35
+ def deploy_test_in_ssh_session(host, match, success_msg, &block)
36
+ deploy_test_in_ssh_session_as(self.host_admin, host, match, success_msg, &block)
37
37
  end
38
38
 
39
39
  # deploy_test_in_ssh_session_as runs the command(s) return by '&block' on the specified host
40
40
  # as user 'userid'
41
41
  # declares an error if EITHER STDOUT does not match 'match' OR STDERR returns anything
42
42
  # 'match' can be a Regexp or a string (which will be converted to a Regexp)
43
- def deploy_test_in_ssh_session_as(userid, host, match, err_msg, &block)
43
+ def deploy_test_in_ssh_session_as(userid, host, match, success_msg, &block)
44
44
  match = Regexp.new(match) if match.is_a? String
45
45
  raise ArgumentError, 'match expression cannot be empty' if match =~ ''
46
46
 
@@ -48,14 +48,15 @@ module TddDeploy
48
48
 
49
49
  result = err_rsp.nil?
50
50
 
51
- prefix = "user@host: #{userid}@#{host}"
51
+ prefix = "user@host: #{userid}@#{host}: #{success_msg}"
52
52
 
53
- fail "<pre>\n#{prefix}: command generated error data:\n" +
54
- " command: #{cmd}\n stdout: '#{rsp}'\n stderr: '#{err_rsp}'\n</pre>" if err_rsp
53
+ fail "#{prefix}: command generated error data:\n" +
54
+ " command: #{cmd}\n stdout: '#{rsp}'\n stderr: '#{err_rsp}'" if err_rsp
55
55
 
56
- if !assert_not_nil rsp, "#{prefix}: stdout is empty for command '#{cmd}'"
56
+ if rsp.nil?
57
+ fail "#{prefix}: stdout is empty for command '#{cmd}'"
57
58
  result &= false
58
- elsif !assert_match match, rsp, "#{prefix}: #{err_msg}\n rsp: #{rsp}"
59
+ elsif !assert_match match, rsp, prefix
59
60
  result &= false
60
61
  end
61
62
 
@@ -14,14 +14,14 @@ module TddDeploy
14
14
 
15
15
  # ssh_login - attempts to log in as *host_admin* on all hosts from current user
16
16
  def ssh_login
17
- deploy_test_on_all_hosts "/home/#{self.host_admin}\n", "unable to connect via ssh" do
17
+ deploy_test_on_all_hosts "/home/#{self.host_admin}\n", "should be able to connect via ssh" do
18
18
  'pwd'
19
19
  end
20
20
  end
21
21
 
22
22
  # ssh_login_as_root - attempts to log in as *root* on all hosts from current user
23
23
  def ssh_login_as_root
24
- deploy_test_on_all_hosts_as 'root', '/root', "unable to connect as root via ssh" do
24
+ deploy_test_on_all_hosts_as 'root', '/root', "Should be able to connect as root via ssh" do
25
25
  'pwd'
26
26
  end
27
27
  end
@@ -3,13 +3,13 @@ require 'tdd_deploy/base'
3
3
  module TddDeploy
4
4
  class RemoteMonit < TddDeploy::Base
5
5
  def test_monit_installed
6
- deploy_test_on_all_hosts '/usr/bin/monit', "monit is not installed" do
6
+ deploy_test_on_all_hosts '/usr/bin/monit', "monit should be installed" do
7
7
  'ls /usr/bin/monit'
8
8
  end
9
9
  end
10
10
 
11
11
  def test_monit_running
12
- deploy_test_on_all_hosts /\smonit\s/, "monit is not running" do
12
+ deploy_test_on_all_hosts /\smonit\s/, "monit should be running" do
13
13
  'ps -p `cat /var/run/monit.pid`'
14
14
  end
15
15
  end
@@ -3,13 +3,13 @@ require 'tdd_deploy/base'
3
3
  module TddDeploy
4
4
  class RemoteNginx < TddDeploy::Base
5
5
  def test_nginx_installed
6
- deploy_test_on_all_hosts '/usr/sbin/nginx', "nginx is not installed" do
6
+ deploy_test_on_all_hosts '/usr/sbin/nginx', "nginx should be installed" do
7
7
  'ls /usr/sbin/nginx'
8
8
  end
9
9
  end
10
10
 
11
11
  def test_nginx_running
12
- deploy_test_on_all_hosts /\snginx\s/, "nginx is not running" do
12
+ deploy_test_on_all_hosts /\snginx\s/, "nginx shold be running" do
13
13
  'ps -p `cat /var/run/nginx.pid`'
14
14
  end
15
15
  end
@@ -3,21 +3,21 @@ require 'tdd_deploy/base'
3
3
  module TddDeploy
4
4
  class RemotePostfix < TddDeploy::Base
5
5
  def test_postfix_installed
6
- deploy_test_on_all_hosts '/usr/sbin/postfix', "postfix is not installed" do
6
+ deploy_test_on_all_hosts '/usr/sbin/postfix', "postfix should be installed" do
7
7
  'ls /usr/sbin/postfix'
8
8
  end
9
9
  end
10
10
 
11
11
  def test_postfix_running
12
- deploy_test_on_all_hosts_as 'root', /\smaster\s/, "postfix is not running" do
12
+ deploy_test_on_all_hosts_as 'root', /\smaster\s/, "postfix should be running" do
13
13
  'ps -p `cat /var/spool/postfix/pid/master.pid`'
14
14
  end
15
15
  end
16
16
 
17
- # def test_postfix_accepts_mail
18
- # deploy_test_on_all_hosts "mail works\n", 'postfix accepts mail' do |host, login, userid|
19
- # "echo \"test mail\" | mail -s 'test mail' -r #{userid}@#{host} #{self.local_admin_email} && echo 'mail works'"
20
- # end
21
- # end
17
+ def test_postfix_accepts_mail
18
+ deploy_test_on_all_hosts "mail works\n", 'postfix accepts mail' do |host, login, userid|
19
+ "echo \"test mail\" | mail -s 'test mail' -r #{userid}@#{host} #{self.local_admin_email} && echo 'mail works'"
20
+ end
21
+ end
22
22
  end
23
23
  end
@@ -3,13 +3,13 @@ require 'tdd_deploy/base'
3
3
  module TddDeploy
4
4
  class RemotePostgresql < TddDeploy::Base
5
5
  def test_postgresql_installed
6
- deploy_test_on_all_hosts "/usr/bin/postgres\n", 'postgres not installed' do |host, login, admin|
6
+ deploy_test_on_all_hosts "/usr/bin/postgres\n", 'postgres should be installed' do |host, login, admin|
7
7
  "ls /usr/bin/postgres"
8
8
  end
9
9
  end
10
10
 
11
11
  def test_postgresql_running
12
- deploy_test_on_all_hosts /postgres\s*\|\s*postgres/, "postgresql server not running" do
12
+ deploy_test_on_all_hosts /postgres\s*\|\s*postgres/, "postgresql server should be running" do
13
13
  "psql --command='\\l' postgres postgres"
14
14
  end
15
15
  end
@@ -36,6 +36,8 @@ module TddDeploy
36
36
 
37
37
  def run_all_tests
38
38
  load_all_tests
39
+
40
+ reset_tests
39
41
 
40
42
  ret = true
41
43
  self.test_classes.each do |klass|
@@ -0,0 +1,15 @@
1
+ require 'tdd_deploy/base'
2
+
3
+ module TddDeploy
4
+ # == TddDeploy::SiteDatabase
5
+ #
6
+ # tests to make sure a database named 'site' is defined in postgresql databases
7
+ class SiteDatabase < TddDeploy::Base
8
+
9
+ def test_site_db_defined
10
+ deploy_test_on_all_hosts "#{self.site}\s*\|\s*#{self.site}", "database for #{self.site} should exist" do
11
+ "psql --command='\\l' postgres postgres"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -6,7 +6,7 @@ module TddDeploy
6
6
  # tests all hosts to make sure that the local user can log on as *site_user*
7
7
  class SiteUser < TddDeploy::Base
8
8
  def test_login_as_site_user
9
- deploy_test_on_all_hosts_as self.site_user, "/home/#{self.site_user}", "unable to log into host as #{self.site_user}" do
9
+ deploy_test_on_all_hosts_as self.site_user, "/home/#{self.site_user}", "should be able to log into host as #{self.site_user}" do
10
10
  'pwd'
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module TddDeploy
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  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.0.1
4
+ version: 0.0.3
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: &2165185440 !ruby/object:Gem::Requirement
16
+ requirement: &2165241880 !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: *2165185440
24
+ version_requirements: *2165241880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-ping
27
- requirement: &2165184940 !ruby/object:Gem::Requirement
27
+ requirement: &2165241380 !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: *2165184940
35
+ version_requirements: *2165241380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: net-ssh
38
- requirement: &2165184400 !ruby/object:Gem::Requirement
38
+ requirement: &2165240900 !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: *2165184400
46
+ version_requirements: *2165240900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ZenTest
49
- requirement: &2165183760 !ruby/object:Gem::Requirement
49
+ requirement: &2165240340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 4.5.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2165183760
57
+ version_requirements: *2165240340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: autotest-growl
60
- requirement: &2165183240 !ruby/object:Gem::Requirement
60
+ requirement: &2165239920 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,13 +65,13 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2165183240
68
+ version_requirements: *2165239920
69
69
  description: Test driven support for host provisioning & Capistrano deployment - for
70
70
  those who don't want to bother learning too much
71
71
  email: ! ' mike@clove.com '
72
72
  executables:
73
73
  - tdd_deploy_context
74
- - tdd_deploy_server.rb
74
+ - tdd_deploy_server
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
@@ -79,7 +79,7 @@ files:
79
79
  - Gemfile
80
80
  - config.ru
81
81
  - bin/tdd_deploy_context
82
- - bin/tdd_deploy_server.rb
82
+ - bin/tdd_deploy_server
83
83
  - lib/tdd_deploy/assertions.rb
84
84
  - lib/tdd_deploy/base.rb
85
85
  - lib/tdd_deploy/deploy_test_methods.rb
@@ -93,6 +93,7 @@ files:
93
93
  - lib/tdd_deploy/railengine.rb
94
94
  - lib/tdd_deploy/run_methods.rb
95
95
  - lib/tdd_deploy/server.rb
96
+ - lib/tdd_deploy/site_tests/site_database.rb
96
97
  - lib/tdd_deploy/site_tests/site_layout.rb
97
98
  - lib/tdd_deploy/site_tests/site_user.rb
98
99
  - lib/tdd_deploy/version.rb
File without changes