Class: TTK::Testers::Master

Inherits:
Tester show all
Includes:
Concrete
Defined in:
lib/ttk/testers/Master.rb

Constant Summary

Constants inherited from Tester

Tester::TESTER_VERSION

Instance Attribute Summary

Attributes inherited from Tester

#config

Instance Method Summary collapse

Methods inherited from Tester

#abort, #requests, #run_strategy, #uri

Constructor Details

#initialize(service, name, sub_testers) ⇒ Master

Returns a new instance of Master.



14
15
16
17
# File 'lib/ttk/testers/Master.rb', line 14

def initialize(service, name, sub_testers)
  super(service, name)
  @sub_testers = sub_testers
end

Instance Method Details

#dynamic_select(&block) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/ttk/testers/Master.rb', line 45

def dynamic_select(&block)
  #FIXME: manage concurrency
  scores = self.sub_testers.map do |uri, sub_tester|
    sub_tester.dynamic_select(&block)
  end
  best = scores.max
  wrap(best.tester)
  best
end

#query_tester(query_node) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/ttk/testers/Master.rb', line 35

def query_tester(query_node)
  super
  sub_testers = self.sub_testers
  query_node.each do |sub_query_node|
    sub_tester = sub_testers[sub_query_node.uri]
    sub_tester.query_tester(sub_query_node) if sub_tester
  end
  nil
end

#select_tester(&block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ttk/testers/Master.rb', line 19

def select_tester(&block)
  query_node = super(&block)
  self.sub_testers.each do |uri, sub_tester|
    sub_query_node = sub_tester.select_tester(&block)
    unless sub_query_node.nil?
      if query_node.nil?
        query_node = QueryNode.new(@service.uri,
                                   @config[:tester_name],
                                   @config[:tester_type])
      end
      query_node << sub_query_node
    end
  end
  query_node
end

#sub_testersObject



55
56
57
# File 'lib/ttk/testers/Master.rb', line 55

def sub_testers
  @sub_testers.synchronize { @sub_testers.dup }
end