Fix flaky test `lazy_user_notes_count_aggregate_spec.rb`
requested to merge 441189-failure-in-ee-spec-lib-gitlab-graphql-aggregations-vulnerabilities into master
What does this MR do and why?
Modifies the lazy_user_notes_count_aggregate_spec.rb
spec to de-duplicate the expected array of ids
.
This is because, as currently written, if FactoryBot
assigns an id of 20
(or 10
or 30
) to the vulnerability
, the spec will fail, making this a flaky spec.
You can see my comment on the issue for a more detailed breakdown of the flakiness
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Hard-code an
id
of20
for thevulnerability
in the specdiff --git a/ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb b/ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb index 43d528d1feb4..19aed5ee4120 100644 --- a/ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb +++ b/ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb @@ -7,7 +7,7 @@ {} end - let(:vulnerability) { create(:vulnerability) } + let(:vulnerability) { create(:vulnerability, id: 20) } describe '#initialize' do it 'adds the vulnerability to the lazy state' do ```
- running the spec without this patch will result in failure:
Failures: 1) Gitlab::Graphql::Aggregations::Vulnerabilities::LazyUserNotesCountAggregate#initialize when there are existing pending_vulnerability_ids uses lazy_user_notes_count_aggregate to collect aggregates Failure/Error: expect(result.lazy_state[:pending_vulnerability_ids]).to match_array expected_ids expected collection contained: [10, 20, 20, 30] actual collection contained: [10, 20, 30] the missing elements were: [20] # ./ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb:35:in `block (4 levels) in <top (required)>' # ./spec/spec_helper.rb:435:in `block (3 levels) in <top (required)>' # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware' # ./spec/spec_helper.rb:426:in `block (2 levels) in <top (required)>'
- running the spec with this patch should all pass
Related to Failure in ee/spec/lib/gitlab/graphql/aggregati... (#441189 - closed) • Michael Becker • 16.10
Edited by Michael Becker