Merge commit '8e342a1378e9da0a8e6340411f42dbe66c39a5ed' into candidate/wrapper-71-final
This commit is contained in:
commit
df491f2e67
11 files changed
+874
-8
No files matched your search
@@ -446,6 +446,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: Install wrapper + test deps (the stock client is in the dev extra)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
@@ -537,6 +540,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
# The A/A of the three A/B oracles (page, network, host) runs on the first seeds of the candidate set on a pull request, and on ALL of them when the pull request
|
||||
# changes a file of that oracle (scripts/ci_ab_pr_seeds.py holds the lists). The checkout is shallow, so the script fetches the base commit and lists the files that
|
||||
# differ from it (`git diff --name-only <base> HEAD`: HEAD is the merge commit, so this is the pull request's own change); the tests read the variables it prints.
|
||||
@@ -761,6 +767,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
@@ -984,6 +993,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
@@ -1254,6 +1266,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: How many seeds the A/A of each oracle visits (all of them when the pull request touches the oracle)
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
@@ -1488,6 +1503,9 @@ jobs:
|
||||
New-ItemProperty -Force -Path $key -Name DumpCount -PropertyType DWord -Value 3 | Out-Null
|
||||
Get-ItemProperty -Path $key | Format-List DumpFolder, DumpType, DumpCount
|
||||
Get-ItemProperty -Path $wer | Format-List Disabled, DontShowUI
|
||||
# The one variable tests/conftest.py reads (tests/_wer_error_mode.py): every pytest process of the later steps clears SEM_NOGPFAULTERRORBOX of its error mode, which the
|
||||
# runner gives it and which would keep a crashing worker from ever reaching the LocalDumps above, and says so in dumps/error-mode.log.
|
||||
"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
{"id": "wrapper.e2e.stock_twin", "giro": "G2", "os": ["linux", "windows"], "min_tests": 20, "exact": true, "tests": ["tests/test_a_drag_from_the_top_into_a_frame_of_another_site_e2e.py", "tests/test_a_select_dropdown_opens_at_its_element_e2e.py", "tests/test_a_tooltip_opens_at_the_pointer_e2e.py", "tests/test_intersection_and_lazy_loading_in_a_frame_of_another_site_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The twins of the browser's own popups and of the frame's reads. Two references, one browser at a time, the reference first and ours second, and the verdict is 'the same as the reference' (tests/_stock_twin.py, tests/_retail_reference.py). The select dropdown (4 scales) and the tooltip (4 scales) are measured from chrome scope, against RETAIL Firefox 159 driven by Marionette alone, headed (the leg sets INVPW_RETAIL_FIREFOX to its firefox.exe). The real drag from the top into a frame of another site (4 scales), what the IntersectionObserver of a scrolled frame of another site reads (8 steps, 4 scales) and when a lazy frame is requested (4 distances, 4 scales) are measured against Playwright's own Firefox (stock_firefox), headed, driven by the stock Playwright client. 20 = 4 + 4 + 4 + 4 + 4. Each record keeps the page's and the chrome's devicePixelRatio and the real scale of the screen. The files are in no whole-suite row: the references are installed only for this row's legs.", "stock_firefox": true},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
|
||||
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 30, "exact": true, "tests": ["tests/test_the_page_bytes_reference_compares_decoded_pixels.py"], "marker": "unit", "needs_root": false, "note": "The helpers of wrapper.e2e.compositing on known inputs, no browser: the PNG compared on decoded pixels (another deBG chunk and compression are the same, one pixel is not, every scanline filter), the comparison with a reference (changed, missing and extra keys named, the entry to record), the type of an engine process, an engine process known by its executable and not by the name it gives itself (Linux), and the CPU of a window, and the shape of the committed Windows reference, and the box cut out of a screenshot (its pixels, a box outside the picture refused, written as a PNG and read back, two boxes told apart by a pixel that is named, the pixels that are not grey)."},
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4057, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_windows_job_keeps_a_dump_of_a_crashing_python.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_reportLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4061, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_windows_job_keeps_a_dump_of_a_crashing_python.py", "tests/test_every_wire_method_is_served_or_refused.py", "tests/test_expose_binding_refusal.py", "tests/test_fakeweb_p4_reLine truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 4116, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_windows_job_keeps_a_dump_of_a_crashing_python.py", "tests/test_every_wire_method_isLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 4128, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_generation_of_the_security_state_keeps_its_evidence.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_file_chooser_is_never_dropped_in_silence.py", "tests/test_a_frame_tap_needs_a_context_with_touch.py", "tests/test_a_gil_free_thread_dump_kills_a_busy_process_and_the_stack_watchdog_does_not.py", "tests/test_a_handle_action_walks_like_a_selector_action.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_gives_the_core_its_engine_for_the_security_state.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_read_whose_probe_ran_out_is_the_callers_timeout.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page.py", "tests/test_a_screenshot_sends_its_scale_to_the_engine.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_streamed_upload_is_staged_in_the_session.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_test_that_is_not_e2e_never_leaves_the_machine.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_ab_host.py", "tests/test_ab_host_aa_stable.py", "tests/test_ab_network.py", "tests/test_ab_network_turn_credential.py", "tests/test_ab_network_turn_deallocation.py", "tests/test_ab_network_webrtc_evidence.py", "tests/test_ab_oracle.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_element_handle_serves_every_method_of_the_client.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_host_gate_ab.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_lab_security_state.py", "tests/test_ci_linux_legs_read_no_mirror.py", "tests/test_ci_poison_host.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_suite_run.py", "tests/test_ci_verdict.py", "tests/test_ci_windows_temp_is_on_d.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_ci_workflows_set_the_security_state.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_action_is_pinned_by_commit_sha.py", "tests/test_every_argument_reaches_the_page_as_playwright_sends_it.py", "tests/test_every_held_request_of_the_journey_starts_after_the_load.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_pytest_process_clears_the_gp_fault_error_box_on_windows.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_every_Line truncated
|
||||
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode).", "core_dumps": "invpw-cores"},
|
||||
{"id": "wrapper.e2e.suite.linux.1", "giro": "G2", "os": ["linux"], "min_tests": 447, "exact": true, "tests": ["tests/test_a_closed_browser_leaves_the_others_alone_e2e.py", "tests/test_a_context_that_ends_leaves_no_process_e2e.py", "tests/test_a_cors_preflight_is_not_a_request_of_the_page_e2e.py", "tests/test_a_declared_webgl_extension_survives_its_use_e2e.py", "tests/test_a_granted_permission_is_the_one_the_page_asks_for_e2e.py", "tests/test_a_held_ice_port_blinds_the_loopback_checks_e2e.py", "tests/test_a_launch_without_a_session_gets_one_e2e.py", "tests/test_a_left_documents_body_is_evicted_e2e.py", "tests/test_a_mouse_click_makes_one_mousemove_on_its_point_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py", "tests/test_a_screenshot_honours_its_scale_e2e.py", "tests/test_a_screenshot_refuses_what_would_touch_the_page_e2e.py", "tests/test_a_served_browser_answers_a_plain_client_e2e.py", "tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_turn_name_over_tcp_goes_through_the_proxy_of_the_context_e2e.py", "tests/test_accept_language_on_the_wire_e2e.py", "tests/test_browser_output_is_drained.py", "tests/test_click_rhythm.py", "tests/test_closing_one_of_four_browsers_does_not_hold_the_loop_e2e.py", "tests/test_control_a_selects_all_in_a_field_e2e.py", "tests/test_cross_origin_iframe.py", "tests/test_declared_host_network_e2e.py", "tests/test_detectors_e2e.py", "tests/test_e2e.py", "tests/test_element_handle_actions.py", "tests/test_element_screenshot_e2e.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_file_chooser.py", "tests/test_fingerprint_surface.py", "tests/test_fission_frames_history_and_processes_e2e.py", "tests/test_fission_frames_workers_storage_and_special_frames_e2e.py", "tests/test_frames_outlive_the_back_forward_cache_e2e.py", "tests/test_goto_networkidle_after_spa_e2e.py", "tests/test_goto_script_redirect_e2e.py", "tests/test_hidden_display_linux.py", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_the_ice_name_of_a_context_goes_by_the_proxy_of_that_context", "tests/test_ignore_https_errors_e2e.py", "tests/test_injected_node_surface.py", "tests/test_juggler_connection.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_navigation_across_processes_e2e.py", "tests/test_navigation_response.py", "tests/test_networkidle_reaches_the_client_e2e.py", "tests/test_oop_frame_element.py", "tests/test_oop_frame_geometry.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pointer_position.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_realness_behind_a_declared_exit_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_route_header_order_e2e.py", "tests/test_same_document_goto_e2e.py", "tests/test_screencast.py", "tests/test_screencast_stop_e2e.py", "tests/test_screenshot_looks_where_you_are.py", "tests/test_security_state_engine_e2e.py", "tests/test_service_worker.py", "tests/test_service_worker_controller_e2e.py", "tests/test_set_offline_e2e.py", "tests/test_shadow_trusted_input.py", "tests/test_strict_and_force.py", "tests/test_the_callers_code_is_not_counted_e2e.py", "tests/test_the_device_enumeration_takes_the_declared_time_e2e.py", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_a_launch_scans_no_process_of_the_machine", "tests/test_the_engine_is_born_in_the_job_e2e.py::test_after_close_no_process_of_the_session_is_left", "tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_trial_does_not_act.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_ua_widget_not_selectable.py", "tests/test_voices_e2e.py", "tests/test_wait_for_function.py", "tests/test_webgl_draws_on_the_engine_s_own_gl_e2e.py", "tests/test_webgl_noise_active.py", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_not_blocked_behind_tcp_only_socks", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_throuLine truncated
|
||||
{"id": "wrapper.e2e.suite.linux.2", "giro": "G2", "os": ["linux"], "min_tests": 414, "exact": true, "tests": ["tests/test_a_click_waits_for_the_navigation_it_plans_e2e.py", "tests/test_a_context_init_script_runs_once_e2e.py", "tests/test_a_drag_keeps_its_buttons_pressed_e2e.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_goto_to_a_response_with_no_document_ends_e2e.py", "tests/test_a_keepalive_request_reaches_the_client_e2e.py", "tests/test_a_latin_letter_on_a_cyrillic_persona_e2e.py", "tests/test_a_page_cannot_probe_the_juggler_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_pointer_event_is_handled_before_the_call_returns_e2e.py", "tests/test_a_request_says_what_it_is_e2e.py", "tests/test_a_worker_comes_back_with_its_page_from_the_cache_e2e.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_isolated_page_and_the_next_e2e.py", "tests/test_bypass_csp_e2e.py", "tests/test_caller_world_handles_e2e.py", "tests/test_canvas_reads_as_drawn.py", "tests/test_canvas_render_stealth.py", "tests/test_context_locale_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_download_is_intercepted_e2e.py", "tests/test_drag_motion.py", "tests/test_expose_binding_e2e.py", "tests/test_fakeweb_p4_e2e.py", "tests/test_fingerprint_consistency.py", "tests/test_fission_frames_dialogs_downloads_popups_e2e.py", "tests/test_fission_frames_route_and_bindings_e2e.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fission_iframe_crash_e2e.py", "tests/test_fission_strategy1_bench.py", "tests/test_goto_to_the_same_url_e2e.py", "tests/test_http3_through_the_proxy_e2e.py", "tests/test_input_is_born_before_the_page_sees_it_e2e.py", "tests/test_juggler_actions.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py::test_a_javascript_that_THROWS_arrives_as_an_error_not_as_None", "tests/test_juggler_injected.py::test_actionability_DISTINGUISHES_instead_of_always_saying_yes", "tests/test_juggler_injected.py::test_reads_that_make_no_sense_are_REJECTED", "tests/test_juggler_injected.py::test_states_DISCRIMINATE_instead_of_always_saying_true", "tests/test_juggler_injected.py::test_the_DOM_READING_group", "tests/test_juggler_injected.py::test_the_selector_engines_respond", "tests/test_juggler_injected.py::test_the_text_reads", "tests/test_juggler_lifecycle_e2e.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_long_session_e2e.py", "tests/test_mouse.py", "tests/test_mouse_events_keep_their_values_e2e.py", "tests/test_new_page_defaults.py", "tests/test_popup_destinations_e2e.py", "tests/test_popup_pages.py", "tests/test_proxy_http_auth_e2e.py", "tests/test_proxy_reaches_the_browser.py", "tests/test_proxy_socks_auth_e2e.py", "tests/test_requestless_navigation.py", "tests/test_route_abort_code.py", "tests/test_route_e2e.py", "tests/test_route_post_data_e2e.py", "tests/test_route_sends_a_navigation_elsewhere_e2e.py", "tests/test_route_superseded_e2e.py", "tests/test_same_document_navigation.py", "tests/test_screenshot_of_text_returns_linux_e2e.py", "tests/test_scroll_into_view.py", "tests/test_scroll_only_if_needed_e2e.py", "tests/test_service_workers_blocked.py", "tests/test_set_input_files_payloads.py", "tests/test_software_compositing_is_declared_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_the_callers_code_runs_once_e2e.py", "tests/test_the_close_returns_when_the_browser_has_exited_e2e.py", "tests/test_the_favicon_stays_out_of_sight_e2e.py", "tests/test_the_font_list_is_the_bundle_e2e.py", "tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py", "tests/test_the_scheme_is_the_personas_e2e.py", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_typing_a_character_without_a_key_e2e.py", "tests/test_wait_for_timeout.py", "tests/test_web_fonts_of_closed_contexts_e2e.py"], "marker": "e2e", "needs_root": false, "windows_twin": "wrapper.e2e.suite.windows.2", "note": "Part 2 of the whole e2e suite of the wrapper (every test that opens the browser: what e2e.yml runs on the published engine), on the engine under test, as two passes through scripts/ci_suite_run.py (4 browsers at once, then the wall_clock tests alone; no rerun). The files of the 2 rows of linux are the files of tests/ that tests/test_the_e2e_suite_is_accounted_for.py holds one by one: a file whole when every test of it is here, else its tests by name. Partition from the junits of runs 44942540063 and 44985244053, test time balanced (about 564 s of estimated wall time, 4 browsers). A new file is added by hand to a row of each system and the minimum of the row goes up by hand. Left out of every row, with the reason in the accounting test: the files and tests of wrapLine truncated
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
"""The stack watchdog of the e2e tests: a Python thread that writes the stack of every thread of the process, holding the GIL.
|
||||
|
||||
``tests/conftest.py`` arms it for each e2e test and cancels it in the teardown. Once the threshold of a test is passed, and then every period until the
|
||||
test ends, it appends one dump to the file it was given: ``Timeout (h:mm:ss)!`` (the time since the arming) and then, for every thread, ``Thread 0x... (most
|
||||
recent call first):`` and its frames as `` File "...", line N in name``. Two identical dumps mean a stuck test, two different ones a slow test.
|
||||
|
||||
Why a Python thread and not ``faulthandler.dump_traceback_later``: that watchdog is a C thread, and it copies the frames of every thread WITHOUT the GIL
|
||||
(``_Py_DumpTracebackThreads``, which CPython documents as "for debug purpose only ... after a segmentation fault, at fatal error") while the other threads
|
||||
keep running and keep changing their frames. On Windows two full dumps of a pytest worker show it dead inside ``dump_frame`` of ``faulthandler_thread``,
|
||||
reading a frame another thread was freeing. This thread takes ``sys._current_frames()`` with the GIL held, so a frame it reads cannot change under it.
|
||||
|
||||
One thread per process, started by the first ``arm`` and reused by every later test. It writes nothing to stdout or stderr. After ``cancel`` returns, nothing
|
||||
more is written for that test: the dump is written under the lock that ``cancel`` takes.
|
||||
|
||||
Known limit: a thread that holds the GIL and never releases it (a C call that does not let go) keeps this thread from running, so it cannot write. That case
|
||||
is pytest's ``faulthandler.enable()``, which writes only when the process dies. The 420 s limit of the run (``--timeout-method thread``) still names the test.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
def _clock(seconds: float) -> str:
|
||||
whole = int(seconds)
|
||||
return "%d:%02d:%02d" % (whole // 3600, whole % 3600 // 60, whole % 60)
|
||||
|
||||
|
||||
class StackWatchdog:
|
||||
def __init__(self) -> None:
|
||||
self._cond = threading.Condition()
|
||||
self._thread: threading.Thread | None = None
|
||||
self._armed = False
|
||||
self._file = None
|
||||
self._started = 0.0
|
||||
self._period = 0.0
|
||||
self._due = 0.0
|
||||
|
||||
@property
|
||||
def thread(self) -> threading.Thread | None:
|
||||
"""The one thread of the process (None until the first ``arm``)."""
|
||||
return self._thread
|
||||
|
||||
def arm(self, nodeid: str, threshold_s: float, period_s: float | None = None, file=None) -> None:
|
||||
"""From ``threshold_s`` seconds on, and then every ``period_s`` (the threshold by default), write the stacks of all threads to ``file`` until ``cancel``."""
|
||||
period = threshold_s if period_s is None else period_s
|
||||
with self._cond:
|
||||
self._file = file
|
||||
self._started = time.monotonic()
|
||||
self._period = max(period, 0.0005)
|
||||
self._due = self._started + threshold_s
|
||||
self._armed = True
|
||||
try:
|
||||
file.write("\n--- %s ---\n" % nodeid)
|
||||
file.flush()
|
||||
except Exception:
|
||||
pass
|
||||
if self._thread is None or not self._thread.is_alive():
|
||||
self._thread = threading.Thread(target=self._run, name="invpw-stack-watchdog", daemon=True)
|
||||
self._thread.start()
|
||||
self._cond.notify_all()
|
||||
|
||||
def cancel(self) -> None:
|
||||
"""Nothing more is written for the armed test once this returns: a dump in progress finishes first, because it is written under the same lock."""
|
||||
with self._cond:
|
||||
self._armed = False
|
||||
self._file = None
|
||||
self._cond.notify_all()
|
||||
|
||||
def _run(self) -> None:
|
||||
with self._cond:
|
||||
while True:
|
||||
if not self._armed:
|
||||
self._cond.wait()
|
||||
continue
|
||||
left = self._due - time.monotonic()
|
||||
if left > 0:
|
||||
# Waiting lets go of the lock, so that a cancel or a new arm is never kept out by a watchdog with a short period.
|
||||
self._cond.wait(left)
|
||||
continue
|
||||
self._write_one_dump()
|
||||
self._due = time.monotonic() + self._period
|
||||
|
||||
def _write_one_dump(self) -> None:
|
||||
mine = threading.get_ident()
|
||||
names = {t.ident: t.name for t in threading.enumerate()}
|
||||
out = ["Timeout (%s)!\n" % _clock(time.monotonic() - self._started)]
|
||||
for ident, frame in sys._current_frames().items():
|
||||
if ident == mine:
|
||||
continue
|
||||
name = names.get(ident)
|
||||
out.append("\nThread 0x%016x%s (most recent call first):\n" % (ident, " [%s]" % name if name else ""))
|
||||
while frame is not None:
|
||||
out.append(' File "%s", line %d in %s\n' % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name))
|
||||
frame = frame.f_back
|
||||
try:
|
||||
self._file.write("".join(out))
|
||||
self._file.flush()
|
||||
except Exception:
|
||||
# A watchdog that fails the suite over its OWN problem is worse than the defect it is watching for.
|
||||
pass
|
||||
|
||||
|
||||
_the_watchdog = StackWatchdog()
|
||||
arm = _the_watchdog.arm
|
||||
cancel = _the_watchdog.cancel
|
||||
|
||||
|
||||
def the_thread() -> threading.Thread | None:
|
||||
return _the_watchdog.thread
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Every pytest process of a Windows job that keeps WER dumps lets Windows Error Reporting see its crash: the bit SEM_NOGPFAULTERRORBOX of its error mode is cleared.
|
||||
|
||||
A process whose error mode carries SEM_NOGPFAULTERRORBOX (0x0002) never invokes Windows Error Reporting when it dies from an unhandled exception, so the
|
||||
LocalDumps key of python.exe that e2e.yml sets (a full dump into ``$RUNNER_TEMP/invpw-evidence/dumps/python``) is never read: the pytest controllers of the
|
||||
runner are born with 0x0003 (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX), and every child inherits the mode of its parent, so every xdist worker is born
|
||||
with it too and a worker that crashes leaves no dump.
|
||||
https://learn.microsoft.com/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode
|
||||
|
||||
``clear_for_wer_dumps()``: tests/conftest.py calls it in ``pytest_configure``, which the controller and every xdist worker run. It acts only when ALL of this
|
||||
holds, so nothing changes on a developer's machine, on Linux, or in a job that did not set LocalDumps:
|
||||
|
||||
* the system is Windows;
|
||||
* ``$INVPW_WER_DUMPS`` (the one variable the "Windows Error Reporting keeps a full dump..." step of each Windows job of e2e.yml exports to ``$GITHUB_ENV``) names an
|
||||
existing folder: the folder the dumps go to.
|
||||
|
||||
It clears bit 0x0002 and keeps every other bit of the mode, and appends one line to ``error-mode.log`` in the parent of that folder (``invpw-evidence/dumps``, inside the evidence the job
|
||||
uploads): ``pid <n> error mode born 0x<hex>, now 0x<hex>``, so the evidence shows the bit was cleared in every process. It writes nothing to stdout or stderr, and it
|
||||
never raises: a failure is a line of that log, not a failed test.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
#: The variable the Windows jobs export: the folder LocalDumps of python.exe writes to.
|
||||
ENV_VAR = "INVPW_WER_DUMPS"
|
||||
LOG_NAME = "error-mode.log"
|
||||
#: SEM_NOGPFAULTERRORBOX: the process is not reported to Windows Error Reporting.
|
||||
SEM_NOGPFAULTERRORBOX = 0x0002
|
||||
|
||||
|
||||
def clear_for_wer_dumps(environ=None) -> None:
|
||||
environ = os.environ if environ is None else environ
|
||||
if sys.platform != "win32":
|
||||
return
|
||||
folder = environ.get(ENV_VAR)
|
||||
if not folder or not os.path.isdir(folder):
|
||||
return
|
||||
log = Path(folder).resolve().parent / LOG_NAME
|
||||
try:
|
||||
import ctypes
|
||||
kernel32 = ctypes.WinDLL("kernel32")
|
||||
kernel32.GetErrorMode.restype = ctypes.c_uint
|
||||
kernel32.SetErrorMode.argtypes = [ctypes.c_uint]
|
||||
kernel32.SetErrorMode.restype = ctypes.c_uint
|
||||
born = kernel32.GetErrorMode()
|
||||
kernel32.SetErrorMode(born & ~SEM_NOGPFAULTERRORBOX)
|
||||
line = "pid %d error mode born 0x%04x, now 0x%04x\n" % (os.getpid(), born, kernel32.GetErrorMode())
|
||||
except Exception as exc: # best effort: the evidence says what went wrong, the test run goes on
|
||||
line = "pid %d error mode not cleared: %s: %s\n" % (os.getpid(), type(exc).__name__, exc)
|
||||
try:
|
||||
with open(log, "a", encoding="utf-8") as handle:
|
||||
handle.write(line)
|
||||
except OSError:
|
||||
pass
|
||||
+9
-5
@@ -1,4 +1,3 @@
|
||||
import faulthandler
|
||||
import http.server
|
||||
import os
|
||||
import random
|
||||
@@ -10,6 +9,7 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import _stack_watchdog
|
||||
from _servers import LocalServer
|
||||
from _browser_census import _a_module_leaves_no_browser_open, _the_connections_a_test_made_are_closed_with_it # noqa: F401 (autouse)
|
||||
|
||||
@@ -71,6 +71,10 @@ def _watchdog_open():
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
# Windows jobs that keep WER dumps (INVPW_WER_DUMPS, exported by the job): the controller and every xdist worker clear SEM_NOGPFAULTERRORBOX of their error mode,
|
||||
# which the runner gives them (0x0003) and which keeps a crashing worker from ever reaching Windows Error Reporting (tests/_wer_error_mode.py).
|
||||
import _wer_error_mode
|
||||
_wer_error_mode.clear_for_wer_dumps()
|
||||
# TEMPORARY, with tests/_crash_cores.py (the -11 at the exit of the security state's generate): on Linux every engine of the run, the core's launches
|
||||
# included, inherits a core limit equal to the hard one, so a crash leaves a core in $INVPW_CORE_DIR (kernel.core_pattern on the e2e jobs).
|
||||
import _crash_cores
|
||||
@@ -91,13 +95,13 @@ def pytest_runtest_setup(item):
|
||||
return
|
||||
handle = _watchdog_open()
|
||||
if handle is not None:
|
||||
handle.write("\n--- %s ---\n" % item.nodeid)
|
||||
faulthandler.dump_traceback_later(_WATCHDOG_S, repeat=True, file=handle)
|
||||
# A Python thread that holds the GIL, not faulthandler.dump_traceback_later: that one copies the frames of every thread without the GIL and crashed a worker (tests/_stack_watchdog.py).
|
||||
_stack_watchdog.arm(item.nodeid, _WATCHDOG_S, file=handle)
|
||||
|
||||
|
||||
def pytest_runtest_teardown(item, nextitem):
|
||||
if _watchdog_handle is not None:
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
_stack_watchdog.cancel()
|
||||
|
||||
|
||||
@pytest.hookimpl(wrapper=True)
|
||||
@@ -125,7 +129,7 @@ def pytest_collection_modifyitems(config, items):
|
||||
def pytest_unconfigure(config):
|
||||
global _watchdog_handle
|
||||
if _watchdog_handle is not None:
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
_stack_watchdog.cancel()
|
||||
_watchdog_handle.close()
|
||||
_watchdog_handle = None
|
||||
|
||||
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
"""faulthandler's thread dump crashes a process whose threads churn frames, and the e2e stack watchdog does not: the hazard behind the Windows part 3 deaths.
|
||||
|
||||
Both halves run the same load in a child python: 32 threads that call a recursive function and start and join a short thread, over and over, so that frames
|
||||
are created and freed all the time, while a watchdog dumps the stacks of every thread every millisecond.
|
||||
|
||||
* The old mechanism, ``faulthandler.dump_traceback_later(0.001, repeat=True)``, copies the frames of every thread without the GIL. The child must die with a
|
||||
crash status (a signal on Linux, an NT status such as 0xC0000005 on Windows), never end well and never end with an exception (status 1). It dies in under 100 ms
|
||||
on CPython 3.11 and 3.12, and the child gets 60 s before the test says that this Python did not show the hazard. This is the proof that the hazard is real.
|
||||
* The new watchdog (``tests/_stack_watchdog.py``) at a period of 1 ms, on the same load, must let the child run for SURVIVAL_S = 6 s (sixty times what the old
|
||||
one lasts) and end with status 0, with the file holding a dump of the threads for at least 20 dumps.
|
||||
|
||||
The child sets itself up not to leave a trace of its crash: on Windows the error mode without the crash box (no Windows Error Reporting dialog and no dump
|
||||
in the LocalDumps folder of a job that keeps them), on Linux a core limit of 0.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
SURVIVAL_S = 6.0
|
||||
THREADS = 32
|
||||
HAZARD_DEADLINE_S = 60.0
|
||||
|
||||
CHILD = '''
|
||||
import json, os, sys, threading, time
|
||||
|
||||
mode, seconds, threads, tests_dir, log_path = sys.argv[1], float(sys.argv[2]), int(sys.argv[3]), sys.argv[4], sys.argv[5]
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
ctypes.windll.kernel32.SetErrorMode(0x8003)
|
||||
else:
|
||||
import resource
|
||||
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
|
||||
sys.path.insert(0, tests_dir)
|
||||
|
||||
stop = threading.Event()
|
||||
|
||||
|
||||
def deep(n):
|
||||
if n == 0:
|
||||
return sum(i for i in range(5))
|
||||
return deep(n - 1) + 1
|
||||
|
||||
|
||||
def churn():
|
||||
while not stop.is_set():
|
||||
deep(30)
|
||||
t = threading.Thread(target=deep, args=(10,))
|
||||
t.start()
|
||||
t.join()
|
||||
|
||||
|
||||
class Sink:
|
||||
"""Counts the dumps and keeps the first megabyte of them in the file: a dump every millisecond would fill a disk."""
|
||||
|
||||
def __init__(self, path):
|
||||
self.file = open(path, "w", encoding="utf-8")
|
||||
self.kept = 0
|
||||
self.dumps = 0
|
||||
|
||||
def write(self, text):
|
||||
self.dumps += text.count("Timeout (")
|
||||
if self.kept < 1000000:
|
||||
self.kept += self.file.write(text)
|
||||
|
||||
def flush(self):
|
||||
self.file.flush()
|
||||
|
||||
|
||||
if mode == "old":
|
||||
import faulthandler
|
||||
faulthandler.dump_traceback_later(0.001, repeat=True, file=open(os.devnull, "w"))
|
||||
else:
|
||||
import _stack_watchdog as dog
|
||||
sink = Sink(log_path)
|
||||
dog.arm("stress", 0.001, 0.001, file=sink)
|
||||
|
||||
workers = [threading.Thread(target=churn, daemon=True) for _ in range(threads)]
|
||||
for w in workers:
|
||||
w.start()
|
||||
time.sleep(seconds)
|
||||
stop.set()
|
||||
if mode == "old":
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
else:
|
||||
dog.cancel()
|
||||
for w in workers:
|
||||
w.join()
|
||||
print(json.dumps({"survived": True, "dumps": 0 if mode == "old" else sink.dumps}))
|
||||
'''
|
||||
|
||||
|
||||
def _run(tmp_path: Path, mode: str, seconds: float, timeout: float):
|
||||
script = tmp_path / ("child_%s.py" % mode)
|
||||
script.write_text(CHILD, encoding="utf-8")
|
||||
log = tmp_path / "dumps.log"
|
||||
done = subprocess.run([sys.executable, str(script), mode, str(seconds), str(THREADS), str(TESTS), str(log)], capture_output=True, text=True, timeout=timeout)
|
||||
return done, log
|
||||
|
||||
|
||||
def _crashed(returncode: int) -> bool:
|
||||
"""A signal on POSIX (negative), an NT status (0xC0000005 and the like, from 0x80000000) on Windows. An exception of Python is 1, a good end is 0."""
|
||||
return returncode < 0 or returncode >= 0x80000000
|
||||
|
||||
|
||||
def test_the_dump_of_faulthandler_kills_a_process_that_churns_frames(tmp_path):
|
||||
done, _ = _run(tmp_path, "old", HAZARD_DEADLINE_S, HAZARD_DEADLINE_S + 60)
|
||||
assert _crashed(done.returncode), (
|
||||
"faulthandler.dump_traceback_later(0.001, repeat=True) did not crash the child on this Python (%s, status %s): the GIL-free copy of the frames "
|
||||
"did not show on %d threads in %d s. stdout %r, stderr %r" % (sys.version.split()[0], done.returncode, THREADS, HAZARD_DEADLINE_S, done.stdout[-200:], done.stderr[-500:]))
|
||||
|
||||
|
||||
def test_the_stack_watchdog_survives_the_same_load_for_sixty_times_as_long(tmp_path):
|
||||
done, log = _run(tmp_path, "new", SURVIVAL_S, SURVIVAL_S + 120)
|
||||
assert done.returncode == 0, "the child ended with status %s after at most %s s, stderr %r" % (done.returncode, SURVIVAL_S, done.stderr[-800:])
|
||||
result = json.loads(done.stdout)
|
||||
assert result["survived"] and result["dumps"] >= 20, result
|
||||
text = log.read_text(encoding="utf-8", errors="replace")
|
||||
assert "Timeout (" in text and "Thread 0x" in text and "in churn" in text
|
||||
@@ -0,0 +1,99 @@
|
||||
"""On Windows, a pytest process of a job that keeps WER dumps clears SEM_NOGPFAULTERRORBOX of its error mode and keeps its other bits (tests/_wer_error_mode.py).
|
||||
|
||||
The runner starts the pytest controllers with the error mode 0x0003 (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX), every child inherits the mode of its parent,
|
||||
and a process with the bit 0x0002 never invokes Windows Error Reporting: the LocalDumps key of python.exe of the job (e2e.yml) never saw a crashing xdist worker.
|
||||
|
||||
The behaviour, in a real child python (the mode is a property of the process, and a child inherits it from the parent's ``SetErrorMode`` at its start):
|
||||
|
||||
* born with 0x0003 and ``INVPW_WER_DUMPS`` naming an existing folder: the child's mode afterwards is 0x0001, and ``error-mode.log`` next to the dumps' folder holds the
|
||||
line of that process, with the mode it was born with and the mode it has now; other bits of the mode stay (0x8003 gives 0x8001, 0x0000 stays 0x0000);
|
||||
* without the variable, or with a folder that does not exist: the mode is unchanged and no log is written.
|
||||
|
||||
A file of its own, and only the row of Windows names it: the kernel's error mode is a Windows mechanism and the test skips on every other system, where a skip is red
|
||||
in the row (tests/test_reaper_on_windows.py is the same case). What runs on both systems (nothing happens off Windows) is in
|
||||
tests/test_every_windows_job_keeps_a_dump_of_a_crashing_python.py.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = [pytest.mark.unit, pytest.mark.skipif(os.name != "nt", reason="the error mode of a process is a Windows mechanism")]
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
#: What the child does: runs the entry point of tests/_wer_error_mode.py as conftest's pytest_configure does, and says its pid and its mode before and after.
|
||||
CHILD = (
|
||||
"import ctypes, json, os, sys\n"
|
||||
"sys.path.insert(0, sys.argv[1])\n"
|
||||
"k = ctypes.WinDLL('kernel32')\n"
|
||||
"k.GetErrorMode.restype = ctypes.c_uint\n"
|
||||
"born = k.GetErrorMode()\n"
|
||||
"import _wer_error_mode\n"
|
||||
"_wer_error_mode.clear_for_wer_dumps()\n"
|
||||
"print(json.dumps({'pid': os.getpid(), 'born': born, 'now': k.GetErrorMode()}))\n"
|
||||
)
|
||||
|
||||
|
||||
def _run_child(born_mode: int, variable: str | None) -> tuple[dict, subprocess.CompletedProcess]:
|
||||
"""A child python started with the error mode ``born_mode`` (set in this process just before the spawn, put back after), and ``INVPW_WER_DUMPS`` = ``variable``."""
|
||||
kernel32 = ctypes.WinDLL("kernel32")
|
||||
kernel32.GetErrorMode.restype = ctypes.c_uint
|
||||
kernel32.SetErrorMode.argtypes = [ctypes.c_uint]
|
||||
kernel32.SetErrorMode.restype = ctypes.c_uint
|
||||
env = {k: v for k, v in os.environ.items() if k != "INVPW_WER_DUMPS"}
|
||||
if variable is not None:
|
||||
env["INVPW_WER_DUMPS"] = variable
|
||||
mine = kernel32.GetErrorMode()
|
||||
kernel32.SetErrorMode(born_mode)
|
||||
try:
|
||||
done = subprocess.run([sys.executable, "-c", CHILD, str(TESTS)], env=env, capture_output=True, text=True, timeout=120)
|
||||
finally:
|
||||
kernel32.SetErrorMode(mine)
|
||||
assert done.returncode == 0, "the child failed: " + done.stderr[-1500:]
|
||||
return json.loads(done.stdout.strip().splitlines()[-1]), done
|
||||
|
||||
|
||||
def _evidence(tmp_path: Path) -> tuple[Path, Path]:
|
||||
"""The shape of the job's evidence: <evidence>/dumps/python is the folder of the dumps, the log goes to <evidence>/dumps."""
|
||||
dumps = tmp_path / "invpw-evidence" / "dumps" / "python"
|
||||
dumps.mkdir(parents=True)
|
||||
return dumps, dumps.parent / "error-mode.log"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("born, expected", [(0x0003, 0x0001), (0x0002, 0x0000), (0x8003, 0x8001), (0x0001, 0x0001), (0x0000, 0x0000)])
|
||||
def test_the_child_loses_the_gp_fault_bit_and_keeps_the_other_bits(tmp_path, born, expected):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, done = _run_child(born, str(dumps))
|
||||
assert seen["born"] == born, "the child was not born with 0x%04x but 0x%04x (the mode is not inherited here): %r" % (born, seen["born"], seen)
|
||||
assert seen["now"] == expected, "born 0x%04x, expected 0x%04x after the entry point, got 0x%04x" % (born, expected, seen["now"])
|
||||
assert seen["now"] == born & ~0x0002
|
||||
assert done.stderr == "" and done.stdout.strip() == json.dumps(seen), "the entry point wrote to stdout or stderr: %r %r" % (done.stdout, done.stderr)
|
||||
line = "pid %d error mode born 0x%04x, now 0x%04x" % (seen["pid"], born, expected)
|
||||
assert line in log.read_text(encoding="utf-8").splitlines(), "no evidence line %r in %s: %r" % (line, log, log.read_text(encoding="utf-8") if log.exists() else None)
|
||||
|
||||
|
||||
def test_the_runner_mode_0x0003_gives_0x0001_and_the_evidence_says_so(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, str(dumps))
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0001)
|
||||
assert log.read_text(encoding="utf-8") == "pid %d error mode born 0x0003, now 0x0001\n" % seen["pid"]
|
||||
|
||||
|
||||
def test_without_the_variable_the_mode_is_unchanged_and_nothing_is_written(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, None)
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0003), seen
|
||||
assert not log.exists() and list(tmp_path.rglob("*.log")) == []
|
||||
|
||||
|
||||
def test_a_variable_that_names_no_folder_leaves_the_mode_unchanged(tmp_path):
|
||||
dumps, log = _evidence(tmp_path)
|
||||
seen, _ = _run_child(0x0003, str(tmp_path / "no-such-folder"))
|
||||
assert (seen["born"], seen["now"]) == (0x0003, 0x0003), seen
|
||||
assert not log.exists()
|
||||
@@ -10,10 +10,14 @@ For each Windows job that runs pytest (found by ``runs-on: windows-*``, so a new
|
||||
|
||||
* before its first pytest step a PowerShell step turns WER on (``Disabled`` 0, ``DontShowUI`` 1) and sets LocalDumps of python.exe: ``DumpType`` 2, ``DumpCount`` 3,
|
||||
``DumpFolder`` an expandable string, ``$RUNNER_TEMP/invpw-evidence/dumps/python``: inside the folder the job's evidence upload takes;
|
||||
* the same step exports ``INVPW_WER_DUMPS=$dumps`` (the DumpFolder) to ``$GITHUB_ENV``, so that every later step has it: tests/conftest.py then makes every pytest
|
||||
process (the controller and each xdist worker) clear SEM_NOGPFAULTERRORBOX (0x0002) of its error mode (tests/_wer_error_mode.py). The runner gives its pytest
|
||||
processes the mode 0x0003, every child inherits it, and a process with that bit never invokes Windows Error Reporting: with LocalDumps set and the bit kept, a
|
||||
crashing worker still left no dump. Nothing else sets the variable;
|
||||
* after the tests a step with ``if: always()`` runs ``scripts/ci_wer_dumps.py`` on that folder (sizes, faulting module), before the upload;
|
||||
* the upload of ``$RUNNER_TEMP/invpw-evidence`` is ``if: always()``, after the tests.
|
||||
|
||||
Known-bad inputs: a job without the step, the step after the first pytest step, a mini dump (DumpType 1), a key of another executable, a folder outside the evidence, a
|
||||
Known-bad inputs: a job whose step does not export the variable, one that exports another folder, a job that sets the variable elsewhere, a job without the step, the step after the first pytest step, a mini dump (DumpType 1), a key of another executable, a folder outside the evidence, a
|
||||
summary missing or not ``always()``, an upload that is not ``always()``. The green case is the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -89,6 +93,14 @@ def _problems(name: str, job: str) -> list[str]:
|
||||
bad.append("%s: WER is not made enabled (Disabled 0)" % name)
|
||||
if not re.search(r"-Name DontShowUI -PropertyType DWord -Value 1\b", step):
|
||||
bad.append("%s: WER may show a dialog (DontShowUI 1 missing)" % name)
|
||||
if not re.search(r'^\s*"INVPW_WER_DUMPS=\$dumps"\s*\|\s*Out-File -FilePath \$env:GITHUB_ENV -Append', step, re.M):
|
||||
bad.append("%s: the LocalDumps step does not export INVPW_WER_DUMPS=$dumps (the DumpFolder) to $GITHUB_ENV: without it tests/conftest.py leaves the error mode of "
|
||||
"every pytest process as the runner gave it (0x0003, SEM_NOGPFAULTERRORBOX set) and a crashing xdist worker never reaches the LocalDumps above" % name)
|
||||
in_job = [ln for ln in job.split("\n") if "INVPW_WER_DUMPS" in ln and not ln.strip().startswith("#")]
|
||||
in_step = [ln for ln in step.split("\n") if "INVPW_WER_DUMPS" in ln]
|
||||
if len(in_job) != len(in_step):
|
||||
bad.append("%s: INVPW_WER_DUMPS is set outside the LocalDumps step (%d lines in the job, %d in the step): the one step that sets the dump folder exports it"
|
||||
% (name, len(in_job), len(in_step)))
|
||||
uploads = [i for i, s in enumerate(steps) if "actions/upload-artifact" in s and re.search(r"^\s+(path: )?\$\{\{ runner\.temp \}\}/invpw-evidence$", s, re.M)]
|
||||
if len(uploads) != 1:
|
||||
return bad + ["%s: %d steps upload the evidence folder, expected 1" % (name, len(uploads))]
|
||||
@@ -132,6 +144,9 @@ def test_the_job_keeps_a_full_dump_of_a_crashing_python_in_its_evidence(name):
|
||||
(lambda t: t.replace("-Name Disabled -PropertyType DWord -Value 0", "-Name Disabled -PropertyType DWord -Value 1"), "Disabled 0"),
|
||||
(lambda t: t.replace("-PropertyType ExpandString", "-PropertyType String"), "not an expandable string"),
|
||||
(lambda t: t.replace("'invpw-evidence\\dumps\\python'", "'crash-dumps'"), "not RUNNER_TEMP/invpw-evidence/dumps/python"),
|
||||
(lambda t: t.replace('"INVPW_WER_DUMPS=$dumps" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8\n', ""), "does not export INVPW_WER_DUMPS=$dumps"),
|
||||
(lambda t: t.replace('"INVPW_WER_DUMPS=$dumps"', '"INVPW_WER_DUMPS=C:\\elsewhere"'), "does not export INVPW_WER_DUMPS=$dumps"),
|
||||
(lambda t: t.replace(" - name: Upload what the test saved\n", " - name: Upload what the test saved\n env:\n INVPW_WER_DUMPS: x\n"), "set outside the LocalDumps step"),
|
||||
(lambda t: t.replace("scripts/ci_wer_dumps.py", "scripts/nothing.py"), "0 steps run scripts/ci_wer_dumps.py"),
|
||||
(lambda t: t.replace(SUMMARY_STEP + ALWAYS, SUMMARY_STEP), "dump summary is not if: always()"),
|
||||
(lambda t: t.replace(" - name: Upload what the test saved\n" + ALWAYS, " - name: Upload what the test saved\n"), "upload of the evidence is not if: always()"),
|
||||
@@ -153,3 +168,13 @@ def test_the_step_after_the_tests_and_the_missing_step_are_refused():
|
||||
assert any("0 steps set LocalDumps" in p for p in _problems("x", gone))
|
||||
moved = job[:start] + job[end + 1:] + "\n" + job[start:end]
|
||||
assert any("after the first pytest step" in p for p in _problems("x", moved)), _problems("x", moved)
|
||||
|
||||
|
||||
def test_the_entry_point_does_nothing_off_windows(tmp_path, monkeypatch):
|
||||
"""Linux (and any system but Windows) is left alone, whatever the variable says: no log, no error, nothing written."""
|
||||
import _wer_error_mode
|
||||
dumps = tmp_path / "invpw-evidence" / "dumps" / "python"
|
||||
dumps.mkdir(parents=True)
|
||||
monkeypatch.setattr(_wer_error_mode.sys, "platform", "linux")
|
||||
_wer_error_mode.clear_for_wer_dumps({"INVPW_WER_DUMPS": str(dumps)})
|
||||
assert list(tmp_path.rglob("*.log")) == []
|
||||
@@ -0,0 +1,304 @@
|
||||
"""No code of this repository arms a thread dump that copies the frames of every thread without the GIL: that dump crashes a live process.
|
||||
|
||||
``faulthandler.dump_traceback_later`` (and pytest's ``faulthandler_timeout``, which arms it), and ``faulthandler.dump_traceback`` with ``all_threads`` true or
|
||||
defaulted, walk the frames of every thread with ``_Py_DumpTracebackThreads``: CPython documents it as "for debug purpose only ... after a segmentation fault, at
|
||||
fatal error". Its watchdog is a C thread that does not hold the GIL while the process keeps running, so it reads a frame another thread is freeing. The Windows
|
||||
part 3 of the e2e lost five workers that way, inside ``dump_frame`` of ``faulthandler_thread`` (two full dumps), all on the one test that runs 2 minutes with about 50
|
||||
threads. The e2e stack watchdog is ``tests/_stack_watchdog.py``, a Python thread that writes ``sys._current_frames()`` holding the GIL.
|
||||
|
||||
What is read, as code and never as text: the ``.py`` files of ``tests/``, ``scripts/`` and ``src/`` with ``ast`` (a call, through ``import faulthandler``, an alias
|
||||
of it, or ``from faulthandler import ...``; a comment or a string that names the function is not a call); ``pyproject.toml`` with a TOML parser, and
|
||||
``pytest.ini``, ``setup.cfg`` and ``tox.ini`` with ``configparser``, for the key ``faulthandler_timeout`` and for it inside ``addopts``; the strings of the
|
||||
``conftest.py`` files and of ``scripts/`` (an ``addopts`` or a ``-o`` argument); the lines of ``.github/workflows/*.yml`` that are not comments.
|
||||
|
||||
Vendored code is excluded only where the repository already has an exclusion list: ``norecursedirs`` of ``[tool.pytest.ini_options]`` in ``pyproject.toml``
|
||||
(``playwright-upstream``, the vendored suite of Playwright, which is not in the tree). The Playwright client vendored in ``src/invisible_playwright/_pw`` has no
|
||||
list and is read like the rest.
|
||||
|
||||
Known-bad inputs, each on a tree in ``tmp_path``: the two lines of ``tests/conftest.py`` of 03425bb8, every form of the call, every place the timeout can be set.
|
||||
Each has its positive next to it: ``dump_traceback(all_threads=False)``, ``faulthandler.enable(all_threads=True)`` (a dump at the death of the process), a comment
|
||||
and a string that name the function, a workflow comment, an excluded folder. The green case is the state of the repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import configparser
|
||||
import re
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
CODE_DIRS = ("tests", "scripts", "src")
|
||||
ALWAYS_SKIPPED = {"__pycache__"}
|
||||
TIMEOUT_NAME = re.compile(r"faulthandler[-_]timeout")
|
||||
RULE = ("the rule: no thread dump that reads the frames of every thread without the GIL (faulthandler.dump_traceback_later, pytest's faulthandler_timeout, "
|
||||
"dump_traceback with all_threads) may be armed in a live process, because it crashed the Windows part 3 worker")
|
||||
FIX = "use tests/_stack_watchdog.py (arm and cancel), a Python thread that writes sys._current_frames() holding the GIL"
|
||||
|
||||
|
||||
def _say(where: str, what: str) -> str:
|
||||
return "%s: %s. How to fix: %s. %s" % (where, what, FIX, RULE)
|
||||
|
||||
|
||||
def _pyproject(root: Path) -> dict:
|
||||
path = root / "pyproject.toml"
|
||||
return tomllib.loads(path.read_text(encoding="utf-8")) if path.is_file() else {}
|
||||
|
||||
|
||||
def _pytest_tables(data: dict) -> list:
|
||||
tool = data.get("tool", {}).get("pytest", {})
|
||||
return [t for t in (tool.get("ini_options"), tool if "ini_options" not in tool else None) if isinstance(t, dict)]
|
||||
|
||||
|
||||
def excluded_dirs(root: Path) -> set:
|
||||
"""The only exclusion list the repository has: norecursedirs of pytest, in pyproject.toml."""
|
||||
out = set(ALWAYS_SKIPPED)
|
||||
for table in _pytest_tables(_pyproject(root)):
|
||||
out.update(table.get("norecursedirs", []))
|
||||
return out
|
||||
|
||||
|
||||
def python_files(root: Path, folders=CODE_DIRS):
|
||||
skipped = excluded_dirs(root)
|
||||
for folder in folders:
|
||||
base = root / folder
|
||||
if not base.is_dir():
|
||||
continue
|
||||
for path in sorted(base.rglob("*.py")):
|
||||
if not skipped.intersection(path.relative_to(root).parts):
|
||||
yield path
|
||||
|
||||
|
||||
def _faulthandler_names(tree: ast.AST):
|
||||
modules, functions = set(), {}
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Import):
|
||||
modules.update(a.asname or a.name for a in node.names if a.name == "faulthandler")
|
||||
elif isinstance(node, ast.ImportFrom) and node.module == "faulthandler":
|
||||
functions.update({a.asname or a.name: a.name for a in node.names})
|
||||
return modules, functions
|
||||
|
||||
|
||||
def _all_threads_is_false(call: ast.Call) -> bool:
|
||||
"""dump_traceback(file, all_threads): only a literal False is proof that one thread is dumped."""
|
||||
for keyword in call.keywords:
|
||||
if keyword.arg == "all_threads":
|
||||
return isinstance(keyword.value, ast.Constant) and keyword.value.value is False
|
||||
return len(call.args) >= 2 and isinstance(call.args[1], ast.Constant) and call.args[1].value is False
|
||||
|
||||
|
||||
def calls_in_source(source: str) -> list:
|
||||
"""(line, text) of every call to faulthandler.dump_traceback_later and of faulthandler.dump_traceback that dumps every thread."""
|
||||
tree = ast.parse(source)
|
||||
modules, functions = _faulthandler_names(tree)
|
||||
found = []
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.Call):
|
||||
continue
|
||||
func = node.func
|
||||
if isinstance(func, ast.Attribute) and isinstance(func.value, ast.Name) and func.value.id in modules:
|
||||
name = func.attr
|
||||
elif isinstance(func, ast.Name) and func.id in functions:
|
||||
name = functions[func.id]
|
||||
else:
|
||||
continue
|
||||
if name == "dump_traceback_later":
|
||||
found.append((node.lineno, "faulthandler.dump_traceback_later is armed"))
|
||||
elif name == "dump_traceback" and not _all_threads_is_false(node):
|
||||
found.append((node.lineno, "faulthandler.dump_traceback dumps every thread (all_threads is true or defaulted)"))
|
||||
return found
|
||||
|
||||
|
||||
def timeout_strings_in_source(source: str) -> list:
|
||||
"""(line, text) of every string of the code that names pytest's faulthandler_timeout (an addopts, a -o argument, a command line)."""
|
||||
return [(n.lineno, "a string names pytest's faulthandler_timeout: %r" % n.value[:80])
|
||||
for n in ast.walk(ast.parse(source)) if isinstance(n, ast.Constant) and isinstance(n.value, str) and TIMEOUT_NAME.search(n.value)]
|
||||
|
||||
|
||||
def python_problems(root: Path) -> list:
|
||||
out = []
|
||||
for path in python_files(root):
|
||||
where = path.relative_to(root).as_posix()
|
||||
try:
|
||||
source = path.read_text(encoding="utf-8")
|
||||
found = calls_in_source(source)
|
||||
except (SyntaxError, UnicodeDecodeError, ValueError) as error:
|
||||
out.append(_say(where, "the file cannot be read as Python (%s), so it cannot be shown free of the dump" % error))
|
||||
continue
|
||||
out += [_say("%s:%d" % (where, line), what) for line, what in found]
|
||||
return out
|
||||
|
||||
|
||||
def string_problems(root: Path) -> list:
|
||||
"""The strings of every conftest.py and of scripts/ that name faulthandler_timeout."""
|
||||
paths = [p for p in python_files(root, ("tests",)) if p.name == "conftest.py"] + list(python_files(root, ("scripts",)))
|
||||
out = []
|
||||
for path in paths:
|
||||
try:
|
||||
found = timeout_strings_in_source(path.read_text(encoding="utf-8"))
|
||||
except (SyntaxError, UnicodeDecodeError, ValueError):
|
||||
continue # python_problems already says that a file cannot be read
|
||||
out += [_say("%s:%d" % (path.relative_to(root).as_posix(), line), what) for line, what in found]
|
||||
return out
|
||||
|
||||
|
||||
def _value_names_timeout(value) -> bool:
|
||||
return bool(TIMEOUT_NAME.search(" ".join(value) if isinstance(value, list) else str(value)))
|
||||
|
||||
|
||||
def config_problems(root: Path) -> list:
|
||||
out = []
|
||||
for table in _pytest_tables(_pyproject(root)):
|
||||
if "faulthandler_timeout" in table:
|
||||
out.append(_say("pyproject.toml [tool.pytest.ini_options]", "faulthandler_timeout is set (it arms dump_traceback_later for every test)"))
|
||||
if _value_names_timeout(table.get("addopts", "")):
|
||||
out.append(_say("pyproject.toml [tool.pytest.ini_options] addopts", "addopts names faulthandler_timeout"))
|
||||
for name, section in (("pytest.ini", "pytest"), ("setup.cfg", "tool:pytest"), ("tox.ini", "pytest")):
|
||||
path = root / name
|
||||
if not path.is_file():
|
||||
continue
|
||||
parser = configparser.ConfigParser(interpolation=None)
|
||||
parser.read_string(path.read_text(encoding="utf-8"))
|
||||
if parser.has_option(section, "faulthandler_timeout"):
|
||||
out.append(_say("%s [%s]" % (name, section), "faulthandler_timeout is set (it arms dump_traceback_later for every test)"))
|
||||
if parser.has_option(section, "addopts") and _value_names_timeout(parser.get(section, "addopts")):
|
||||
out.append(_say("%s [%s] addopts" % (name, section), "addopts names faulthandler_timeout"))
|
||||
return out
|
||||
|
||||
|
||||
def workflow_problems(root: Path) -> list:
|
||||
out = []
|
||||
folder = root / ".github" / "workflows"
|
||||
for path in sorted(folder.glob("*.yml")) if folder.is_dir() else []:
|
||||
for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
|
||||
code = re.split(r"(?:^|\s)#", line, maxsplit=1)[0]
|
||||
if TIMEOUT_NAME.search(code):
|
||||
out.append(_say("%s:%d" % (path.relative_to(root).as_posix(), number), "the workflow sets pytest's faulthandler_timeout: %s" % code.strip()[:100]))
|
||||
return out
|
||||
|
||||
|
||||
def problems(root: Path) -> list:
|
||||
return python_problems(root) + string_problems(root) + config_problems(root) + workflow_problems(root)
|
||||
|
||||
|
||||
def _tree(tmp_path: Path, files: dict) -> Path:
|
||||
for name, text in files.items():
|
||||
path = tmp_path / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8")
|
||||
return tmp_path
|
||||
|
||||
|
||||
def test_no_file_of_the_repository_arms_a_gil_free_thread_dump():
|
||||
found = problems(ROOT)
|
||||
assert not found, "\n".join(found)
|
||||
|
||||
|
||||
# The two lines of tests/conftest.py of 03425bb8, which the e2e of the Windows part 3 ran.
|
||||
OLD_CONFTEST = '''import faulthandler
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
handle = open("w.log", "a")
|
||||
faulthandler.dump_traceback_later(150.0, repeat=True, file=handle)
|
||||
|
||||
|
||||
def pytest_runtest_teardown(item, nextitem):
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
'''
|
||||
|
||||
|
||||
def test_the_conftest_of_03425bb8_is_red_and_names_the_file_and_the_line(tmp_path):
|
||||
found = problems(_tree(tmp_path, {"tests/conftest.py": OLD_CONFTEST}))
|
||||
assert len(found) == 1
|
||||
assert found[0].startswith("tests/conftest.py:6: faulthandler.dump_traceback_later is armed. How to fix: use tests/_stack_watchdog.py")
|
||||
assert "crashed the Windows part 3 worker" in found[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source, line", [
|
||||
("import faulthandler\nfaulthandler.dump_traceback_later(1)\n", 2),
|
||||
("import faulthandler as fh\nfh.dump_traceback_later(1, repeat=True)\n", 2),
|
||||
("from faulthandler import dump_traceback_later\ndump_traceback_later(1)\n", 2),
|
||||
("from faulthandler import dump_traceback_later as arm\ndef f():\n arm(1)\n", 3),
|
||||
("import faulthandler\nfaulthandler.dump_traceback()\n", 2),
|
||||
("import faulthandler\nfaulthandler.dump_traceback(all_threads=True)\n", 2),
|
||||
("import faulthandler, sys\nfaulthandler.dump_traceback(sys.stderr, True)\n", 2),
|
||||
("import faulthandler\nfaulthandler.dump_traceback(all_threads=some_flag)\n", 2),
|
||||
("from faulthandler import dump_traceback\ndump_traceback(None)\n", 2),
|
||||
])
|
||||
@pytest.mark.parametrize("folder", ["tests", "scripts", "src/pkg"])
|
||||
def test_every_form_of_the_call_is_red_in_every_folder(tmp_path, folder, source, line):
|
||||
found = python_problems(_tree(tmp_path, {folder + "/a.py": source}))
|
||||
assert [f.split(":")[0:2] for f in found] == [["%s/a.py" % folder, str(line)]]
|
||||
|
||||
|
||||
def test_a_file_that_cannot_be_parsed_is_red_and_not_skipped(tmp_path):
|
||||
found = python_problems(_tree(tmp_path, {"scripts/broken.py": "def (:\n"}))
|
||||
assert len(found) == 1 and found[0].startswith("scripts/broken.py: the file cannot be read as Python")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", [
|
||||
"import faulthandler\nfaulthandler.dump_traceback(all_threads=False)\n",
|
||||
"import faulthandler, sys\nfaulthandler.dump_traceback(sys.stderr, False)\n",
|
||||
"import faulthandler\nfaulthandler.enable(all_threads=True)\nfaulthandler.cancel_dump_traceback_later()\n",
|
||||
"# faulthandler.dump_traceback_later(1)\nx = 'faulthandler.dump_traceback_later(1)'\n",
|
||||
'"""faulthandler.dump_traceback_later(1)"""\n',
|
||||
"def dump_traceback_later(x):\n return x\ndump_traceback_later(1)\n",
|
||||
"class faulthandler:\n def dump_traceback_later(self): ...\nfaulthandler().dump_traceback_later()\n",
|
||||
])
|
||||
def test_the_uses_that_do_not_crash_a_live_process_are_green(tmp_path, source):
|
||||
assert python_problems(_tree(tmp_path, {"tests/a.py": source})) == []
|
||||
|
||||
|
||||
def test_a_folder_in_norecursedirs_is_the_only_one_left_out(tmp_path):
|
||||
call = "import faulthandler\nfaulthandler.dump_traceback_later(1)\n"
|
||||
pyproject = '[tool.pytest.ini_options]\nnorecursedirs = ["playwright-upstream"]\n'
|
||||
root = _tree(tmp_path, {"pyproject.toml": pyproject, "tests/playwright-upstream/a.py": call, "tests/vendor/b.py": call})
|
||||
assert [f.split(":")[0] for f in python_problems(root)] == ["tests/vendor/b.py"]
|
||||
assert excluded_dirs(root) == {"__pycache__", "playwright-upstream"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pyproject", [
|
||||
'[tool.pytest.ini_options]\nfaulthandler_timeout = 300\n',
|
||||
'[tool.pytest.ini_options]\naddopts = "-m unit -o faulthandler_timeout=300"\n',
|
||||
'[tool.pytest.ini_options]\naddopts = ["-m", "unit", "--faulthandler-timeout=300"]\n',
|
||||
'[tool.pytest]\nfaulthandler_timeout = 300\n',
|
||||
])
|
||||
def test_the_timeout_of_pytest_in_pyproject_is_red(tmp_path, pyproject):
|
||||
found = config_problems(_tree(tmp_path, {"pyproject.toml": pyproject}))
|
||||
assert len(found) == 1 and found[0].startswith("pyproject.toml [tool.pytest")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, section", [("pytest.ini", "pytest"), ("setup.cfg", "tool:pytest"), ("tox.ini", "pytest")])
|
||||
def test_the_timeout_of_pytest_in_an_ini_file_is_red(tmp_path, name, section):
|
||||
found = config_problems(_tree(tmp_path, {name: "[%s]\nfaulthandler_timeout = 300\n" % section}))
|
||||
assert len(found) == 1 and found[0].startswith("%s [%s]" % (name, section))
|
||||
found = config_problems(_tree(tmp_path / "b", {name: "[%s]\naddopts = -x --faulthandler-timeout=9\n" % section}))
|
||||
assert len(found) == 1 and found[0].startswith("%s [%s] addopts" % (name, section))
|
||||
|
||||
|
||||
def test_a_config_with_no_timeout_is_green(tmp_path):
|
||||
files = {"pyproject.toml": '[tool.pytest.ini_options]\naddopts = "-m unit"\ntimeout = 420\n', "pytest.ini": "[pytest]\naddopts = -x\n",
|
||||
"tox.ini": "[tox]\nenvlist = a\n[testenv]\ncommands = pytest -o faulthandler_timeout=3\n", "setup.cfg": "[flake8]\nmax-line-length = 9\n"}
|
||||
assert config_problems(_tree(tmp_path, files)) == []
|
||||
|
||||
|
||||
def test_a_conftest_and_a_script_that_name_the_timeout_in_a_string_are_red(tmp_path):
|
||||
root = _tree(tmp_path, {
|
||||
"tests/conftest.py": "def pytest_configure(config):\n config.addinivalue_line('addopts', '--faulthandler-timeout=9')\n",
|
||||
"scripts/run.py": "ARGS = ['pytest', '-o', 'faulthandler_timeout=9']\n",
|
||||
"tests/test_a.py": "ARGS = ['-o', 'faulthandler_timeout=9']\n",
|
||||
})
|
||||
assert [f.split(":")[0:2] for f in string_problems(root)] == [["tests/conftest.py", "2"], ["scripts/run.py", "1"]]
|
||||
|
||||
|
||||
def test_a_workflow_that_sets_the_timeout_is_red_and_a_comment_is_not(tmp_path):
|
||||
root = _tree(tmp_path, {".github/workflows/a.yml": "jobs:\n t:\n steps:\n # pytest -o faulthandler_timeout=9 is what not to do\n"
|
||||
" - run: pytest -o faulthandler_timeout=300 tests # not this\n"
|
||||
" - run: pytest --faulthandler-timeout 5\n"
|
||||
" - run: pytest tests # --faulthandler-timeout 5\n"})
|
||||
assert [f.split(":")[0:2] for f in workflow_problems(root)] == [[".github/workflows/a.yml", "5"], [".github/workflows/a.yml", "6"]]
|
||||
@@ -0,0 +1,122 @@
|
||||
"""The e2e stack watchdog (``tests/_stack_watchdog.py``) writes the stacks of every thread once the threshold of a test is passed, and nothing after the cancel.
|
||||
|
||||
It runs in a child python, so that no thread of this pytest session is touched and the file is the only thing read. The child arms the watchdog for a test, parks
|
||||
in a function named ``the_blocked_call_of_the_test`` until the file holds two dumps (it waits on the file, with a deadline of 90 s that is only a guard against a
|
||||
hang), cancels, and arms a second test, whose first dump it waits for. What the parent checks, on the file and on the exit of the child:
|
||||
|
||||
* the dump has the header ``Timeout (h:mm:ss)!`` and, for the threads, ``Thread 0x... (most recent call first):`` with the frames, the blocked function's name
|
||||
among them and the name of a parked thread (from ``threading.enumerate()``): the shape that whoever reads ``e2e-watchdog.log`` reads;
|
||||
* a test that is cancelled before its threshold leaves its ``--- nodeid ---`` line and no dump;
|
||||
* once ``cancel`` returned, nothing more is written for that test: the bytes of the file at that moment are the same after the second test's first dump, and
|
||||
everything after them belongs to the second test (the second dump arriving is what shows the watchdog was running, so no fixed wait decides the verdict);
|
||||
* the second test reuses the same thread, and the process has only one watchdog thread;
|
||||
* nothing is written to stdout or stderr but the child's own result line.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
TESTS = Path(__file__).resolve().parent
|
||||
|
||||
CHILD = '''
|
||||
import json, os, sys, threading, time
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
import _stack_watchdog as dog
|
||||
|
||||
path = sys.argv[2]
|
||||
log = open(path, "a", buffering=1, encoding="utf-8")
|
||||
|
||||
|
||||
def raw():
|
||||
with open(path, "rb") as handle:
|
||||
return handle.read()
|
||||
|
||||
|
||||
def waiting_for(condition, what):
|
||||
end = time.monotonic() + 90
|
||||
while not condition():
|
||||
if time.monotonic() > end:
|
||||
raise SystemExit("timed out waiting for " + what)
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
def the_blocked_call_of_the_test():
|
||||
waiting_for(lambda: raw().count(b"Timeout (") >= 2, "two dumps of the first test")
|
||||
|
||||
|
||||
parked = threading.Thread(target=threading.Event().wait, name="a-parked-thread", daemon=True)
|
||||
parked.start()
|
||||
|
||||
dog.arm("tests/test_a.py::too_fast_to_be_watched", 3600, file=log)
|
||||
dog.cancel()
|
||||
|
||||
dog.arm("tests/test_a.py::first", 0.1, file=log)
|
||||
first_thread = dog.the_thread().ident
|
||||
the_blocked_call_of_the_test()
|
||||
dog.cancel()
|
||||
size_at_cancel = os.path.getsize(path)
|
||||
|
||||
dog.arm("tests/test_a.py::second", 0.1, file=log)
|
||||
second_thread = dog.the_thread().ident
|
||||
waiting_for(lambda: raw()[size_at_cancel:].count(b"Timeout (") >= 1, "the first dump of the second test")
|
||||
dog.cancel()
|
||||
watchdogs = [t for t in threading.enumerate() if t.name == "invpw-stack-watchdog"]
|
||||
print(json.dumps({"size_at_cancel": size_at_cancel, "first": first_thread, "second": second_thread, "watchdog_threads": len(watchdogs)}))
|
||||
'''
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def run(tmp_path_factory):
|
||||
folder = tmp_path_factory.mktemp("stack_watchdog")
|
||||
script, log = folder / "child.py", folder / "e2e-watchdog.log"
|
||||
script.write_text(CHILD, encoding="utf-8")
|
||||
done = subprocess.run([sys.executable, str(script), str(TESTS), str(log)], capture_output=True, text=True, timeout=180)
|
||||
return done, log.read_bytes() if log.exists() else b""
|
||||
|
||||
|
||||
def test_the_child_ends_well_and_writes_to_neither_stdout_nor_stderr(run):
|
||||
done, _ = run
|
||||
assert done.returncode == 0, done.stderr[-1500:]
|
||||
assert done.stderr == ""
|
||||
assert len(done.stdout.splitlines()) == 1 and json.loads(done.stdout)["watchdog_threads"] == 1, done.stdout
|
||||
|
||||
|
||||
def _lines(raw: bytes) -> str:
|
||||
return raw.decode("utf-8").replace("\r\n", "\n")
|
||||
|
||||
|
||||
def test_a_blocked_test_gets_the_stack_of_every_thread_with_the_header_of_the_log(run):
|
||||
_, raw = run
|
||||
first = _lines(raw).split("--- tests/test_a.py::first ---")[1].split("--- tests/test_a.py::second ---")[0]
|
||||
assert re.search(r"^Timeout \(\d+:\d{2}:\d{2}\)!$", first, re.MULTILINE), first[:600]
|
||||
assert re.search(r"^Thread 0x[0-9a-f]{16} \[a-parked-thread\] \(most recent call first\):$", first, re.MULTILINE), first[:1500]
|
||||
assert re.search(r'^ File ".*child\.py", line \d+ in the_blocked_call_of_the_test$', first, re.MULTILINE), first[:1500]
|
||||
assert first.count("Timeout (") >= 2
|
||||
|
||||
|
||||
def test_a_test_cancelled_before_its_threshold_leaves_its_line_and_no_dump(run):
|
||||
_, raw = run
|
||||
unwatched = _lines(raw).split("--- tests/test_a.py::too_fast_to_be_watched ---")[1].split("--- tests/test_a.py::first ---")[0]
|
||||
assert "Timeout (" not in unwatched and "Thread 0x" not in unwatched
|
||||
|
||||
|
||||
def test_nothing_is_written_for_a_test_after_its_cancel(run):
|
||||
done, raw = run
|
||||
size = json.loads(done.stdout)["size_at_cancel"]
|
||||
before, after = _lines(raw[:size]), _lines(raw[size:])
|
||||
assert after.startswith("\n--- tests/test_a.py::second ---\n"), after[:300]
|
||||
assert "--- tests/test_a.py::first ---" not in after and "--- tests/test_a.py::second ---" not in before
|
||||
|
||||
|
||||
def test_the_second_test_reuses_the_thread_of_the_first(run):
|
||||
done, _ = run
|
||||
result = json.loads(done.stdout)
|
||||
assert result["first"] == result["second"] and result["watchdog_threads"] == 1
|
||||
@@ -47,6 +47,7 @@ ONE_SYSTEM = {
|
||||
"tests/test_juggler_posix_pipe.py": "linux",
|
||||
"tests/test_prefs_composition_arm_on_windows.py": "windows",
|
||||
"tests/test_reaper_on_windows.py": "windows",
|
||||
"tests/test_every_pytest_process_clears_the_gp_fault_error_box_on_windows.py": "windows",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user