Skip to content

Fix flaky test "branches_spec.rb"

What does this MR do and why?

What

The branches_spec.rb:163 is a flasky test that occasionally throws an error:

  1. https://gitlab.com/gitlab-org/gitlab/-/jobs/4494862995#L1469 (succeeded after the second retry)
  2. https://jihulab.com/gitlab-cn/gitlab/-/jobs/8143166

Current MR is used to fix it.

Why flasky

This test is used to check if there is an N+1 query problem by comparing the impact of the number of branches on the number of SQL queries.

Unfortunately, there are dozens of SQL queries, most of them have nothing to do with branches queries. And the number of queries will be affected by other test cases (I guess it is related to caching).

Considering the remarkable characteristics of N+1 query problem, we can easily solve the flaky problem by increasing the number of query objects.

How big is the performance impact on the test?

Before

$ bin/rspec spec/features/projects/branches_spec.rb:163
Finished in 13.8 seconds

After

$ bin/rspec spec/features/projects/branches_spec.rb:163
Finished in 15.3 seconds

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

Execute this command:

$ bin/rspec ./spec/features/projects/branches_spec.rb:134

MR acceptance checklist

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


cc @mtan-gitlab @icbd

Edited by Zhiyuan Lu

Merge request reports