dtr 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CHANGES +21 -0
  2. data/README.rdoc +39 -28
  3. data/Rakefile +1 -1
  4. data/TODO +1 -3
  5. data/bin/dtr +20 -13
  6. data/dtr.gemspec +3 -3
  7. data/lib/dtr.rb +2 -2
  8. data/lib/dtr/agent.rb +12 -5
  9. data/lib/dtr/agent/brain.rb +45 -19
  10. data/lib/dtr/agent/herald.rb +8 -10
  11. data/lib/dtr/agent/process_root.rb +23 -0
  12. data/lib/dtr/agent/rails_ext.rb +57 -0
  13. data/lib/dtr/agent/runner.rb +19 -39
  14. data/lib/dtr/agent/sync_codebase.rb +10 -19
  15. data/lib/dtr/agent/sync_logger.rb +1 -0
  16. data/lib/dtr/agent/worker.rb +13 -61
  17. data/lib/dtr/agent/working_env_ext.rb +51 -17
  18. data/lib/dtr/agent/working_status.rb +34 -0
  19. data/lib/dtr/facade.rb +19 -17
  20. data/lib/dtr/master.rb +2 -0
  21. data/lib/dtr/monitor.rb +2 -2
  22. data/lib/dtr/raketasks.rb +14 -19
  23. data/lib/dtr/shared.rb +1 -0
  24. data/lib/dtr/shared/adapter.rb +2 -101
  25. data/lib/dtr/shared/adapter/base.rb +118 -0
  26. data/lib/dtr/shared/adapter/mortality.rb +41 -0
  27. data/lib/dtr/shared/configuration.rb +32 -14
  28. data/lib/dtr/shared/root.rb +20 -0
  29. data/lib/dtr/shared/sync_codebase/master_ext.rb +2 -2
  30. data/lib/dtr/shared/sync_codebase/sync_service.rb +7 -4
  31. data/lib/dtr/shared/utils/cmd.rb +4 -2
  32. data/lib/dtr/shared/utils/env_store.rb +16 -24
  33. data/lib/dtr/shared/working_env.rb +8 -0
  34. data/lib/dtr/test_unit/drb_test_runner.rb +1 -1
  35. data/lib/dtr/test_unit/thread_safe_test_result.rb +56 -3
  36. data/test/acceptance/dtr_package_task_test.rb +3 -3
  37. data/test/acceptance/general_test.rb +3 -3
  38. data/test/acceptance/rails_ext_test.rb +86 -0
  39. data/test/acceptance/raketasks_test.rb +14 -0
  40. data/test/acceptance/sync_codebase_test.rb +8 -31
  41. data/test/acceptance/sync_logger_test.rb +6 -3
  42. data/test/agent_helper.rb +24 -16
  43. data/test/logger_stub.rb +3 -3
  44. data/test/test_helper.rb +12 -9
  45. data/test/unit/adapter_test.rb +1 -1
  46. data/test/unit/configuration_test.rb +36 -4
  47. data/test/unit/database_initializer_test.rb +36 -0
  48. data/test/unit/facade_test.rb +11 -1
  49. data/test/unit/thread_safe_test_result_test.rb +41 -0
  50. data/test/unit/working_env_test.rb +11 -21
  51. data/testdata/rails_projects/simple_project/README +256 -0
  52. data/testdata/rails_projects/simple_project/Rakefile +10 -0
  53. data/testdata/rails_projects/simple_project/app/controllers/application.rb +15 -0
  54. data/testdata/rails_projects/simple_project/app/controllers/products_controller.rb +5 -0
  55. data/testdata/rails_projects/simple_project/app/helpers/application_helper.rb +3 -0
  56. data/testdata/rails_projects/simple_project/app/helpers/products_helper.rb +2 -0
  57. data/testdata/rails_projects/simple_project/app/models/product.rb +5 -0
  58. data/testdata/rails_projects/simple_project/app/views/products/index.rhtml +7 -0
  59. data/testdata/rails_projects/simple_project/config/boot.rb +109 -0
  60. data/testdata/rails_projects/simple_project/config/database.yml +19 -0
  61. data/testdata/rails_projects/simple_project/config/database.yml.mysql +12 -0
  62. data/testdata/rails_projects/simple_project/config/environment.rb +67 -0
  63. data/testdata/rails_projects/simple_project/config/environments/development.rb +17 -0
  64. data/testdata/rails_projects/simple_project/config/environments/production.rb +22 -0
  65. data/testdata/rails_projects/simple_project/config/environments/test.rb +22 -0
  66. data/testdata/rails_projects/simple_project/config/initializers/inflections.rb +10 -0
  67. data/testdata/rails_projects/simple_project/config/initializers/mime_types.rb +5 -0
  68. data/testdata/rails_projects/simple_project/config/initializers/new_rails_defaults.rb +17 -0
  69. data/testdata/rails_projects/simple_project/config/routes.rb +43 -0
  70. data/testdata/rails_projects/simple_project/db/migrate/20081027133744_create_products.rb +13 -0
  71. data/testdata/rails_projects/simple_project/db/schema.rb +21 -0
  72. data/testdata/rails_projects/simple_project/doc/README_FOR_APP +2 -0
  73. data/testdata/rails_projects/simple_project/public/404.html +30 -0
  74. data/testdata/rails_projects/simple_project/public/422.html +30 -0
  75. data/testdata/rails_projects/simple_project/public/500.html +30 -0
  76. data/testdata/rails_projects/simple_project/public/dispatch.cgi +10 -0
  77. data/testdata/rails_projects/simple_project/public/dispatch.fcgi +24 -0
  78. data/testdata/rails_projects/simple_project/public/dispatch.rb +10 -0
  79. data/testdata/rails_projects/simple_project/public/favicon.ico +0 -0
  80. data/testdata/rails_projects/simple_project/public/images/rails.png +0 -0
  81. data/testdata/rails_projects/simple_project/public/index.html +274 -0
  82. data/testdata/rails_projects/simple_project/public/javascripts/application.js +2 -0
  83. data/testdata/rails_projects/simple_project/public/javascripts/controls.js +963 -0
  84. data/testdata/rails_projects/simple_project/public/javascripts/dragdrop.js +972 -0
  85. data/testdata/rails_projects/simple_project/public/javascripts/effects.js +1120 -0
  86. data/testdata/rails_projects/simple_project/public/javascripts/prototype.js +4225 -0
  87. data/testdata/rails_projects/simple_project/public/robots.txt +5 -0
  88. data/testdata/rails_projects/simple_project/script/about +4 -0
  89. data/testdata/rails_projects/simple_project/script/console +3 -0
  90. data/testdata/rails_projects/simple_project/script/dbconsole +3 -0
  91. data/testdata/rails_projects/simple_project/script/destroy +3 -0
  92. data/testdata/rails_projects/simple_project/script/generate +3 -0
  93. data/testdata/rails_projects/simple_project/script/performance/benchmarker +3 -0
  94. data/testdata/rails_projects/simple_project/script/performance/profiler +3 -0
  95. data/testdata/rails_projects/simple_project/script/performance/request +3 -0
  96. data/testdata/rails_projects/simple_project/script/plugin +3 -0
  97. data/testdata/rails_projects/simple_project/script/process/inspector +3 -0
  98. data/testdata/rails_projects/simple_project/script/process/reaper +3 -0
  99. data/testdata/rails_projects/simple_project/script/process/spawner +3 -0
  100. data/testdata/rails_projects/simple_project/script/runner +3 -0
  101. data/testdata/rails_projects/simple_project/script/server +3 -0
  102. data/testdata/rails_projects/simple_project/test/fixtures/products.yml +9 -0
  103. data/testdata/rails_projects/simple_project/test/functional/products_controller_test.rb +11 -0
  104. data/testdata/rails_projects/simple_project/test/test_helper.rb +38 -0
  105. data/testdata/rails_projects/simple_project/test/unit/product_test.rb +27 -0
  106. data/testdata/raketasks/Rakefile +1 -1
  107. metadata +90 -5
  108. data/testdata/verify_dir_pwd/Rakefile +0 -6
  109. data/testdata/verify_dir_pwd/verify_dir_pwd_test_case.rb +0 -10
@@ -17,9 +17,10 @@ module DTR
17
17
  module SyncService
18
18
  include Package
19
19
  include Service::File
20
- def sync_codebase
21
- DTR.info("Start sync codebase, clean #{File.join(Dir.pwd, package_name)}")
22
- FileUtils.rm_rf(File.join(Dir.pwd, package_name))
20
+
21
+ def sync_codebase(&block)
22
+ DTR.info("Start sync codebase, clean #{File.expand_path(Dir.pwd)}")
23
+ Dir.glob('*').each { |f| FileUtils.rm_rf(f) }
23
24
 
24
25
  DTR.info("Lookup codebase package file")
25
26
  package = lookup_file
@@ -27,7 +28,9 @@ module DTR
27
28
  File.open(package_copy_file, 'w') do |f|
28
29
  package.copy_into(f)
29
30
  end
30
- do_work(unpackage_cmd)
31
+
32
+ block.call
33
+
31
34
  DTR.info("sync codebase finished, clean #{package_copy_file}")
32
35
  FileUtils.rm_f(package_copy_file)
33
36
  end
@@ -16,14 +16,16 @@ module DTR
16
16
  class CmdInterrupt < StandardError; end
17
17
 
18
18
  class Cmd
19
- def self.execute(cmd)
19
+ def self.execute(cmd, options = {:error_output_log_level => :error})
20
20
  return true if cmd.nil? || cmd.empty?
21
21
  DTR.info {"Executing: #{cmd.inspect}"}
22
22
  output = %x[#{cmd} 2>&1]
23
23
  # don't put the following message into a block which maybe passed to remote process
24
24
  status = $?.exitstatus
25
25
  DTR.info {"Execution is done, status: #{status}"}
26
- DTR.error "#{cmd.inspect} output:\n#{output}" if status != 0
26
+ if status != 0
27
+ DTR.send(options[:error_output_log_level], "#{cmd.inspect} output:\n#{output}")
28
+ end
27
29
  $?.exitstatus == 0
28
30
  end
29
31
  end
@@ -18,42 +18,34 @@ module DTR
18
18
  class EnvStore
19
19
  FILE_NAME = '.dtr_env_pstore' unless defined?(FILE_NAME)
20
20
 
21
- def self.destroy
22
- File.delete(FILE_NAME) if File.exist?(FILE_NAME)
21
+ def self.default_file
22
+ File.join(DTR.root || Dir.pwd, FILE_NAME)
23
+ end
24
+
25
+ def initialize(file=EnvStore.default_file)
26
+ @pstore = PStore.new(File.expand_path(file))
27
+ end
28
+
29
+ def destroy
30
+ File.delete(@pstore.path) if File.exist?(@pstore.path)
23
31
  end
24
32
 
25
33
  def [](key)
26
- return nil unless File.exist?(FILE_NAME)
27
-
28
- repository = PStore.new(FILE_NAME)
29
- repository.transaction(true) do
30
- repository[key]
34
+ @pstore.transaction(true) do
35
+ @pstore[key]
31
36
  end
32
37
  end
33
38
 
34
39
  def []=(key, value)
35
- repository = PStore.new(FILE_NAME)
36
- repository.transaction do
37
- repository[key] = value
40
+ @pstore.transaction do
41
+ @pstore[key] = value
38
42
  end
39
43
  end
40
44
 
41
45
  def <<(key_value)
42
46
  key, value = key_value
43
- repository = PStore.new(FILE_NAME)
44
- repository.transaction do
45
- repository[key] = (repository[key] || []) << value
46
- end
47
- end
48
-
49
- def shift(key)
50
- repository = PStore.new(FILE_NAME)
51
- repository.transaction do
52
- if array = repository[key]
53
- array.shift
54
- repository[key] = array
55
- end
56
- end
47
+ array_value = (self[key] || []) << value
48
+ self[key] = array_value
57
49
  end
58
50
  end
59
51
 
@@ -34,5 +34,13 @@ module DTR
34
34
  def ==(obj)
35
35
  obj && obj[:identifier] == self[:identifier]
36
36
  end
37
+
38
+ def method_missing(m, *args, &block)
39
+ if args.blank?
40
+ self[m]
41
+ else
42
+ super
43
+ end
44
+ end
37
45
  end
38
46
  end
@@ -32,7 +32,7 @@ module DTR
32
32
  end
33
33
 
34
34
  def run_test_on(runner)
35
- runner.run(@test, @result, &@progress_block)
35
+ runner.run(@test, @result.instance(runner), &@progress_block)
36
36
  rescue DRb::DRbConnError => e
37
37
  DTR.info {"#{cause.class.name}(#{cause.message}), rerun test: #{@test.name}"}
38
38
  DTR.debug { cause.backtrace.join("\n") }
@@ -14,9 +14,7 @@
14
14
 
15
15
  module DTR
16
16
  module TestUnit
17
- class ThreadSafeTestResult
18
- include DRbUndumped
19
-
17
+ class SynchronizedTestResult
20
18
  def initialize(rs)
21
19
  @mutex = Mutex.new
22
20
  @rs = rs
@@ -34,5 +32,60 @@ module DTR
34
32
  end
35
33
  end
36
34
  end
35
+
36
+ class ThreadSafeTestResult < SynchronizedTestResult
37
+
38
+ class Pair
39
+ include DRbUndumped
40
+
41
+ def initialize(rs1, rs2)
42
+ @rs1 = rs1
43
+ @rs2 = rs2
44
+ end
45
+
46
+ def to_s
47
+ @rs1.to_s
48
+ end
49
+
50
+ def method_missing(method, *args, &block)
51
+ @rs1.send(method, *args, &block)
52
+ @rs2.send(method, *args, &block)
53
+ end
54
+ end
55
+
56
+ class RunnerTestResults
57
+
58
+ def initialize
59
+ @results = {}
60
+ end
61
+
62
+ def fetch(runner)
63
+ @results[runner_id(runner)] ||= SynchronizedTestResult.new(Test::Unit::TestResult.new)
64
+ end
65
+
66
+ def to_s
67
+ @results.sort_by{|runner_id, result| -result.run_count}.collect do |runner_id, result|
68
+ "#{runner_id} => #{result}"
69
+ end.join("\n")
70
+ end
71
+
72
+ def runner_id(runner)
73
+ runner.instance_variable_get('@uri').gsub(/^druby:\/\//, '')
74
+ end
75
+ end
76
+
77
+ def initialize(*args)
78
+ super
79
+ @results = RunnerTestResults.new
80
+ end
81
+
82
+ def instance(runner)
83
+ Pair.new(self, @results.fetch(runner))
84
+ end
85
+
86
+ def to_s
87
+ "#{@results}\n\n#{super}"
88
+ end
89
+ end
37
90
  end
38
91
  end
@@ -5,14 +5,14 @@ class DTRPackageTaskTest < Test::Unit::TestCase
5
5
  def test_package
6
6
  testdata_dir = File.expand_path(File.dirname(__FILE__) + '/../../testdata')
7
7
  Dir.chdir(testdata_dir) do
8
- %x[rake --rakefile package_task_test_rakefile dtr_package]
8
+ %x[rake -q --rakefile package_task_test_rakefile dtr_package]
9
9
  assert File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/a_test_case2.rb")
10
10
  assert File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/lib/lib_test_case.rb")
11
11
  assert File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/is_required_by_a_test.rb")
12
12
 
13
13
  assert File.exists?(testdata_dir + "/dtr_pkg/codebase-dump.zip")
14
14
 
15
- %x[rake --rakefile package_task_test_rakefile dtr_clobber_package]
15
+ %x[rake -q --rakefile package_task_test_rakefile dtr_clobber_package]
16
16
 
17
17
  assert !File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/a_test_case2.rb")
18
18
  assert !File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/lib/lib_test_case.rb")
@@ -27,7 +27,7 @@ class DTRPackageTaskTest < Test::Unit::TestCase
27
27
  def test_should_not_include_dtr_pkg_dir
28
28
  testdata_dir = File.expand_path(File.dirname(__FILE__) + '/../../testdata')
29
29
  Dir.chdir(testdata_dir) do
30
- %x[rake dtr_repackage]
30
+ %x[rake -q dtr_repackage]
31
31
  assert !File.exists?(testdata_dir + "/dtr_pkg/codebase-dump/dtr_pkg")
32
32
  end
33
33
  ensure
@@ -158,8 +158,8 @@ class GeneralTest < Test::Unit::TestCase
158
158
  end
159
159
 
160
160
  def test_run_test_specified_by_load_path
161
+ lib_path = File.expand_path(File.dirname(__FILE__) + '/../../testdata/lib')
161
162
  assert_fork_process_exits_ok do
162
- lib_path = File.expand_path(File.dirname(__FILE__) + '/../../testdata/lib')
163
163
  $LOAD_PATH.unshift lib_path
164
164
  require 'lib_test_case'
165
165
  $argv_dup = ['lib_test_case.rb']
@@ -226,7 +226,7 @@ class GeneralTest < Test::Unit::TestCase
226
226
  suite << ATestCase.suite
227
227
  suite << ATestCase2.suite
228
228
  suite << AFileSystemTestCase.suite
229
- with_agent_helper_group do
229
+ with_agent_configuration do
230
230
  result = runit(suite)
231
231
  assert result.passed?
232
232
  assert_equal 3, result.run_count
@@ -254,7 +254,7 @@ class GeneralTest < Test::Unit::TestCase
254
254
  assert_equal 0, $?.exitstatus
255
255
  ensure
256
256
  @test_processes.each do |pid|
257
- DTR.kill_process pid
257
+ kill_process pid
258
258
  end
259
259
  end
260
260
 
@@ -0,0 +1,86 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ include DTR::AgentHelper
4
+
5
+ class RailsExtTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ start_agents(:follower_listen_heartbeat_timeout => 15)
9
+ end
10
+
11
+ def teardown
12
+ stop_agents
13
+ end
14
+
15
+ def test_run_dtr_test_task_with_simple_sqlite_project
16
+ new_simple_project do |testdata|
17
+ assert_run_dtr_test_task_success_with(testdata)
18
+ end
19
+ end
20
+
21
+ def test_should_not_trigger_auto_preparing_database_when_setup_agent_env_command_specified
22
+ new_simple_project do |testdata|
23
+ assert_fork_process_exits_ok do
24
+ Dir.chdir(testdata) do
25
+ output = %x[rake dtr:test DTR_GROUP='#{DTR::AgentHelper::GROUP}' BROADCAST_IP=localhost DTR_AGENT_ENV_SETUP_CMD=ls]
26
+ expected = <<-OUTPUT
27
+ 5 tests, 0 assertions, 0 failures, 10 errors
28
+ OUTPUT
29
+ assert_equal 1, $?.exitstatus
30
+ assert output.include?(expected), "#{output} should include #{expected}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def test_run_dtr_test_task_with_mysql_database
37
+ new_simple_project do |testdata|
38
+ FileUtils.cp_r(testdata + "/config/database.yml.mysql", testdata + "/config/database.yml")
39
+ assert_run_dtr_test_task_success_with(testdata)
40
+ Dir.chdir(agent1_runner1_dir) do
41
+ assert File.exist?('created_by_database_yml_mysql')
42
+ end
43
+ end
44
+ end
45
+
46
+ def test_run_dtr_test_task_with_database_yml_dtr_specified
47
+ new_simple_project do |testdata|
48
+ FileUtils.cp_r(testdata + "/config/database.yml.mysql", testdata + "/config/database.yml.dtr")
49
+ assert_run_dtr_test_task_success_with(testdata)
50
+ Dir.chdir(agent1_runner1_dir) do
51
+ assert File.exist?('created_by_database_yml_mysql')
52
+ end
53
+ end
54
+ end
55
+
56
+ def assert_run_dtr_test_task_success_with(testdata)
57
+ assert_fork_process_exits_ok do
58
+ Dir.chdir(testdata) do
59
+ output = %x[rake dtr:test DTR_GROUP='#{DTR::AgentHelper::GROUP}' BROADCAST_IP=localhost]
60
+ expected = <<-OUTPUT
61
+ 5 tests, 7 assertions, 0 failures, 0 errors
62
+ OUTPUT
63
+ assert_equal 0, $?.exitstatus
64
+ assert output.include?(expected), "should include #{expected}"
65
+ end
66
+ end
67
+ end
68
+
69
+ def new_simple_project
70
+ simple_project = File.expand_path(File.dirname(__FILE__) + '/../../testdata/rails_projects/simple_project')
71
+ testdata = File.expand_path(File.dirname(__FILE__) + '/rails_ext_test')
72
+ FileUtils.rm_rf(testdata)
73
+ FileUtils.cp_r(simple_project, testdata)
74
+
75
+ lib_dir = File.expand_path(File.dirname(__FILE__) + '/../../lib')
76
+ tasks_dir = File.expand_path(File.dirname(__FILE__) + '/../../tasks')
77
+ dtr_plugin_dir = testdata + '/vendor/plugins/dtr'
78
+ FileUtils.mkdir_p(dtr_plugin_dir)
79
+ FileUtils.cp_r(lib_dir, dtr_plugin_dir)
80
+ FileUtils.cp_r(tasks_dir, dtr_plugin_dir)
81
+
82
+ yield testdata
83
+ ensure
84
+ FileUtils.rm_rf(testdata)
85
+ end
86
+ end
@@ -20,4 +20,18 @@ OUTPUT
20
20
  stop_agents
21
21
  FileUtils.rm_rf("raketasks_test_agent")
22
22
  end
23
+
24
+ def test_test_task_with_processes
25
+ test_dir = File.expand_path(File.dirname(__FILE__) + '/../../testdata/raketasks')
26
+ Dir.chdir(test_dir) do
27
+ output = %x[rake dtr P=3]
28
+ expected = <<-OUTPUT
29
+ 1 tests, 1 assertions, 0 failures, 0 errors
30
+ OUTPUT
31
+ assert_equal 0, $?.exitstatus
32
+ assert output.include?(expected), "should include #{expected}"
33
+ end
34
+ ensure
35
+ FileUtils.rm_rf("#{test_dir}/#{Socket.gethostname.gsub(/[^\d\w]/, '_')}")
36
+ end
23
37
  end
@@ -9,8 +9,8 @@ class SyncCodebaseTest < Test::Unit::TestCase
9
9
  testdata_dir = File.expand_path(File.dirname(__FILE__) + '/../../testdata')
10
10
 
11
11
  master = Process.fork do
12
- DTR.configuration.with_rinda_server do
13
- Dir.chdir(testdata_dir) do
12
+ Dir.chdir(testdata_dir) do
13
+ DTR.configuration.with_rinda_server do
14
14
  DTR::Cmd.execute('rake dtr_repackage')
15
15
  provide_file DTR::SyncCodebase::CopiablePackage.new
16
16
  DRb.thread.join
@@ -20,10 +20,12 @@ class SyncCodebaseTest < Test::Unit::TestCase
20
20
  #sleep for waiting rinda server start
21
21
  sleep(1)
22
22
  client = Process.fork do
23
- start_service
24
23
  Dir.mkdir("test_sync_codebase")
25
24
  Dir.chdir("test_sync_codebase") do
26
- sync_codebase
25
+ start_service
26
+ sync_codebase do
27
+ do_work(unpackage_cmd)
28
+ end
27
29
  end
28
30
  end
29
31
  Process.waitpid client
@@ -31,36 +33,11 @@ class SyncCodebaseTest < Test::Unit::TestCase
31
33
  assert !File.exists?("test_sync_codebase/#{package_copy_file}")
32
34
  ensure
33
35
  stop_service rescue nil
34
- DTR.kill_process master
35
- DTR.kill_process client
36
+ kill_process master
37
+ kill_process client
36
38
  FileUtils.rm_rf("test_sync_codebase")
37
39
  Dir.chdir(testdata_dir) do
38
40
  DTR::Cmd.execute('rake dtr_clobber_package')
39
41
  end
40
42
  end
41
-
42
- def test_should_not_sync_codebase_and_setup_working_dir_when_agent_is_in_same_dir_with_master_process
43
- @master_dir = File.expand_path(File.dirname(__FILE__) + '/../../testdata/verify_dir_pwd')
44
- @agent = start_agent_at @master_dir, 2, false
45
- begin
46
- assert_fork_process_exits_ok do
47
- Dir.chdir(@master_dir) do
48
- require 'verify_dir_pwd_test_case'
49
- end
50
- $argv_dup = ['verify_dir_pwd_test_case.rb']
51
- suite = Test::Unit::TestSuite.new('test_should_not_sync_codebase_and_setup_working_dir')
52
- suite << VerifyDirPwdTestCase.suite
53
-
54
- Dir.chdir(@master_dir) do
55
- result = runit(suite)
56
- assert result.passed?
57
- assert_equal 1, result.run_count
58
- end
59
- end
60
- ensure
61
- DTR.kill_process @agent
62
- Process.waitall
63
- end
64
- end
65
-
66
43
  end
@@ -5,7 +5,7 @@ include DTR::AgentHelper
5
5
  class SyncLoggerTest < Test::Unit::TestCase
6
6
 
7
7
  def setup
8
- start_agents
8
+ start_agents(:size => 1)
9
9
  end
10
10
 
11
11
  def teardown
@@ -13,8 +13,8 @@ class SyncLoggerTest < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_master_process_should_get_log_of_agents
16
+ @logger = LoggerStub.new
16
17
  assert_fork_process_exits_ok do
17
- @logger = LoggerStub.new
18
18
  DTR.logger = @logger
19
19
 
20
20
  $argv_dup = ['a_test_case.rb']
@@ -23,10 +23,13 @@ class SyncLoggerTest < Test::Unit::TestCase
23
23
  runit(suite)
24
24
 
25
25
  logs = @logger.logs.flatten.join("\n")
26
- assert(/From #{Socket.gethostname}: => Herald starts off\.\.\./ =~ logs)
26
+ # puts logs
27
+ assert(/From #{Socket.gethostname}: => Herald starts off/ =~ logs)
27
28
  assert(/From #{Socket.gethostname}: runner0: test files loaded/ =~ logs)
28
29
  #when use Delegator to implement UndumpedLogger, there are lots of 'nil' in the log
29
30
  assert(/nil/ !~ logs)
30
31
  end
32
+ ensure
33
+ @logger.clear
31
34
  end
32
35
  end