diff --git a/gems/gitlab-secret_detection/spec/lib/gitlab/secret_detection/scan_spec.rb b/gems/gitlab-secret_detection/spec/lib/gitlab/secret_detection/scan_spec.rb index 9b20eb3850eeb8b28b1bdb9b04b1bc6f88f113f4..03d4615179f8be5ff8b9f1ede6754dca908b6878 100644 --- a/gems/gitlab-secret_detection/spec/lib/gitlab/secret_detection/scan_spec.rb +++ b/gems/gitlab-secret_detection/spec/lib/gitlab/secret_detection/scan_spec.rb @@ -252,9 +252,23 @@ def new_blob(id:, data:) it "whole secret detection scan operation times out" do scan_timeout_secs = 0.000_001 # 1 micro-sec to intentionally timeout large blob - response = Gitlab::SecretDetection::Response.new(Gitlab::SecretDetection::Status::SCAN_TIMEOUT) - - expect(scan.secrets_scan(blobs, timeout: scan_timeout_secs)).to eq(response) + expected_response = Gitlab::SecretDetection::Response.new(Gitlab::SecretDetection::Status::SCAN_TIMEOUT) + + begin + response = scan.secrets_scan(blobs, timeout: scan_timeout_secs) + expect(response).to eq(expected_response) + rescue ArgumentError + # When RSpec's main process terminates and attempts to clean up child processes upon completion, it terminates + # subprocesses where the scans might be still ongoing. This behavior is not recognized by the + # upstream library (parallel), which manages all forked subprocesses it created for running scans. When the + # upstream library attempts to close its forked subprocesses which already terminated, it raises an + # 'ArgumentError' with the message 'bad signal type NilClass,' resulting in flaky failures in the test + # expectations. + # + # Example: https://gitlab.com/gitlab-org/gitlab/-/jobs/6935051992 + # + puts "skipping the test since the subprocesses forked for SD scanning are terminated by main process" + end end it "one of the blobs times out while others continue to get scanned" do