Skip to content

Fix test pollution in count_deployments_metric_spec

What does this MR do and why?

This specific spec is leaving around data after it runs. This can cause subsequent jobs to fail under the right ordering of tests. This isn't happening in master right now but this was causing problems for my other MR !125333 (merged) and it seems I'm likely the first to run into this just based on bad luck.

This problem can be reproduced with:

bin/rspec ./spec/lib/gitlab/usage/metrics/instrumentations/count_deployments_metric_spec.rb[1:5:1:1] ./spec/models/ci/pipeline_spec.rb:286

As per our documentation in https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#common-test-setup we should not be using before(:all) to create data but we can instead use before_all which handles the transaction rollback for us automatically.

Changelog: other

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Dylan Griffith

Merge request reports

Loading