Class: DeepTest::Distributed::RemoteDeployment

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

Instance Method Summary collapse

Constructor Details

#initialize(options, landing_fleet, failover_deployment) ⇒ RemoteDeployment

Returns a new instance of RemoteDeployment.



4
5
6
7
8
# File 'lib/deep_test/distributed/remote_deployment.rb', line 4

def initialize(options, landing_fleet, failover_deployment)
  @failover_deployment = failover_deployment
  @options = options
  @landing_fleet = landing_fleet
end

Instance Method Details

#deploy_agentsObject



36
37
38
39
40
41
42
43
# File 'lib/deep_test/distributed/remote_deployment.rb', line 36

def deploy_agents
  DeepTest.logger.debug { "RemoteDeployment deploying agents with #{@landing_fleet}" }
  @landing_fleet.deploy_agents
rescue => e
  raise if failed_over?
  fail_over("deploy_agents", e)
  retry
end

#fail_over(method, exception) ⇒ Object



45
46
47
48
49
# File 'lib/deep_test/distributed/remote_deployment.rb', line 45

def fail_over(method, exception)
  DeepTest.logger.debug { "RemoteDeployment failing over on #{method}." }
  @options.ui_instance.distributed_failover_to_local(method, exception)
  @landing_fleet = @failover_deployment
end

#failed_over?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/deep_test/distributed/remote_deployment.rb', line 51

def failed_over?
  @landing_fleet == @failover_deployment
end

#load_files(filelist) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/deep_test/distributed/remote_deployment.rb', line 10

def load_files(filelist)
  # load one file before calling listeners to make sure environment has
  # been initialized as expected
  #
  load filelist.first
  @options.new_listener_list.before_sync

  t = Thread.new do
    @landing_fleet.push_code(@options)
    @landing_fleet.establish_beachhead(@options)
    @landing_fleet.load_files filelist
  end

  filelist[1..-1].each {|f| load f}

  begin
    t.join
  rescue => e
    # The failover here doesn't invoke load_files on the failover_deployment
    # because it will be a LocalDeployment, which forks from the current 
    # process.  The fact that we depend in this here is damp...
    #
    fail_over("load_files", e)
  end
end