dtr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,11 @@
1
1
  = DTR Changelog
2
2
 
3
+ == release 0.0.4
4
+ * added timeout for running test more stable
5
+ the default timeout is 60 sec, can be changed by environment variable 'RUN_TEST_TIMEOUT'
6
+ * output master process log into different log file with runners
7
+
8
+
3
9
  == release 0.0.3
4
10
  * more stable and maintainable
5
11
  * added monitor command for monitoring the server status
data/README CHANGED
@@ -33,7 +33,7 @@ grid".
33
33
 
34
34
  The latest version of DTR can be found at
35
35
 
36
- * http://rubyforge.org/projects/dtr/
36
+ * http://github.com/xli/dtr/tree/master
37
37
 
38
38
  == Installation
39
39
 
@@ -60,12 +60,6 @@ If you wish to run the unit and functional tests that come with DTR:
60
60
 
61
61
  rake # You need a version of rake installed
62
62
 
63
- == DTR References
64
-
65
- * DTR Documentation Home: http://dtr.rubyforge.org
66
- * DTR Project Page: http://rubyforge.org/projects/dtr
67
- * DTR API Documents: http://dtr.rubyforge.org
68
-
69
63
  == Simple Example
70
64
 
71
65
  Once installed, you can run DTR server anywhere:
@@ -250,16 +244,11 @@ DTR is available under an Apache License Version 2.
250
244
 
251
245
  == Support
252
246
 
253
- The DTR homepage is http://dtr.rubyforge.org. You can find the DTR
254
- RubyForge page at http://rubyforge.org/projects/dtr or Google Code
255
- project at http://code.google.com/p/dtrunner.
256
-
257
247
  Feel free to submit commits or feature requests. If you send a patch,
258
248
  remember to update the corresponding unit tests. If fact, I prefer
259
249
  new feature to be submitted in the form of new unit tests.
260
250
 
261
- For other information, feel free to ask on the ruby-talk mailing list
262
- or contact mailto:swing1979@gmail.com.
251
+ For other information, feel free to contact mailto:swing1979@gmail.com.
263
252
 
264
253
  == Usage
265
254
 
data/Rakefile CHANGED
@@ -130,67 +130,15 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
130
130
  # Create a task that will package the DTR software into distributable
131
131
  # tar, zip and gem files.
132
132
 
133
- PKG_FILES = FileList[
134
- 'install.rb',
135
- '[A-Z]*',
136
- 'bin/**/*',
137
- 'lib/**/*.rb',
138
- 'lib/**/*.rake',
139
- 'test/**/*.rb',
140
- 'doc/**/*'
141
- ]
142
- PKG_FILES.exclude('doc/example/*.o')
143
- PKG_FILES.exclude(%r{doc/example/main$})
144
-
145
133
  if ! defined?(Gem)
146
134
  puts "Package Target requires RubyGEMs"
147
135
  else
148
- spec = Gem::Specification.new do |s|
149
-
150
- #### Basic information.
151
-
152
- s.name = 'dtr'
153
- s.version = $package_version
154
- s.summary = "DTR is a distributed test runner to run tests on distributed computers for decreasing build time."
155
-
156
- #### Dependencies and requirements.
157
-
158
- s.add_dependency('daemons', '> 1.0.7')
159
- #s.requirements << ""
160
-
161
- #### Which files are to be included in this gem? Everything! (Except SVN directories.)
162
-
163
- s.files = PKG_FILES.to_a.delete_if {|item| item.include?(".svn")}
164
-
165
- #### Load-time details: library and application (you will need one or both).
166
-
167
- s.require_path = 'lib' # Use these for libraries.
168
-
169
- s.bindir = "bin" # Use these for applications.
170
- s.executables = ["dtr"]
171
- s.default_executable = "dtr"
172
-
173
- #### Documentation and testing.
174
-
175
- s.has_rdoc = true
176
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
177
- s.rdoc_options = rd.options
178
-
179
- #### Author and project details.
180
-
181
- s.author = "Li Xiao"
182
- s.email = "swing1979@gmail.com"
183
- s.homepage = "http://dtr.rubyforge.org"
184
- s.rubyforge_project = "dtr"
185
- # if ENV['CERT_DIR']
186
- # s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
187
- # s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
188
- # end
189
- end
190
-
191
- package_task = Rake::GemPackageTask.new(spec) do |pkg|
192
- #pkg.need_zip = true
193
- #pkg.need_tar = true
136
+ File.open(File.dirname(__FILE__) + '/dtr.gemspec') do |f|
137
+ spec = eval(f.read)
138
+ package_task = Rake::GemPackageTask.new(spec) do |pkg|
139
+ #pkg.need_zip = true
140
+ #pkg.need_tar = true
141
+ end
194
142
  end
195
143
  end
196
144
 
@@ -0,0 +1,34 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'dtr'
3
+ spec.version = "0.0.4"
4
+ spec.summary = "DTR is a distributed test runner to run tests on distributed computers for decreasing build time."
5
+
6
+ #### Dependencies and requirements.
7
+
8
+ spec.add_dependency('daemons', '> 1.0.7')
9
+ #s.requirements << ""
10
+
11
+ #### Which files are to be included in this gem? Everything! (Except SVN directories.)
12
+
13
+ spec.files = FileList['lib/**/*.rb', 'lib/**/*.rake', 'bin/*', '[a-zA-Z]*'].to_a
14
+ p FileList['lib/**/*.rb', 'lib/**/*.rake', 'bin/*', '[a-zA-Z]*'].to_a
15
+
16
+ #### Load-time details: library and application (you will need one or both).
17
+
18
+ spec.require_path = 'lib' # Use these for libraries.
19
+
20
+ spec.bindir = "bin" # Use these for applications.
21
+ spec.executables = ["dtr"]
22
+ spec.default_executable = "dtr"
23
+
24
+ #### Documentation and testing.
25
+
26
+ spec.has_rdoc = false
27
+
28
+ #### Author and project details.
29
+
30
+ spec.author = "Li Xiao"
31
+ spec.email = "swing1979@gmail.com"
32
+ spec.homepage = "http://github.com/xli/dtr/tree/master"
33
+ spec.rubyforge_project = "dtr"
34
+ end
data/lib/dtr.rb CHANGED
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- DTRVERSION="0.0.3"
15
+ DTRVERSION="0.0.4"
16
16
  DTROPTIONS = {} unless defined?(DTROPTIONS)
17
17
 
18
18
  require 'fileutils'
@@ -16,6 +16,18 @@ require 'pstore'
16
16
 
17
17
  require 'logger'
18
18
 
19
+ class Array
20
+ def blank?
21
+ empty?
22
+ end
23
+ end
24
+
25
+ class NilClass
26
+ def blank?
27
+ true
28
+ end
29
+ end
30
+
19
31
  module DTR
20
32
 
21
33
  MESSAGE_KEY = :message
@@ -30,7 +42,7 @@ module DTR
30
42
  else
31
43
  DTROPTIONS[:log_file] || 'dtr.log'
32
44
  end
33
- Logger.new(log_file, 1, 5*1024*1024)
45
+ Logger.new("./#{log_file}", 1, 5*1024*1024)
34
46
  end
35
47
  DTROPTIONS[:logger].datetime_format = "%m-%d %H:%M:%S"
36
48
  DTROPTIONS[:logger].level = DTROPTIONS[:log_level] || Logger::INFO
@@ -60,6 +60,7 @@ module DTR
60
60
 
61
61
  private
62
62
  def start_runners
63
+ return if self.processes.to_i <= 0
63
64
  runner_names = []
64
65
  self.processes.to_i.times {|i| runner_names << "runner#{i}"}
65
66
  %x[dtr -r #{runner_names.join(',')} -D #{runner_options}]
@@ -39,15 +39,15 @@ module DTR
39
39
 
40
40
  class RunnerAgent
41
41
 
42
- def self.start(runner_names=["Distributed Test Runner"], setup_cmd=nil)
42
+ def self.start(runner_names=["Distributed Test Runner"], setup_agent_env_cmd=nil)
43
43
  DTR.with_monitor do
44
- new(runner_names, setup_cmd).launch
44
+ new(runner_names, setup_agent_env_cmd).launch
45
45
  end
46
46
  end
47
47
 
48
- def initialize(runner_names, setup_cmd)
48
+ def initialize(runner_names, setup_agent_env_cmd)
49
49
  @runner_names = runner_names.is_a?(Array) ? runner_names : [runner_names.to_s]
50
- @setup_cmd = setup_cmd || ""
50
+ @setup_agent_env_cmd = setup_agent_env_cmd || ""
51
51
  @runner_pids = []
52
52
  @herald = nil
53
53
  @working_env_key = :working_env
@@ -85,7 +85,7 @@ module DTR
85
85
  kill_all_runners
86
86
  ENV['DTR_MASTER_ENV'] = working_env[:dtr_master_env]
87
87
 
88
- if Cmd.execute(@setup_cmd)
88
+ if Cmd.execute(@setup_agent_env_cmd || working_env[:setup_agent_env_cmd])
89
89
  @runner_names.each do |name|
90
90
  @runner_pids << drb_fork { Runner.start name, working_env }
91
91
  end
@@ -100,7 +100,7 @@ module DTR
100
100
  private
101
101
 
102
102
  def kill_all_runners
103
- unless @runner_pids.empty?
103
+ unless @runner_pids.blank?
104
104
  @runner_pids.each{ |pid| Process.kill 'KILL', pid rescue nil }
105
105
  DTR.info "=> All runners(#{@runner_pids.join(", ")}) were killed."
106
106
  @runner_pids = []
@@ -139,7 +139,7 @@ module DTR
139
139
  def beat
140
140
  loop do
141
141
  begin
142
- if @env_store[@key].empty?
142
+ if @env_store[@key].blank?
143
143
  @provider.send_message('---/V---')
144
144
  else
145
145
  while message = @env_store[@key].first
@@ -179,7 +179,7 @@ module DTR
179
179
  begin
180
180
  working_env = @provider.working_env
181
181
  DTR.debug { "working env: #{working_env.inspect}" }
182
- if working_env[:files].empty?
182
+ if working_env[:files].blank?
183
183
  DTR.error "No test files need to load?(working env: #{working_env.inspect})"
184
184
  else
185
185
  @env_store[@key] = working_env if @env_store[@key].nil? || @env_store[@key][:identifier] != working_env[:identifier]
@@ -253,6 +253,11 @@ module DTR
253
253
  @provider.provide(self)
254
254
  end
255
255
 
256
+ def reboot
257
+ DTR.info "#{self} is rebooting. Ran #{@started.size} tests, finished #{@run_finished.size}."
258
+ @provider.provide(self)
259
+ end
260
+
256
261
  def shutdown
257
262
  DTR.info "#{self} is shutting down. Ran #{@started.size} tests, finished #{@run_finished.size}."
258
263
  @provider.stop_service rescue exit!
@@ -18,8 +18,10 @@ require 'test/unit/testcase'
18
18
  require 'test/unit/util/observable'
19
19
  require 'monitor'
20
20
  require 'drb'
21
+ require 'timeout'
21
22
 
22
23
  DTROPTIONS = {} unless defined?(DTROPTIONS)
24
+ DTROPTIONS[:log_file] = 'dtr_master_process.log' unless DTROPTIONS[:log_file]
23
25
 
24
26
  module DTR
25
27
  def reject
@@ -57,7 +59,7 @@ module DTR
57
59
  def add_finish_count
58
60
  synchronize do
59
61
  @finish_count += 1
60
- @complete_cond.signal if complete?
62
+ @complete_cond.signal
61
63
  end
62
64
  end
63
65
 
@@ -69,18 +71,18 @@ module DTR
69
71
 
70
72
  def wait_until_complete
71
73
  synchronize do
72
- @complete_cond.wait_until {complete?} unless complete?
74
+ @complete_cond.wait_until {complete?}
73
75
  end
74
76
  end
75
77
 
76
78
  private
77
79
  def complete?
78
- DTR.debug {"Counter status: #{status}"}
80
+ DTR.info{ "Counter status: #{status}" }
79
81
  @finish_count >= @start_count
80
82
  end
81
83
 
82
84
  def status
83
- "finish_count: #{@finish_count}; start_count: #{@start_count}"
85
+ "finish_count => #{@finish_count}, start_count => #{@start_count}"
84
86
  end
85
87
  end
86
88
 
@@ -162,6 +164,7 @@ module DTR
162
164
  end
163
165
 
164
166
  RUN_TEST_FINISHED = "::DRbTestRunner::RUN_TEST_FINISHED"
167
+ DEFAULT_RUN_TEST_TIMEOUT = 60 #seconds
165
168
 
166
169
  def initialize(test, result, &progress_block)
167
170
  @test = test
@@ -182,10 +185,17 @@ module DTR
182
185
  def run_test_on(runner)
183
186
  Thread.start do
184
187
  begin
185
- runner.run(@test, @result, &@progress_block)
188
+ Timeout.timeout(ENV['RUN_TEST_TIMEOUT'] || DEFAULT_RUN_TEST_TIMEOUT) do
189
+ runner.run(@test, @result, &@progress_block)
190
+ end
186
191
  @progress_block.call(RUN_TEST_FINISHED, @test.name)
192
+ rescue Timeout::Error => e
193
+ DTR.info {"Run test timeout(#{ENV['RUN_TEST_TIMEOUT'] || DEFAULT_RUN_TEST_TIMEOUT}), reboot runner"}
194
+ runner.reboot rescue nil
195
+ DTR.info {"rerun test: #{@test.name}"}
196
+ self.run
187
197
  rescue DRb::DRbConnError => e
188
- DTR.info{ "DRb::DRbConnError(#{e.message}), rerun test: #{@test.name}" }
198
+ DTR.info {"DRb::DRbConnError(#{e.message}), rerun test: #{@test.name}"}
189
199
  self.run
190
200
  rescue Exception => e
191
201
  DTR.info{ "#{test.name}, rescue an exception: #{e.message}, add error into result." }
@@ -235,7 +245,7 @@ module DTR
235
245
  alias_method :__run__, :run
236
246
 
237
247
  def run(result, &progress_block)
238
- DTR.debug { "start of run suite(#{name}), size: #{size};"}
248
+ DTR.info { "start of run suite(#{name}), size: #{size};"}
239
249
 
240
250
  if result.kind_of?(ThreadSafeTestResult)
241
251
  __run__(result, &progress_block)
@@ -246,7 +256,8 @@ module DTR
246
256
 
247
257
  DTR.service_provider.setup_working_env WorkingEnv.refresh
248
258
 
249
- puts 'Refreshed dtr working environment, looking for runner service...' unless DTR.silent?
259
+ puts 'Refreshed dtr working environment, looking for runner service...' unless ENV['DTR_ENV'] == 'test'
260
+ DTR.info {"Master process started at #{Time.now}"}
250
261
  result = ThreadSafeTestResult.new(result)
251
262
  __run__(result) do |channel, value|
252
263
  DTR.debug { "=> channel: #{channel}, value: #{value}" }
@@ -259,7 +270,7 @@ module DTR
259
270
  DTR.debug { "==> teardown" }
260
271
  DTR.service_provider.teardown_working_env
261
272
  end
262
- DTR.debug { "end of run suite(#{name}), test result status: #{result}, counter status: #{DRbTestRunner.counter}"}
273
+ DTR.info { "end of run suite(#{name}), test result status: #{result}, counter status: #{DRbTestRunner.counter}"}
263
274
  end
264
275
  end
265
276
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Li Xiao
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-28 00:00:00 +08:00
12
+ date: 2008-09-02 00:00:00 +08:00
13
13
  default_executable: dtr
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: daemons
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -27,19 +28,9 @@ executables:
27
28
  - dtr
28
29
  extensions: []
29
30
 
30
- extra_rdoc_files:
31
- - README
32
- - LICENSE.txt
33
- - TODO
34
- - CHANGES
31
+ extra_rdoc_files: []
32
+
35
33
  files:
36
- - install.rb
37
- - CHANGES
38
- - LICENSE.TXT
39
- - Rakefile
40
- - README
41
- - TODO
42
- - bin/dtr
43
34
  - lib/dtr/base.rb
44
35
  - lib/dtr/raketasks.rb
45
36
  - lib/dtr/runner.rb
@@ -47,23 +38,28 @@ files:
47
38
  - lib/dtr/test_unit.rb
48
39
  - lib/dtr/test_unit_injection.rb
49
40
  - lib/dtr.rb
50
- - test/base_test.rb
51
- - test/logger_test.rb
52
- - test/scenario_tests.rb
53
- - test/test_helper.rb
54
- - test/test_unit_test.rb
55
- - doc/jamis.rb
56
- - LICENSE.txt
57
- has_rdoc: true
58
- homepage: http://dtr.rubyforge.org
59
- post_install_message:
60
- rdoc_options:
61
- - --line-numbers
62
- - --inline-source
63
- - --main
41
+ - bin/dtr
42
+ - bin
43
+ - CHANGES
44
+ - doc
45
+ - dtr.gemspec
46
+ - html
47
+ - install.rb
48
+ - lib
49
+ - LICENSE.TXT
50
+ - log
51
+ - pkg
52
+ - Rakefile
64
53
  - README
65
- - --title
66
- - "\"DTR -- Distributed Test Runner"
54
+ - rspec
55
+ - test
56
+ - testdata
57
+ - TODO
58
+ has_rdoc: false
59
+ homepage: http://github.com/xli/dtr/tree/master
60
+ post_install_message:
61
+ rdoc_options: []
62
+
67
63
  require_paths:
68
64
  - lib
69
65
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -81,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
77
  requirements: []
82
78
 
83
79
  rubyforge_project: dtr
84
- rubygems_version: 1.0.1
80
+ rubygems_version: 1.2.0
85
81
  signing_key:
86
82
  specification_version: 2
87
83
  summary: DTR is a distributed test runner to run tests on distributed computers for decreasing build time.