From 740ee6e447fdc5969433c46246f79214e652f46d Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 11 Jun 2022 12:19:52 +0100 Subject: [PATCH 1/4] Add timeout to remote debuggee waiting logic --- test/support/utils.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/support/utils.rb b/test/support/utils.rb index b36b6d2fa..cf5a42650 100644 --- a/test/support/utils.rb +++ b/test/support/utils.rb @@ -306,8 +306,10 @@ def manual_debug_code(program) write_temp_file(strip_line_num(program)) remote_info = setup_unix_domain_socket_remote_debuggee - while !File.exist?(remote_info.sock_path) - sleep 0.1 + Timeout.timeout(TIMEOUT_SEC) do + while !File.exist?(remote_info.sock_path) + sleep 0.1 + end end DEBUGGER__::Client.new([socket_path]).connect @@ -335,7 +337,11 @@ def setup_unix_domain_socket_remote_debuggee sock_path = DEBUGGER__.create_unix_domain_socket_name + "-#{$ruby_debug_test_num += 1}" remote_info = setup_remote_debuggee("#{RDBG_EXECUTABLE} -O --sock-path=#{sock_path} #{temp_file_path}") remote_info.sock_path = sock_path - sleep 0.1 while !File.exist?(sock_path) && Process.kill(0, remote_info.pid) + + Timeout.timeout(TIMEOUT_SEC) do + sleep 0.1 while !File.exist?(sock_path) && Process.kill(0, remote_info.pid) + end + remote_info end From 3cb47b1ea4b07bc7e76a400b042ad1ced1df5cea Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 11 Jun 2022 12:38:22 +0100 Subject: [PATCH 2/4] Cleanup targets may be nil depends on the failure --- test/support/protocol_utils.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/support/protocol_utils.rb b/test/support/protocol_utils.rb index 44bb8bd37..5a5c77ff6 100644 --- a/test/support/protocol_utils.rb +++ b/test/support/protocol_utils.rb @@ -291,11 +291,11 @@ def execute_dap_scenario scenario flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC ensure - @reader_thread.kill - @sock.close if @sock - @remote_info.reader_thread.kill - @remote_info.r.close - @remote_info.w.close + @reader_thread&.kill + @sock&.close + @remote_info&.reader_thread&.kill + @remote_info&.r&.close + @remote_info&.w&.close end def execute_cdp_scenario scenario @@ -316,11 +316,11 @@ def execute_cdp_scenario scenario flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC ensure - @reader_thread.kill - @web_sock.cleanup if @web_sock - @remote_info.reader_thread.kill - @remote_info.r.close - @remote_info.w.close + @reader_thread&.kill + @web_sock&.cleanup + @remote_info&.reader_thread&.kill + @remote_info&.r&.close + @remote_info&.w&.close end def req_disconnect From 73d9a9e30a438099b1d3894b177362abd6fc6f4a Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 11 Jun 2022 17:58:05 +0100 Subject: [PATCH 3/4] Rename WebSocketClient#cleanup to #close because it's all it does --- test/support/cdp_utils.rb | 2 +- test/support/protocol_utils.rb | 10 +++++----- test/support/test_case.rb | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/support/cdp_utils.rb b/test/support/cdp_utils.rb index d851cea75..31d2fd1c3 100644 --- a/test/support/cdp_utils.rb +++ b/test/support/cdp_utils.rb @@ -157,7 +157,7 @@ def exchange_cdp_message msgs flunk create_protocol_message"TIMEOUT ERROR (#{TIMEOUT_SEC} sec) while waiting for the following response.\n#{JSON.pretty_generate target_msg}" ensure @reader_thread.kill - @web_sock.cleanup + @web_sock.close @remote_info.reader_thread.kill @remote_info.r.close @remote_info.w.close diff --git a/test/support/protocol_utils.rb b/test/support/protocol_utils.rb index 5a5c77ff6..f8b6a3b72 100644 --- a/test/support/protocol_utils.rb +++ b/test/support/protocol_utils.rb @@ -146,7 +146,7 @@ def req_terminate_debuggee send_cdp_request 'Runtime.terminateExecution' end - cleanup_reader + close_reader end def assert_reattach @@ -317,7 +317,7 @@ def execute_cdp_scenario scenario flunk create_protocol_message "Expected the debuggee program to finish" unless wait_pid @remote_info.pid, TIMEOUT_SEC ensure @reader_thread&.kill - @web_sock&.cleanup + @web_sock&.close @remote_info&.reader_thread&.kill @remote_info&.r&.close @remote_info&.w&.close @@ -333,7 +333,7 @@ def req_disconnect @web_sock.send_close_connection end - cleanup_reader + close_reader end def req_set_breakpoints_on_dap @@ -360,14 +360,14 @@ def req_set_breakpoints_on_dap } end - def cleanup_reader + def close_reader @reader_thread.raise Detach case ENV['RUBY_DEBUG_TEST_UI'] when 'vscode' @sock.close when 'chrome' - @web_sock.cleanup + @web_sock.close end end diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 524b06b96..0f08b677c 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -249,7 +249,7 @@ def send_close_connection @sock.print frame.pack 'c*' end - def cleanup + def close @sock.close end end @@ -361,7 +361,7 @@ def cleanup method: "Debugger.setBlackboxPatterns", params: { patterns: [ - + ] } }, @@ -378,7 +378,7 @@ def initialize @result = [] @keys = [] end - + def parse objs objs.each{|k, v| parse_ k, v @@ -386,7 +386,7 @@ def parse objs } @result end - + def parse_ k, v @keys << k case v From ab55aafe14cebe12cb6c2945f0eba8faf57cdd77 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 12 Jun 2022 00:25:39 +0100 Subject: [PATCH 4/4] Add timeout to workflows The default timeout is 6 hours, which is unnecessarily long. We should stop tests if it doesn't finish in 10~15 mins to see what happens. --- .github/workflows/protocol.yml | 1 + .github/workflows/ruby.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/protocol.yml b/.github/workflows/protocol.yml index 03ca77330..5e2ca2ea2 100644 --- a/.github/workflows/protocol.yml +++ b/.github/workflows/protocol.yml @@ -17,6 +17,7 @@ jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: ruby-version: ['2.6', '2.7', '3.0', '3.1', 'head', 'debug'] diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6cfd553d1..a2db74e1c 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,6 +17,7 @@ jobs: test: runs-on: ubuntu-latest + timeout-minutes: 15 strategy: matrix: ruby-version: ['2.6', '2.7', '3.0', '3.1', 'head', 'debug']