Class: DTR::Agent::Runner

Inherits:
ProcessRoot show all
Includes:
DRbUndumped, Service::Runner
Defined in:
lib/dtr/agent/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Service::Runner

#lookup_runner, #provide_runner

Methods included from Service::Rinda

#lookup, #lookup_ring, #start_service, #stop_service

Constructor Details

#initialize(name) ⇒ Runner

Returns a new instance of Runner.



23
24
25
26
# File 'lib/dtr/agent/runner.rb', line 23

def initialize(name)
  super
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/dtr/agent/runner.rb', line 21

def name
  @name
end

Instance Method Details

#provideObject



58
59
60
# File 'lib/dtr/agent/runner.rb', line 58

def provide
  provide_runner(self)
end

#run(test, result, &progress_block) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/dtr/agent/runner.rb', line 49

def run(test, result, &progress_block)
  DTR.debug {"running #{test}..."}
  Agent::TestCase.new(test, result, &progress_block).run
  DTR.debug {"done #{test}"}
ensure
  provide
  DTR.debug {"=> Runner provided"}
end

#startObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dtr/agent/runner.rb', line 28

def start
  #start service first, so that all logs can be sync with master process
  start_service

  ENV['DTR_RUNNER_NAME'] = name
  DTR.info "Start #{self} at #{DTR.root}, pid: #{Process.pid}"
  DTR.configuration.working_env.load_environment do
    provide
    DTR.info {"=> Runner provided"}
    while DTR.configuration.runners_should_be_working?
      sleep(1)
    end
  end
rescue
  DTR.error($!.message)
  DTR.error($!.backtrace.join("\n"))
ensure
  #make sure exit process for drb may cause this process hang on
  exit!(0)
end

#to_sObject



62
63
64
# File 'lib/dtr/agent/runner.rb', line 62

def to_s
  "Runner #{@name}"
end