Assert the exit in the replication status rake spec

What does this MR do and why?

The gitlab:geo:check_replication_verification_status examples wrapped themselves in an around hook that rescued SystemExit. The task always ends in exit or abort, so the exception escaped the expect { run_task } block before the output matcher compared anything, and the hook then swallowed it outside the example. RSpec reported every success and error message assertion as passing regardless of what the task printed. Only the "exits with a 1" example was real, because it asserted on the exception itself.

This MR drops the hook and chains .and raise_error(SystemExit) onto each output expectation, the pattern the same file already uses for gitlab:geo:update_primary_node_url, and asserts the status code on the success path. The abort_execution matcher was left for the abort cases that already use it.

References

Differences

Before: Changing the task's success message to anything else leaves the spec green.

After: The output assertions run and fail on a wrong message.

How to set up and validate locally

  1. Run bundle exec rspec ee/spec/tasks/gitlab/geo_rake_spec.rb -e check_replication_verification_status.
  2. Temporarily edit the SUCCESS - Replication is up-to-date. string in ee/lib/tasks/gitlab/geo.rake; on master the spec still passes, with this MR it fails.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jeston Singh

Merge request reports

Loading
Loading