Skip to content

Instantly share code, notes, and snippets.

@chessbyte
Last active May 21, 2020 18:18
Show Gist options
  • Save chessbyte/df6e4cb5aa459aa32cb0fc186823e19a to your computer and use it in GitHub Desktop.
Save chessbyte/df6e4cb5aa459aa32cb0fc186823e19a to your computer and use it in GitHub Desktop.
Automate Method Dispatch
diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/drb_remote_invoker.rb b/lib/miq_automation_engine/engine/miq_ae_engine/drb_remote_invoker.rb
index b6d6353..a049bed 100644
--- a/lib/miq_automation_engine/engine/miq_ae_engine/drb_remote_invoker.rb
+++ b/lib/miq_automation_engine/engine/miq_ae_engine/drb_remote_invoker.rb
@@ -9,6 +9,7 @@ module MiqAeEngine
end
def with_server(inputs, bodies, method_name, script_info)
+puts "DrbRemoteInvoker.with_server(inputs=#{inputs.inspect}, bodies=#{bodies.inspect}, method_name=#{method_name.inspect}, script_info=#{script_info.inspect})"
setup if num_methods.zero?
self.num_methods += 1
svc = MiqAeMethodService::MiqAeService.new(@workspace, inputs)
@@ -25,6 +26,7 @@ module MiqAeEngine
# Previously we had used DRb.front but that gets compromised when multiple
# DRb servers are running in the same process.
def self.workspace
+puts "DrbRemoteInvoker.workspace called"
if Thread.current['DRb'] && Thread.current['DRb']['server']
Thread.current['DRb']['server'].front.workspace
end
@@ -42,6 +44,7 @@ module MiqAeEngine
require 'tmpdir'
Dir::Tmpname.create("automation_engine", nil) do |path|
self.drb_server = DRb.start_service("drbunix://#{path}", drb_front, :idconv => global_id_conv)
+puts "DrbRemoteInvoker.setup - drb_server=#{self.drb_server}"
FileUtils.chmod(0o700, path)
end
end
diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb
index 7fe3c00..1f592ca 100644
--- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb
+++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb
@@ -228,6 +228,7 @@ module MiqAeEngine
end
rc = status.exitstatus
msg = "Method exited with rc=#{verbose_rc(rc)}"
+puts msg
method_pid = nil
threads = []
rescue StandardError => err
diff --git a/spec/miq_ae_method_dispatch_spec.rb b/spec/miq_ae_method_dispatch_spec.rb
index 9705cef..9be75dc 100644
--- a/spec/miq_ae_method_dispatch_spec.rb
+++ b/spec/miq_ae_method_dispatch_spec.rb
@@ -91,17 +91,17 @@ describe "MiqAeMethodDispatch" do
'ae_instances' => ae_instances))
end
- it "long running method", :skip => "Fails sporadically because 2 seconds is not long enough" do
- File.delete(@pidfile) if File.exist?(@pidfile)
- setup_model(rip_van_winkle_script)
- # Set the timeout to 2 seconds so we can terminate
- # unresponsive method
- send_ae_request_via_queue(@automate_args, 2)
- status, _msg, _ws = deliver_ae_request_from_queue
- expect(status).to eql 'timeout'
- pid = File.read(@pidfile).to_i
- expect { Process.getpgid(pid) }.to raise_error(Errno::ESRCH)
- end
+ # it "long running method", :skip => "Fails sporadically because 2 seconds is not long enough" do
+ # File.delete(@pidfile) if File.exist?(@pidfile)
+ # setup_model(rip_van_winkle_script)
+ # # Set the timeout to 2 seconds so we can terminate
+ # # unresponsive method
+ # send_ae_request_via_queue(@automate_args, 2)
+ # status, _msg, _ws = deliver_ae_request_from_queue
+ # expect(status).to eql 'timeout'
+ # pid = File.read(@pidfile).to_i
+ # expect { Process.getpgid(pid) }.to raise_error(Errno::ESRCH)
+ # end
it "run method that writes to stderr and stdout" do
setup_model(std_script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment