From 7e5bbf5dc904e10ae1f6638fc4ebc4a72053fa5d Mon Sep 17 00:00:00 2001 From: "renars.eihe" Date: Tue, 28 Jun 2022 08:59:31 +0300 Subject: [PATCH 1/3] config_caps + control_flow update --- lib/core/device_handler.rb | 2 ++ lib/core/types_control_flow.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/core/device_handler.rb b/lib/core/device_handler.rb index e9e360c4..df116e55 100644 --- a/lib/core/device_handler.rb +++ b/lib/core/device_handler.rb @@ -84,6 +84,8 @@ def create_single_device(case_role, role_app, case_caps) config_caps = convert_yaml(config_device["capabilities"]) log_info("Role '#{case_role}': Adding capabilities from config: #{config_caps}") udid = config_caps["udid"] if config_caps.key?("udid") + @driver_port = config_caps["systemPort"].to_i if config_caps.key?("systemPort") + @server_port = config_caps["wdaLocalPort"].to_i if config_caps.key?("wdaLocalPort") end if !case_caps.empty? log_info("Role '#{case_role}': Adding capabilities from case: #{case_caps}") diff --git a/lib/core/types_control_flow.rb b/lib/core/types_control_flow.rb index 0e59e486..c9e51d64 100644 --- a/lib/core/types_control_flow.rb +++ b/lib/core/types_control_flow.rb @@ -2,13 +2,13 @@ module ControlFlowTypes # execute a case def case_handler(action, _case) - run(action["Value"], get_parent_params(action)) - log_info("Finished case #{action["Value"]}, resuming parent case #{_case}") + run(convert_value(action["Value"]), get_parent_params(action)) + log_info("Finished case #{convert_value(action["Value"])}, resuming parent case #{_case}") end # execute a case that can be run in parallel with another case def parallel_case_handler(action, case_threads, max_parallel_cases) - case_name = action["Value"] + case_name = convert_value(action["Value"]) unless case_threads.empty? alive_threads = case_threads.keys.each.map {|t| t.alive?}.length if max_parallel_cases <= alive_threads From 77a580261051ad3b23477d47ce87e7a323b1d5e8 Mon Sep 17 00:00:00 2001 From: "renars.eihe" Date: Tue, 28 Jun 2022 13:48:04 +0300 Subject: [PATCH 2/3] driver_port added to case_caps --- lib/core/device_handler.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/device_handler.rb b/lib/core/device_handler.rb index df116e55..c2ef64f6 100644 --- a/lib/core/device_handler.rb +++ b/lib/core/device_handler.rb @@ -5,7 +5,7 @@ class DeviceHandler def initialize(case_role_sets) @timeout = $config["Timeout"] ? $config["Timeout"] : 10 - @server_port = 4727 + @server_port = ENV.has_key?('serverPort') ? ENV['serverPort'].to_i : 4727 @driver_port = 8205 @devices = {} create_devices(case_role_sets) @@ -85,11 +85,13 @@ def create_single_device(case_role, role_app, case_caps) log_info("Role '#{case_role}': Adding capabilities from config: #{config_caps}") udid = config_caps["udid"] if config_caps.key?("udid") @driver_port = config_caps["systemPort"].to_i if config_caps.key?("systemPort") - @server_port = config_caps["wdaLocalPort"].to_i if config_caps.key?("wdaLocalPort") + @driver_port = config_caps["wdaLocalPort"].to_i if config_caps.key?("wdaLocalPort") end if !case_caps.empty? log_info("Role '#{case_role}': Adding capabilities from case: #{case_caps}") udid = case_caps["udid"] if case_caps.key?("udid") + @driver_port = case_caps["systemPort"].to_i if case_caps.key?("systemPort") + @driver_port = case_caps["wdaLocalPort"].to_i if case_caps.key?("wdaLocalPort") end # Create virtual device for the role From ead60cfa2aa37fddb6bbcd6c65b0b99d87cd0817 Mon Sep 17 00:00:00 2001 From: "renars.eihe" Date: Tue, 28 Jun 2022 16:01:52 +0300 Subject: [PATCH 3/3] server_port fix --- lib/core/device_handler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/device_handler.rb b/lib/core/device_handler.rb index c2ef64f6..ad8d9143 100644 --- a/lib/core/device_handler.rb +++ b/lib/core/device_handler.rb @@ -5,7 +5,7 @@ class DeviceHandler def initialize(case_role_sets) @timeout = $config["Timeout"] ? $config["Timeout"] : 10 - @server_port = ENV.has_key?('serverPort') ? ENV['serverPort'].to_i : 4727 + @server_port = 4727 @driver_port = 8205 @devices = {} create_devices(case_role_sets) @@ -79,6 +79,7 @@ def create_single_device(case_role, role_app, case_caps) url, udid, options = setup_path_to_device(config_device) # Get capabilities from config and case, and replace existing udid if it is provided + @server_port = convert_value(config_device["serverPort"]).to_i if config_device.key?("serverPort") config_caps = {} if config_device.key?("capabilities") && !config_device["capabilities"].nil? config_caps = convert_yaml(config_device["capabilities"])