Skip to content

Fix flaky set comparison

What does this MR do?

Fix flaky test in ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb identified in gitlab-org/quality/triage-reports#412 (closed)

Example failure:

  1) Gitlab::Graphql::Aggregations::Vulnerabilities::LazyUserNotesCountAggregate#initialize uses lazy_user_notes_count_aggregate to collect aggregates
     Failure/Error: expect(subject.lazy_state[:pending_vulnerability_ids]).to match [10, 20, 30, vulnerability.id]
       expected #<Set: {10, 20, 30}> to match [10, 20, 30, 10]
     # ./ee/spec/lib/gitlab/graphql/aggregations/vulnerabilities/lazy_user_notes_count_aggregate_spec.rb:24:in `block (4 levels) in <main>'
     # ./spec/spec_helper.rb:340:in `block (3 levels) in <main>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:331:in `block (2 levels) in <main>'
     # ./spec/spec_helper.rb:327:in `block (3 levels) in <main>'
     # ./spec/spec_helper.rb:327:in `block (2 levels) in <main>'
     # -e:1:in `<main>'

This may happen as vulnerabilty.id is sequentially generated and it could be one of 10, 20, or 30. When this happens, the test would fail, because it would be comparing a set to an array.

Merge request reports