tdd_deploy 0.1.12 → 0.1.13

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/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem 'net-ping'
10
10
 
11
11
  # gem 'rack', "~> 1.2.1"
12
12
  gem 'rack'
13
+
14
+ gem 'pry'
@@ -19,10 +19,23 @@ class TddDeployEnv
19
19
 
20
20
  def show_env
21
21
  puts "============================================="
22
- self.env_types.keys.sort.each do |k|
22
+ self.env_types.keys.select { |k| ![:pseudo, :capfile].include? env_types[k] }.sort.each do |k|
23
23
  v = self.send(k.to_sym)
24
24
  printf "%-20s: %s\n", k, v
25
25
  end
26
+
27
+ puts "\nPseudo Keys: (assignable ONLY if all hosts are the same)"
28
+ self.env_types.keys.sort.select { |k| env_types[k] == :pseudo }.each do |k|
29
+ v = self.send(k.to_sym)
30
+ printf "%-20s: %s\n", k, v
31
+ end
32
+
33
+ puts "\nCap File Keys: (read only)"
34
+ self.env_types.keys.sort.select { |k| env_types[k] == :capfile }.each do |k|
35
+ v = self.send(k.to_sym)
36
+ printf "%-20s: %s\n", k, v
37
+ end
38
+
26
39
  if (self.web_hosts.nil? && self.db_hosts.nil?) || self.web_hosts == self.db_hosts
27
40
  printf "\n\nSpecial Key\n%-20s: %s\n", 'hosts', self.hosts, "set 'hosts' to set both web & db hosts"
28
41
  end
@@ -58,13 +58,13 @@ module TddDeploy
58
58
  raise ArgumentError, 'match expression cannot be empty' if match =~ ''
59
59
 
60
60
  rsp, err_rsp, cmd = run_on_a_host_as(userid, host, &block)
61
- prefix = "user@host: #{userid}@#{host}: #{success_msg}"
61
+ prefix = "user@host: #{userid}@#{host}:\n --- #{success_msg}"
62
62
 
63
63
  if err_rsp
64
- return fail host, "#{prefix}: command generated error data:\n" +
64
+ return fail host, "#{prefix}:\n --- command generated error data:\n" +
65
65
  " command: #{cmd}\n stdout: '#{rsp}'\n stderr: '#{err_rsp}'"
66
66
  elsif rsp.nil?
67
- return fail host, "#{prefix}: stdout is empty for command '#{cmd}'"
67
+ return fail host, "#{prefix}:\n --- stdout is empty for command '#{cmd}'"
68
68
  else
69
69
  return assert_match host, match, rsp, prefix
70
70
  end
@@ -50,8 +50,10 @@ module TddDeploy
50
50
  #
51
51
  # === Pseudo Variables
52
52
  # * 'hosts' - list of all hosts - always returns app_hosts + balance_hosts + db_hosts + web_hosts.
53
- #may be assigned to if all three host lists are identical, otherwise raises an exception.
53
+ # may be assigned to if all three host lists are identical, otherwise raises an exception.
54
54
  #'tdd_deploy_context' hides it from view unless it can be assigned
55
+ #
56
+ # === Capfile Variables - Read Only
55
57
  # * 'app' - list of all hosts in the :app role of the Capistrano recipes
56
58
  # * 'db' - list of all hosts in the :db role of the Capistrano recipes
57
59
  # * 'migration_hosts' - list of all hosts in the :db role with option :primary => true
@@ -126,10 +128,11 @@ module TddDeploy
126
128
  'web_hosts' => :list,
127
129
 
128
130
  'hosts' => :pseudo,
129
- 'app' => :pseudo,
130
- 'db' => :pseudo,
131
- 'migration_hosts' => :pseudo,
132
- 'web' => :pseudo,
131
+
132
+ 'app' => :capfile,
133
+ 'db' => :capfile,
134
+ 'migration_hosts' => :capfile,
135
+ 'web' => :capfile,
133
136
  }
134
137
 
135
138
  DataCache.env_desc = {
@@ -155,10 +158,11 @@ module TddDeploy
155
158
  'db_hosts' => 'list of hosts running database servers',
156
159
  'web_hosts' => 'list of hosts running real web servers - Apache or Nginx or ...',
157
160
 
158
- 'hosts' => 'uniquified sum of app_hosts, balance_hosts, db_hosts, and web_hosts',
161
+ 'hosts' => 'unqualified sum of app_hosts, balance_hosts, db_hosts, and web_hosts',
162
+
159
163
  'app' => 'list of servers in the Capistrano :app role',
160
164
  'db' => 'list of servers in the Capistrano :db role',
161
- 'migration_hosts' => 'list of servers in the Capistrano :db role with :primary => truen',
165
+ 'migration_hosts' => 'list of servers in the Capistrano :db role with :primary => true',
162
166
  'web' => 'list of servers in the Capistrano :web role',
163
167
  }
164
168
 
@@ -212,6 +216,7 @@ module TddDeploy
212
216
  when :int then DataCache.env_hash[k] = v.to_i
213
217
  when :string then DataCache.env_hash[k] = v.to_s
214
218
  when :list then DataCache.env_hash[k] = self.str_to_list(v)
219
+ when :capfile then next
215
220
  when :pseudo then
216
221
  if k == 'hosts'
217
222
  if (tmp = DataCache.env_hash['web_hosts']) == DataCache.env_hash['db_hosts'] \
@@ -277,6 +282,7 @@ module TddDeploy
277
282
  (self.env_types.keys - self.env_hash.keys).each do |key|
278
283
  case self.env_types[key]
279
284
  when :pseudo then next
285
+ when :capfile then next
280
286
  when :list
281
287
  self.env_hash[key] = str_to_list(self.env_defaults[key])
282
288
  else
@@ -327,6 +333,7 @@ module TddDeploy
327
333
  when :list then
328
334
  f.write "#{k}=#{self.list_to_str(k)}\n" unless k == 'hosts'
329
335
  when :pseudo then next
336
+ when :capfile then next
330
337
  else
331
338
  raise ::RuntimeError.new("unknown key: #{k}")
332
339
  end
@@ -341,7 +348,12 @@ module TddDeploy
341
348
 
342
349
  tmp +=<<-EOF
343
350
  def #{k}
344
- self.env_hash['#{k}']
351
+ if '#{k}' == 'capfile_paths' && (self.env_hash['capfile_paths'].nil? || self.env_hash['capfile_paths'] == [])
352
+ DataCache.capfile = nil
353
+ self.env_hash['capfile_paths'] = self.str_to_list self.env_defaults['capfile_paths']
354
+ else
355
+ self.env_hash['#{k}']
356
+ end
345
357
  end
346
358
  EOF
347
359
  case DataCache.env_types[k]
@@ -361,20 +373,23 @@ module TddDeploy
361
373
  tmp +=<<-EOF
362
374
  def #{k}=(v)
363
375
  self.env_hash['#{k}'] = self.str_to_list(v)
364
- DataCache.capfile = nil if '#{k}' == 'capfile_paths'
376
+ if '#{k}' == 'capfile_paths'
377
+ DataCache.capfile = nil
378
+ self.env_hash['capfile_paths'] = self.env_defaults['capfile_paths'] if v.nil?
379
+ end
380
+ end
381
+ EOF
382
+ when :capfile
383
+ tmp +=<<-EOF
384
+ def #{k}
385
+ self.capfile.role_to_host_list :#{k}
365
386
  end
366
387
  EOF
388
+ else
389
+ raise Exception.new("Internal Error: key #{k} has invalid type: #{t}")
367
390
  end
368
391
  end
369
392
 
370
- ['app', 'db', 'web'].each do |k|
371
- tmp +=<<-EOF
372
- def #{k}
373
- self.capfile.role_to_host_list :#{k}
374
- end
375
- EOF
376
- end
377
-
378
393
  class_eval tmp
379
394
 
380
395
  # accessors for all defined env variables
@@ -211,7 +211,9 @@ end
211
211
  <% result, success_msg = msg %>
212
212
  <% test_result_index += 1 %>
213
213
  <li id="test-result-detail-<%= test_result_index %>" class="<%= even_odd %> <%= result ? 'test-result-detail-success' : 'test-result-detail-failure' %>">
214
+ <pre>
214
215
  <%= success_msg %>
216
+ </pre>
215
217
  </li>
216
218
  <% end %>
217
219
  </ul>
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # balance_host config fragment for <%= site %>
3
3
  #
4
- upstream <%= site %> {
4
+ upstream <%= site_url %> {
5
5
  <% web_hosts.each do |host| %>
6
6
  server <%= host %>;
7
7
  <% end %>
@@ -22,6 +22,6 @@ server {
22
22
  proxy_read_timeout 90;
23
23
  proxy_buffers 32 4k;
24
24
 
25
- proxy_pass http://<%= site %>;
25
+ proxy_pass http://<%= site_url %>;
26
26
  }
27
27
  }
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # web_host config fragment for <%= site %>
3
3
  #
4
- upstream <%= site %> {
4
+ upstream <%= site_url %> {
5
5
  # backend servers
6
6
  <% ((site_base_port)...(site_base_port+site_num_servers)).each do |port| %>
7
7
  server 127.0.0.1:<%= port %>;
@@ -37,7 +37,7 @@ server {
37
37
  proxy_read_timeout 90;
38
38
  proxy_buffers 32 4k;
39
39
 
40
- proxy_pass http://<%= site %>;
40
+ proxy_pass http://<%= site_url %>;
41
41
  }
42
42
 
43
43
  error_page 500 502 503 504 /500.html;
@@ -1,3 +1,3 @@
1
1
  module TddDeploy
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.13'
3
3
  end
@@ -40,8 +40,8 @@ class TestEnvironTestCase < Test::Unit::TestCase
40
40
  @foo.clear_env
41
41
  system('TMP=/tmp/t-$$; trap "rm $TMP; exit" 0 1 2 3 15 ;cp site_host_setup.env $TMP ; sed -e 1d $TMP >site_host_setup.env')
42
42
  @foo.read_env
43
- non_pseudo_keys = @foo.env_types.reject {|k,t| t == :pseudo }.keys.sort
44
- assert_equal non_pseudo_keys, @foo.env_hash.keys.sort, "read_env should set all keys"
43
+ non_pseudo_or_capfile_keys = @foo.env_types.reject {|k,t| t == :pseudo || t == :capfile}.keys.sort
44
+ assert_equal non_pseudo_or_capfile_keys, @foo.env_hash.keys.sort, "read_env should set all non-pseudo and non-capfile keys"
45
45
  end
46
46
 
47
47
  def test_response_to_accessors
@@ -161,11 +161,13 @@ class TestEnvironTestCase < Test::Unit::TestCase
161
161
  case @foo.env_types[k]
162
162
  when :int then expect = 0
163
163
  when :string then expect = ''
164
- when :list then expect = []
164
+ when :list then expect = (k == 'capfile_paths' ? [@foo.env_defaults['capfile_paths']] : [])
165
+ when :capfile then next
165
166
  when :pseudo then next
166
167
  end
167
- assert_equal expect, @foo.env_hash[k], "After Zapping, env_hash['#{k}'] should be #{expect}"
168
- assert_equal expect, @foo.send(k.to_sym), "After Zapping, @foo.#{k} should be #{expect}"
168
+ # order is important here - the accessors 'do things' which manipulate the hash
169
+ assert_equal expect, @foo.send(k.to_sym), "After Zapping, @foo.#{k} should be #{expect.inspect}"
170
+ assert_equal expect, @foo.env_hash[k], "After Zapping, env_hash['#{k}'] should be #{expect.inspect}"
169
171
  end
170
172
  end
171
173
 
@@ -3,6 +3,7 @@ $:.unshift File.expand_path('../../lib', __FILE__)
3
3
  # Add bundler setup to load path
4
4
  require 'rubygems'
5
5
  require 'bundler/setup'
6
+ require 'pry'
6
7
  # $:.each { |x| puts x }
7
8
 
8
9
  require 'test/unit'
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.12
4
+ version: 0.1.13
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: &2157389080 !ruby/object:Gem::Requirement
16
+ requirement: &2174254660 !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: *2157389080
24
+ version_requirements: *2174254660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-ping
27
- requirement: &2157388620 !ruby/object:Gem::Requirement
27
+ requirement: &2174254200 !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: *2157388620
35
+ version_requirements: *2174254200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: net-ssh
38
- requirement: &2157388200 !ruby/object:Gem::Requirement
38
+ requirement: &2174253780 !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: *2157388200
46
+ version_requirements: *2174253780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack
49
- requirement: &2157387780 !ruby/object:Gem::Requirement
49
+ requirement: &2174253360 !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: *2157387780
57
+ version_requirements: *2174253360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ZenTest
60
- requirement: &2157387280 !ruby/object:Gem::Requirement
60
+ requirement: &2174252860 !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: *2157387280
68
+ version_requirements: *2174252860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: autotest-growl
71
- requirement: &2157386860 !ruby/object:Gem::Requirement
71
+ requirement: &2174252440 !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: *2157386860
79
+ version_requirements: *2174252440
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 '