DEV: Add logging for flaky FinalDestination spec (#19548)

This test occasionally fails in CI. I haven't been able to reproduce the issue locally. This logging will print some extra information when the assertion fails.
This commit is contained in:
David Taylor 2022-12-21 14:40:18 +00:00 committed by GitHub
parent 2031b75055
commit a56e679723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -17,13 +17,17 @@ describe FinalDestination::Resolver do
Addrinfo.stubs(:getaddrinfo).with { |addr| addr == "example.com" }.returns(mock_response) Addrinfo.stubs(:getaddrinfo).with { |addr| addr == "example.com" }.returns(mock_response)
expect { expect {
FinalDestination::Resolver.lookup("sleep.example.com", timeout: 0.001) result = FinalDestination::Resolver.lookup("sleep.example.com", timeout: 0.001)
# If the test gets this far, it failed
puts "Flaky test debug: Result was #{result.inspect}"
}.to raise_error(Timeout::Error) }.to raise_error(Timeout::Error)
start_thread_count = alive_thread_count start_thread_count = alive_thread_count
expect { expect {
FinalDestination::Resolver.lookup("sleep.example.com", timeout: 0.001) result = FinalDestination::Resolver.lookup("sleep.example.com", timeout: 0.001)
# If the test gets this far, it failed
puts "Flaky test debug: Result was #{result.inspect}"
}.to raise_error(Timeout::Error) }.to raise_error(Timeout::Error)
expect(alive_thread_count).to eq(start_thread_count) expect(alive_thread_count).to eq(start_thread_count)