Skip to content

Swallow collection errors in RspecProfiling

What does this MR do?

Prevents connection or other errors when saving an example to our rspec_profiling database from breaking the spec run

Are there points in the code the reviewer needs to double check?

Errors go to the logger with warn level, but don't seem to make it to the build log. Is this a problem? Ideally it would be easy to see if the integration is broken.

Why was this MR needed?

Collection should be on a best-effort basis. It's not acceptable to break our CI rig just because a statistics database is down.

Screenshots (if relevant)

Before:

gitlab-mbp:gitlab lupine$ CI=1 RAILS_ENV=test RSPEC_PROFILING_POSTGRES_URL=postgresql://localhost:5555 bundle exec rspec spec/models/abuse_report_spec.rb:7
Run options: include {:locations=>{"./spec/models/abuse_report_spec.rb"=>[7]}}

  1) AbuseReport should be valid
     Failure/Error: @connection = PGconn.connect(@connection_parameters)

     PG::ConnectionBad:
       could not connect to server: Connection refused
       	Is the server running on host "localhost" (::1) and accepting
       	TCP/IP connections on port 5555?
       could not connect to server: Connection refused
       	Is the server running on host "localhost" (127.0.0.1) and accepting
       	TCP/IP connections on port 5555?
# ...

After:

gitlab-mbp:gitlab lupine$ RAILS_ENV=test CI=1 RSPEC_PROFILING_POSTGRES_URL=postgresql://localhost:5555 bundle exec rspec spec/models/key_spec.rb
rspec_profiling couldn't collect an example: could not connect to server: Connection refused                                                                                                 |  ETA: 00:08:00
	Is the server running on host "localhost" (::1) and accepting
	TCP/IP connections on port 5555?
could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5555?
. Further warnings suppressed.
 24/24 |======================================================>| Time: 00:00:58

Finished in 1 minute 0.23 seconds (files took 1 minute 32.31 seconds to load)
24 examples, 0 failures

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #29005 (closed)

Merge request reports