Class: DeepTest::LocalDeployment

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/local_deployment.rb

Direct Known Subclasses

Distributed::Beachhead

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, agent_class = DeepTest::Agent) ⇒ LocalDeployment

Returns a new instance of LocalDeployment.



5
6
7
8
# File 'lib/deep_test/local_deployment.rb', line 5

def initialize(options, agent_class = DeepTest::Agent)
  @options = options
  @agent_class = agent_class
end

Instance Attribute Details

#warlockObject (readonly)

Returns the value of attribute warlock.



3
4
5
# File 'lib/deep_test/local_deployment.rb', line 3

def warlock
  @warlock
end

Instance Method Details

#deploy_agentsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/deep_test/local_deployment.rb', line 18

def deploy_agents
  DeepTest.logger.debug { "Deploying #{number_of_agents} #{@agent_class}s" }
  wait_for_connect_threads = []
  each_agent do |agent_num|
    stream_from_child_process, stream_to_parent_process = IO.pipe
    warlock.start "agent #{agent_num}", @agent_class.new(agent_num, @options, @options.new_listener_list), 
                  stream_from_child_process, stream_to_parent_process
    wait_for_connect_threads << Thread.new do
      stream_to_parent_process.close
      message = stream_from_child_process.read
      stream_from_child_process.close
      raise "Agent was not able to connect: #{message}" unless message == "Connected\n"
    end
  end        

  wait_for_connect_threads.each { |t| t.join }
end

#load_files(files) ⇒ Object



14
15
16
# File 'lib/deep_test/local_deployment.rb', line 14

def load_files(files)
  files.each {|f| load f}
end

#number_of_agentsObject



36
37
38
# File 'lib/deep_test/local_deployment.rb', line 36

def number_of_agents
  @options.number_of_agents
end