jstorimer-deep-test 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/README.rdoc +70 -41
- data/Rakefile +104 -32
- data/TODO +2 -2
- data/VERSION +1 -1
- data/bin/deep_test +15 -0
- data/jstorimer-deep-test-0.1.0.gem +0 -0
- data/jstorimer-deep-test.gemspec +1425 -0
- data/lib/deep_test.rb +40 -28
- data/lib/deep_test/database/mysql_setup_listener.rb +12 -12
- data/lib/deep_test/database/setup_listener.rb +23 -23
- data/lib/deep_test/distributed/dispatch_controller.rb +10 -17
- data/lib/deep_test/distributed/drb_client_connection_info.rb +15 -0
- data/lib/deep_test/distributed/master_test_server.rb +52 -0
- data/lib/deep_test/distributed/multi_test_server_proxy.rb +44 -0
- data/lib/deep_test/distributed/null_work_unit.rb +12 -0
- data/lib/deep_test/distributed/remote_worker_client.rb +54 -0
- data/lib/deep_test/distributed/remote_worker_server.rb +82 -0
- data/lib/deep_test/distributed/rsync.rb +12 -25
- data/lib/deep_test/distributed/show_status.rhtml +41 -0
- data/lib/deep_test/distributed/test_server.rb +78 -0
- data/lib/deep_test/distributed/test_server_status.rb +9 -0
- data/lib/deep_test/distributed/test_server_workers.rb +24 -0
- data/lib/deep_test/distributed/throughput_runner.rb +42 -0
- data/lib/deep_test/distributed/throughput_statistics.rb +26 -0
- data/lib/deep_test/distributed/throughput_worker_client.rb +19 -0
- data/lib/deep_test/extensions/drb_extension.rb +34 -0
- data/lib/deep_test/listener_list.rb +1 -1
- data/lib/deep_test/local_workers.rb +55 -0
- data/lib/deep_test/logger.rb +2 -17
- data/lib/deep_test/marshallable_exception_wrapper.rb +4 -4
- data/lib/deep_test/metrics/gatherer.rb +67 -0
- data/lib/deep_test/metrics/queue_lock_wait_time_measurement.rb +133 -0
- data/lib/deep_test/{null_listener.rb → null_worker_listener.rb} +14 -14
- data/lib/deep_test/option.rb +60 -0
- data/lib/deep_test/options.rb +42 -45
- data/lib/deep_test/process_orchestrator.rb +49 -0
- data/lib/deep_test/rake_tasks.rb +1 -3
- data/lib/deep_test/result_reader.rb +6 -10
- data/lib/deep_test/rspec_detector.rb +1 -1
- data/lib/deep_test/server.rb +75 -0
- data/lib/deep_test/spec.rb +1 -5
- data/lib/deep_test/spec/extensions/example_methods.rb +1 -7
- data/lib/deep_test/spec/extensions/reporter.rb +29 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +2 -3
- data/lib/deep_test/spec/runner.rb +17 -32
- data/lib/deep_test/spec/work_result.rb +0 -2
- data/lib/deep_test/test/runner.rb +2 -2
- data/lib/deep_test/test/supervised_test_suite.rb +10 -9
- data/lib/deep_test/test/work_result.rb +0 -1
- data/lib/deep_test/test_task.rb +1 -1
- data/lib/deep_test/ui/console.rb +11 -9
- data/lib/deep_test/warlock.rb +25 -37
- data/lib/deep_test/worker.rb +57 -0
- data/sample_rails_project/deep_test.rb +0 -4
- data/sample_rails_project/lib/{foreign_host_agent_simulation_listener.rb → foreign_host_worker_simulation_listener.rb} +4 -6
- data/sample_rails_project/lib/tasks/deep_test.rake +4 -13
- data/script/internal/run_test_suite.rb +7 -0
- data/script/public/master_test_server.rb +24 -0
- data/script/public/test_server.rb +18 -0
- data/script/public/test_throughput.rb +29 -0
- data/spec/deep_test/option_spec.rb +33 -0
- data/spec/deep_test/options_spec.rb +59 -80
- data/spec/deep_test/spec/extensions/example_methods_spec.rb +4 -5
- data/spec/deep_test/spec/extensions/spec_task_spec.rb +6 -4
- data/spec/deep_test/spec/runner_spec.rb +32 -59
- data/spec/spec_helper.rb +6 -14
- data/spec/thread_worker.rb +25 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +9 -13
- data/test/deep_test/distributed/dispatch_controller_test.rb +177 -130
- data/test/deep_test/distributed/drb_client_connection_info_test.rb +42 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +34 -38
- data/test/deep_test/distributed/master_test_server_test.rb +32 -0
- data/test/deep_test/distributed/multi_test_server_proxy_test.rb +96 -0
- data/test/deep_test/distributed/remote_worker_client_test.rb +180 -0
- data/test/deep_test/distributed/remote_worker_server_test.rb +99 -0
- data/test/deep_test/distributed/rsync_test.rb +62 -42
- data/test/deep_test/distributed/test_server_test.rb +94 -0
- data/test/deep_test/distributed/test_server_workers_test.rb +26 -0
- data/test/deep_test/distributed/throughput_runner_test.rb +68 -0
- data/test/deep_test/distributed/throughput_worker_client_test.rb +28 -0
- data/test/deep_test/listener_list_test.rb +15 -17
- data/test/deep_test/local_workers_test.rb +22 -0
- data/test/deep_test/logger_test.rb +7 -34
- data/test/deep_test/marshallable_exception_wrapper_test.rb +29 -31
- data/test/deep_test/metrics/gatherer_test.rb +66 -0
- data/test/deep_test/process_orchestrator_test.rb +11 -0
- data/test/deep_test/result_reader_test.rb +95 -95
- data/test/deep_test/server_test.rb +58 -0
- data/test/deep_test/test/extensions/error_test.rb +36 -38
- data/test/deep_test/test/runner_test.rb +3 -7
- data/test/deep_test/test/supervised_test_suite_test.rb +61 -89
- data/test/deep_test/test/work_result_test.rb +76 -80
- data/test/deep_test/test/work_unit_test.rb +51 -53
- data/test/deep_test/test_task_test.rb +38 -10
- data/test/deep_test/ui/console_test.rb +4 -8
- data/test/deep_test/warlock_test.rb +31 -33
- data/test/deep_test/worker_test.rb +94 -0
- data/test/failing.rake +11 -0
- data/{negative_acceptance_tests/failing_test.rb → test/failing.rb} +1 -3
- data/{infrastructure → test}/fake_deadlock_error.rb +0 -0
- data/test/simple_test_blackboard.rb +45 -0
- data/test/simple_test_blackboard_test.rb +33 -0
- data/{infrastructure → test}/test_factory.rb +0 -0
- data/test/test_helper.rb +5 -20
- data/test/test_task_test.rb +57 -60
- metadata +78 -87
- data/infrastructure/dynamic_teardown.rb +0 -22
- data/infrastructure/load.rb +0 -11
- data/infrastructure/test_central_command.rb +0 -15
- data/infrastructure/test_exception.rb +0 -7
- data/infrastructure/test_logger.rb +0 -11
- data/infrastructure/test_operator.rb +0 -15
- data/infrastructure/test_result.rb +0 -15
- data/infrastructure/thread_agent.rb +0 -21
- data/infrastructure/timewarp/Rakefile +0 -14
- data/infrastructure/timewarp/lib/timewarp.rb +0 -21
- data/infrastructure/timewarp/test/timewarp_test.rb +0 -45
- data/lib/deep_test/agent.rb +0 -108
- data/lib/deep_test/central_command.rb +0 -165
- data/lib/deep_test/cpu_info.rb +0 -22
- data/lib/deep_test/demon.rb +0 -25
- data/lib/deep_test/distributed/beachhead.rb +0 -104
- data/lib/deep_test/distributed/establish_beachhead.rb +0 -19
- data/lib/deep_test/distributed/landing_fleet.rb +0 -30
- data/lib/deep_test/distributed/landing_ship.rb +0 -60
- data/lib/deep_test/distributed/remote_deployment.rb +0 -56
- data/lib/deep_test/distributed/shell_environment.rb +0 -50
- data/lib/deep_test/distributed/ssh_client_connection_info.rb +0 -14
- data/lib/deep_test/failure_message.rb +0 -19
- data/lib/deep_test/lib_root.rb +0 -4
- data/lib/deep_test/local_deployment.rb +0 -46
- data/lib/deep_test/main.rb +0 -41
- data/lib/deep_test/metrics/data.rb +0 -34
- data/lib/deep_test/metrics/measurement.rb +0 -39
- data/lib/deep_test/proxy_io.rb +0 -77
- data/lib/deep_test/test/run_test_suite.rb +0 -5
- data/lib/telegraph.rb +0 -29
- data/lib/telegraph/ack_sequence.rb +0 -14
- data/lib/telegraph/logging.rb +0 -20
- data/lib/telegraph/message.rb +0 -39
- data/lib/telegraph/operator.rb +0 -47
- data/lib/telegraph/switchboard.rb +0 -57
- data/lib/telegraph/wire.rb +0 -73
- data/negative_acceptance_tests/dying_spec.rb +0 -13
- data/negative_acceptance_tests/dying_test.rb +0 -13
- data/negative_acceptance_tests/failing_spec.rb +0 -9
- data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +0 -16
- data/negative_acceptance_tests/passing_spec.rb +0 -10
- data/negative_acceptance_tests/passing_test.rb +0 -12
- data/negative_acceptance_tests/tasks.rake +0 -87
- data/negative_acceptance_tests/tests.rb +0 -60
- data/test/deep_test/agent_test.rb +0 -175
- data/test/deep_test/central_command_test.rb +0 -147
- data/test/deep_test/cpu_info_test.rb +0 -33
- data/test/deep_test/demon_test.rb +0 -23
- data/test/deep_test/distributed/beachhead_test.rb +0 -67
- data/test/deep_test/distributed/landing_fleet_test.rb +0 -55
- data/test/deep_test/distributed/landing_ship_test.rb +0 -48
- data/test/deep_test/distributed/remote_deployment_test.rb +0 -134
- data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +0 -1
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +0 -1
- data/test/deep_test/distributed/shell_environment_test.rb +0 -108
- data/test/deep_test/distributed/ssh_client_connection_info_test.rb +0 -34
- data/test/deep_test/local_deployment_test.rb +0 -19
- data/test/deep_test/main_test.rb +0 -12
- data/test/deep_test/metrics/data_test.rb +0 -22
- data/test/deep_test/metrics/measurement_test.rb +0 -18
- data/test/deep_test/proxy_io_test.rb +0 -104
@@ -0,0 +1,34 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class DRbBindAllTCPSocket < DRb::DRbTCPSocket
|
3
|
+
def self.parse_uri(uri)
|
4
|
+
if uri =~ /^drubyall:\/\/(.*?):(\d+)(\?(.*))?$/
|
5
|
+
host = $1
|
6
|
+
port = $2.to_i
|
7
|
+
option = $4
|
8
|
+
[host, port, option]
|
9
|
+
else
|
10
|
+
raise(DRb::DRbBadScheme, uri) unless uri =~ /^drubyall:/
|
11
|
+
raise(DRb::DRbBadURI, 'can\'t parse uri:' + uri)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Open a server listening for connections at +uri+ using
|
16
|
+
# configuration +config+.
|
17
|
+
def self.open_server(uri, config)
|
18
|
+
uri = 'drubyall://:0' unless uri
|
19
|
+
host, port, opt = parse_uri(uri)
|
20
|
+
|
21
|
+
if host.size == 0
|
22
|
+
host = getservername
|
23
|
+
end
|
24
|
+
|
25
|
+
DeepTest.logger.debug("Listening on port #{port}, all addresses.")
|
26
|
+
soc = TCPServer.open('0.0.0.0', port)
|
27
|
+
port = soc.addr[1] if port == 0
|
28
|
+
uri = "druby://#{host}:#{port}"
|
29
|
+
self.new(uri, soc, config)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
DRb::DRbProtocol.add_protocol DeepTest::DRbBindAllTCPSocket
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class LocalWorkers
|
3
|
+
def initialize(options)
|
4
|
+
@options = options
|
5
|
+
@warlock = Warlock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_files(files)
|
9
|
+
files.each {|f| load f}
|
10
|
+
end
|
11
|
+
|
12
|
+
def server
|
13
|
+
@options.server
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_all
|
17
|
+
each_worker do |worker_num|
|
18
|
+
start_worker(worker_num) do
|
19
|
+
reseed_random_numbers
|
20
|
+
reconnect_to_database
|
21
|
+
worker = DeepTest::Worker.new(worker_num,
|
22
|
+
server,
|
23
|
+
@options.new_listener_list)
|
24
|
+
worker.run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def stop_all
|
30
|
+
@warlock.stop_all
|
31
|
+
end
|
32
|
+
|
33
|
+
def number_of_workers
|
34
|
+
@options.number_of_workers
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def reconnect_to_database
|
40
|
+
ActiveRecord::Base.connection.reconnect! if defined?(ActiveRecord::Base)
|
41
|
+
end
|
42
|
+
|
43
|
+
def start_worker(worker_num, &blk)
|
44
|
+
@warlock.start("worker #{worker_num}", &blk)
|
45
|
+
end
|
46
|
+
|
47
|
+
def reseed_random_numbers
|
48
|
+
srand
|
49
|
+
end
|
50
|
+
|
51
|
+
def each_worker
|
52
|
+
number_of_workers.to_i.times { |worker_num| yield worker_num }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/deep_test/logger.rb
CHANGED
@@ -2,31 +2,16 @@ module DeepTest
|
|
2
2
|
class Logger < ::Logger
|
3
3
|
def initialize(*args)
|
4
4
|
super
|
5
|
-
|
6
|
-
self.formatter = proc { |severity, time, progname, msg| "[DeepTest@#{hostname}] #{time.strftime "%F %T"} #{msg}\n" }
|
5
|
+
self.formatter = proc { |severity, time, progname, msg| "[DeepTest] #{msg}\n" }
|
7
6
|
self.level = configured_log_level
|
8
7
|
end
|
9
8
|
|
10
|
-
def io_stream
|
11
|
-
@logdev.dev
|
12
|
-
end
|
13
|
-
|
14
9
|
def configured_log_level
|
15
10
|
if ENV['DEEP_TEST_LOG_LEVEL']
|
16
|
-
Logger.const_get(ENV['DEEP_TEST_LOG_LEVEL']
|
11
|
+
Logger.const_get(ENV['DEEP_TEST_LOG_LEVEL'])
|
17
12
|
else
|
18
13
|
Logger::INFO
|
19
14
|
end
|
20
15
|
end
|
21
|
-
|
22
|
-
Severity.constants.each do |severity|
|
23
|
-
eval <<-end_src
|
24
|
-
def #{severity.downcase}
|
25
|
-
super
|
26
|
-
rescue Exception => e
|
27
|
-
super "\#{e.class}: \#{e} occurred logging on \#{caller[0]}", &nil
|
28
|
-
end
|
29
|
-
end_src
|
30
|
-
end
|
31
16
|
end
|
32
17
|
end
|
@@ -19,8 +19,8 @@ module DeepTest
|
|
19
19
|
klass = eval("::" + classname)
|
20
20
|
resolved_message = message
|
21
21
|
rescue => e
|
22
|
-
DeepTest.logger.debug
|
23
|
-
DeepTest.logger.debug
|
22
|
+
DeepTest.logger.debug("Unable to load exception class: #{classname}: #{e.message}")
|
23
|
+
DeepTest.logger.debug(e.backtrace.join("\n"))
|
24
24
|
|
25
25
|
klass = UnloadableException
|
26
26
|
resolved_message = "#{classname}: #{message}"
|
@@ -29,8 +29,8 @@ module DeepTest
|
|
29
29
|
begin
|
30
30
|
resolved_exception = klass.new resolved_message
|
31
31
|
rescue => e
|
32
|
-
DeepTest.logger.debug
|
33
|
-
DeepTest.logger.debug
|
32
|
+
DeepTest.logger.debug("Unable to instantiation exception class: #{classname}: #{e.message}")
|
33
|
+
DeepTest.logger.debug(e.backtrace.join("\n"))
|
34
34
|
|
35
35
|
resolved_exception = UnloadableException.new resolved_message
|
36
36
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module DeepTest
|
2
|
+
module Metrics
|
3
|
+
class Gatherer
|
4
|
+
def self.setup(options)
|
5
|
+
$metrics_gatherer = new(options)
|
6
|
+
|
7
|
+
at_exit do
|
8
|
+
$metrics_gatherer.write_file
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.enabled?
|
13
|
+
return false unless $metrics_gatherer
|
14
|
+
$metrics_gatherer.enabled?
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.section(title, &block)
|
18
|
+
$metrics_gatherer.section(title, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(options)
|
22
|
+
@options = options
|
23
|
+
@sections = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def enabled?
|
27
|
+
!@options.metrics_file.nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
def section(title, &block)
|
31
|
+
@sections << Section.new(title, &block) if enabled?
|
32
|
+
end
|
33
|
+
|
34
|
+
def render
|
35
|
+
@sections.map {|s| s.render}.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_file
|
39
|
+
return unless enabled?
|
40
|
+
File.open(@options.metrics_file, "w") do |io|
|
41
|
+
io << render
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Section
|
46
|
+
def initialize(title, &generate_measurements_block)
|
47
|
+
@title = title
|
48
|
+
@generate_measurements_block = generate_measurements_block
|
49
|
+
end
|
50
|
+
|
51
|
+
def measurement(name, value)
|
52
|
+
@measurements << [name, value]
|
53
|
+
end
|
54
|
+
|
55
|
+
def gather_measurements
|
56
|
+
@measurements = []
|
57
|
+
@generate_measurements_block.call(self)
|
58
|
+
end
|
59
|
+
|
60
|
+
def render
|
61
|
+
gather_measurements
|
62
|
+
"[#{@title}]\n" + @measurements.map {|name, value| "#{name}: #{value}"}.join("\n")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module DeepTest
|
2
|
+
module Metrics
|
3
|
+
module QueueLockWaitTimeMeasurement
|
4
|
+
attr_reader :total_pop_time, :total_push_time
|
5
|
+
|
6
|
+
def self.extended(o)
|
7
|
+
o.instance_eval do
|
8
|
+
alias pop_without_lock_wait_measurement pop
|
9
|
+
alias pop pop_with_lock_wait_measurement
|
10
|
+
|
11
|
+
alias push_without_lock_wait_measurement push
|
12
|
+
alias push push_with_lock_wait_measurement
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def pop_with_lock_wait_measurement(no_wait = false)
|
17
|
+
if no_wait
|
18
|
+
return measure(:add_pop_time) do
|
19
|
+
pop_without_lock_wait_measurement(no_wait)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
begin
|
23
|
+
# Measure without waiting to minimize extra time added
|
24
|
+
# above locking time
|
25
|
+
#
|
26
|
+
return measure(:add_pop_time) do
|
27
|
+
pop_without_lock_wait_measurement(true)
|
28
|
+
end
|
29
|
+
rescue ThreadError => e
|
30
|
+
if e.message == "queue empty"
|
31
|
+
# Normally we would have waiting for a condvar signal,
|
32
|
+
# so don't penalize time for locking here again - hence
|
33
|
+
# no measure
|
34
|
+
return pop_without_lock_wait_measurement(false)
|
35
|
+
else
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def push_with_lock_wait_measurement(value)
|
43
|
+
measure(:add_push_time) do
|
44
|
+
push_without_lock_wait_measurement(value)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def measure(accumulator)
|
49
|
+
start_time = Time.now
|
50
|
+
result = yield
|
51
|
+
send(accumulator, Time.now - start_time)
|
52
|
+
result
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_push_time(time)
|
56
|
+
Thread.exclusive do
|
57
|
+
@total_push_time ||= 0
|
58
|
+
@total_push_time += time
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_pop_time(time)
|
63
|
+
Thread.exclusive do
|
64
|
+
@total_pop_time ||= 0
|
65
|
+
@total_pop_time += time
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
if $0 == __FILE__
|
74
|
+
require 'thread'
|
75
|
+
require 'timeout'
|
76
|
+
|
77
|
+
thread_count = (ARGV[0] || 10).to_i
|
78
|
+
action_count = (ARGV[1] || 100).to_i
|
79
|
+
|
80
|
+
def test_measurement(thread_count, action_count)
|
81
|
+
q = Queue.new
|
82
|
+
q.extend DeepTest::Metrics::QueueLockWaitTimeMeasurement
|
83
|
+
|
84
|
+
threads = []
|
85
|
+
thread_count.times do
|
86
|
+
threads << Thread.new do
|
87
|
+
action_count.times do |i|
|
88
|
+
show_progress ".", action_count, i
|
89
|
+
q.push 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
thread_count.times do
|
95
|
+
threads << Thread.new do
|
96
|
+
action_count.times do |i|
|
97
|
+
show_progress "-", action_count, i
|
98
|
+
if rand(2) == 0
|
99
|
+
begin
|
100
|
+
q.pop(true)
|
101
|
+
rescue ThreadError
|
102
|
+
end
|
103
|
+
else
|
104
|
+
begin
|
105
|
+
Timeout.timeout(0.01) do
|
106
|
+
q.pop
|
107
|
+
end
|
108
|
+
rescue Timeout::Error
|
109
|
+
break
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
threads.each {|t| t.join}
|
117
|
+
|
118
|
+
puts
|
119
|
+
puts "Push Time: #{q.total_push_time}"
|
120
|
+
puts "Pop Time: #{q.total_pop_time}"
|
121
|
+
end
|
122
|
+
|
123
|
+
def show_progress(s, total, current)
|
124
|
+
if (current % (total / 5)) == 0
|
125
|
+
$stdout.print s
|
126
|
+
$stdout.flush
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
start_time = Time.now
|
131
|
+
test_measurement(thread_count, action_count)
|
132
|
+
puts "Total Run Time: #{Time.now - start_time}"
|
133
|
+
end
|
@@ -2,7 +2,7 @@ module DeepTest
|
|
2
2
|
#
|
3
3
|
# Listener that implements no-ops for all callbacks that DeepTest supports.
|
4
4
|
#
|
5
|
-
class
|
5
|
+
class NullWorkerListener
|
6
6
|
#
|
7
7
|
# Before DeepTest synchronizes any code during a distributed run,
|
8
8
|
# before_sync is called. If DeepTest is not running distributed,
|
@@ -12,51 +12,51 @@ module DeepTest
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
15
|
-
# Before DeepTest starts any
|
15
|
+
# Before DeepTest starts any workers, it instantiates a listener and
|
16
16
|
# invokes this method. No other callbacks are made to the listener
|
17
17
|
# instance receiving this message.
|
18
18
|
#
|
19
|
-
def
|
19
|
+
def before_starting_workers
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
23
|
-
# A separate listener instance is created in each
|
24
|
-
# notified that the
|
25
|
-
# provided for the listener to use. If you are using 3
|
23
|
+
# A separate listener instance is created in each worker process and
|
24
|
+
# notified that the worker is starting. The worker for the process is
|
25
|
+
# provided for the listener to use. If you are using 3 workers, this
|
26
26
|
# method is invoked 3 times on 3 distinct instances. These instances
|
27
27
|
# will also receive the starting_work and finished_work callbacks for
|
28
|
-
# the
|
28
|
+
# the worker provided.
|
29
29
|
#
|
30
|
-
def starting(
|
30
|
+
def starting(worker)
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
34
|
-
# Each time a
|
34
|
+
# Each time a worker takes a work unit, it calls this method before
|
35
35
|
# doing the work. In total, this method will be called as many times
|
36
36
|
# as there are work units. The listener instance that received the
|
37
|
-
# starting callback with the
|
37
|
+
# starting callback with the worker provided here is the same instance
|
38
38
|
# that receives this message.
|
39
39
|
#
|
40
40
|
# Because each work processes work units in a serial fashion, the
|
41
41
|
# listener will receive a finished_work message before another
|
42
42
|
# starting_work message.
|
43
43
|
#
|
44
|
-
def starting_work(
|
44
|
+
def starting_work(worker, work_unit)
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# Each time a
|
48
|
+
# Each time a worker finishes computing a result for a work unit,
|
49
49
|
# it calls this method before sending that result back to the server.
|
50
50
|
# In total, this method will be called as many times
|
51
51
|
# as there are work units. The listener instance that received the
|
52
|
-
# starting callback with the
|
52
|
+
# starting callback with the worker provided here is the same instance
|
53
53
|
# that receives this message.
|
54
54
|
#
|
55
55
|
# Because each work processes work units in a serial fashion, the
|
56
56
|
# listener will receive a starting_work message before another
|
57
57
|
# finished_work message.
|
58
58
|
#
|
59
|
-
def finished_work(
|
59
|
+
def finished_work(worker, work_unit, result)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module DeepTest
|
2
|
+
class Option
|
3
|
+
attr_reader :name, :default
|
4
|
+
|
5
|
+
def initialize(name, type, default)
|
6
|
+
@name, @type, @default = name, type, default
|
7
|
+
end
|
8
|
+
|
9
|
+
def from_command_line(command_line)
|
10
|
+
command_line =~ /--#{name} (\S+)(\s|$)/
|
11
|
+
@type.from_string($1) if $1
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_command_line(value)
|
15
|
+
"--#{name} #{@type.to_string(value)}" if value && value != default
|
16
|
+
end
|
17
|
+
|
18
|
+
module Hash
|
19
|
+
def self.to_string(hash)
|
20
|
+
pairs = []
|
21
|
+
hash.each do |key, value|
|
22
|
+
value = value.gsub(/ /,'%20') if (::String === value)
|
23
|
+
pairs << "#{key}:#{value.inspect}"
|
24
|
+
end
|
25
|
+
pairs.join(",")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.from_string(string)
|
29
|
+
hash = {}
|
30
|
+
string.split(/,/).each do |pair|
|
31
|
+
key, unevaled_value = pair.split(/:/)
|
32
|
+
value = eval(unevaled_value)
|
33
|
+
value = value.gsub(/%20/, " ") if ::String === value
|
34
|
+
hash[key.to_sym] = value
|
35
|
+
end
|
36
|
+
hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Integer
|
41
|
+
def self.to_string(i)
|
42
|
+
i.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.from_string(s)
|
46
|
+
s.to_i
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module String
|
51
|
+
def self.to_string(s)
|
52
|
+
s
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.from_string(s)
|
56
|
+
s
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|