Class: TTK::Testers::Tester
- Includes:
- Abstract, DRb::DRbUndumped
- Defined in:
- lib/ttk/testers/Tester.rb,
lib/ttk/testers/tester/score.rb,
lib/ttk/testers/tester/config.rb,
lib/ttk/testers/tester/notifier.rb,
lib/ttk/testers/tester/query_node.rb,
lib/ttk/testers/tester/running_task.rb,
lib/ttk/testers/tester/remote_status.rb
Defined Under Namespace
Modules: Notification Classes: Config, Notifier, QueryNode, RemoteStatus, RunningTask, Score
Constant Summary collapse
- TESTER_VERSION =
Version.new(0, 1, '$Rev: 557 $'.gsub!(/\D/, '').to_i)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#abort(test_id) ⇒ Object
Abort a running test.
-
#dynamic_select(&block) ⇒ Object
Dynamically select a tester.
-
#initialize(service, name) ⇒ Tester
constructor
module Notification.
-
#query_tester(query_node) ⇒ Object
Run the query on this tester.
-
#requests ⇒ Object
List all requests available on this tester.
-
#run_strategy(test, symtbl) ⇒ Object
Load a strategy using the loader in the symtbl and run it.
-
#select_tester(&block) ⇒ Object
Return a query node if the block return true.
- #uri ⇒ Object
Constructor Details
#initialize(service, name) ⇒ Tester
module Notification
31 32 33 34 35 36 37 |
# File 'lib/ttk/testers/Tester.rb', line 31 def initialize(service, name) @service = service initialize_config(name) @notifier = Notifier.new @notifier.add_observer(@service) @tasks = RunningTask.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
39 40 41 |
# File 'lib/ttk/testers/Tester.rb', line 39 def config @config end |
Instance Method Details
#abort(test_id) ⇒ Object
Abort a running test. The identifier of a running test is the hash key of the test: test.hash.
91 92 93 94 95 |
# File 'lib/ttk/testers/Tester.rb', line 91 def abort(test_id) Thread.new do @tasks.abort(test_id) end end |
#dynamic_select(&block) ⇒ Object
Dynamically select a tester.
84 85 86 87 |
# File 'lib/ttk/testers/Tester.rb', line 84 def dynamic_select(&block) score = block[@service.uri, { :nb_jobs => @tasks.size } ] Score.new(score, (score <= 0) ? nil : self) end |
#query_tester(query_node) ⇒ Object
Run the query on this tester.
55 56 57 58 |
# File 'lib/ttk/testers/Tester.rb', line 55 def query_tester(query_node) query_node.run(self) nil end |
#requests ⇒ Object
List all requests available on this tester.
76 77 78 79 80 81 |
# File 'lib/ttk/testers/Tester.rb', line 76 def requests o = Tester.superclass.new public_methods.select do |meth| not (o.respond_to?(meth) or meth.to_s =~ /^_/) end end |
#run_strategy(test, symtbl) ⇒ Object
Load a strategy using the loader in the symtbl and run it.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ttk/testers/Tester.rb', line 61 def run_strategy(test, symtbl) @notifier.changed @notifier.notify_observers(Notification::START_STRATEGY, test) saver = Filters::Saver.new log = symtbl[:log_factory].create(saver) test.symtbl = symtbl[:symtbl_class].new(symtbl) prologue_test(test, log) status = run_impl_test(test, log) epilogue_test(test, log) @notifier.changed @notifier.notify_observers(Notification::STOP_STRATEGY, test, status) RemoteStatus.new(status, saver) end |
#select_tester(&block) ⇒ Object
Return a query node if the block return true.
46 47 48 49 50 51 52 |
# File 'lib/ttk/testers/Tester.rb', line 46 def select_tester(&block) if block[@service.uri, @config] QueryNode.new(@service.uri, @config[:tester_name], @config[:tester_type]) end end |
#uri ⇒ Object
41 42 43 |
# File 'lib/ttk/testers/Tester.rb', line 41 def uri @service.uri end |