Skip to content

Fix flaky trigger_indexing_worker_spec

What does this MR do and why?

This MR fixes two flaky examples in ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb.

Failures:
  1) Search::Elastic::TriggerIndexingWorker#perform for task: users behaves like an idempotent worker indexes users
     Failure/Error: unscoped { yield relation, index }
       #<Elastic::ProcessInitialBookkeepingService (class)> received :track! with unexpected arguments
         expected: (#<User id:2630 @user858>, #<User id:2631 @user859>, #<User id:2632 @user860>)
              got: (#<User id:2632 @user860>, #<User id:2630 @user858>, #<User id:2631 @user859>)
       Diff:
       @@ -1 +1 @@
       -[#<User id:2630 @user858>, #<User id:2631 @user859>, #<User id:2632 @user860>]
       +[#<User id:2632 @user860>, #<User id:2630 @user858>, #<User id:2631 @user859>]
     Shared Example Group: "an idempotent worker" called from ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:179
     # ./ee/app/workers/search/elastic/trigger_indexing_worker.rb:85:in `block in users'
     # ./app/models/concerns/each_batch.rb:99:in `block (2 levels) in each_batch'
     # ./app/models/concerns/each_batch.rb:99:in `block in each_batch'
     # ./app/models/concerns/each_batch.rb:69:in `step'
     # ./app/models/concerns/each_batch.rb:69:in `each_batch'
     # ./ee/app/workers/search/elastic/trigger_indexing_worker.rb:84:in `users'
     # ./ee/app/workers/search/elastic/trigger_indexing_worker.rb:38:in `perform'
     # ./ee/app/workers/concerns/elastic/indexing_control.rb:34:in `perform'
     # ./ee/app/workers/concerns/geo/skip_secondary.rb:14:in `perform'
     # ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:9:in `block (2 levels) in <top (required)>'
     # ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:184:in `block (5 levels) in <top (required)>'
     # ./spec/spec_helper.rb:426:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:417:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:413:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:70:in `with_raw_context'
     # ./spec/spec_helper.rb:413:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:260:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/fast_quarantine.rb:22:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
Finished in 35 minutes 6 seconds (files took 1 minute 17.17 seconds to load)
2250 examples, 1 failure, 7 pending
Failed examples:
rspec ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:180 # Search::Elastic::TriggerIndexingWorker#perform for task: users behaves like an idempotent worker indexes users
Failures:
  1) Search::Elastic::TriggerIndexingWorker#perform for task: projects behaves like an idempotent worker indexes projects
     Failure/Error: expect(::Elastic::ProcessInitialBookkeepingService).to receive(:backfill_projects!).with(*projects)
       #<Elastic::ProcessInitialBookkeepingService (class)> received :backfill_projects! with unexpected arguments
         expected: (#<Project id:1058 group443/project-1056>>, #<Project id:1059 group444/project-1057>>, #<Project id:1060 group445/project-1058>>)
              got: (#<Project id:1060 group445/project-1058>>, #<Project id:1058 group443/project-1056>>, #<Project id:1059 group444/project-1057>>)
       Diff:
       @@ -1,4 +1,4 @@
       -[#<Project id:1058 group443/project-1056>>,
       - #<Project id:1059 group444/project-1057>>,
       - #<Project id:1060 group445/project-1058>>]
       +[#<Project id:1060 group445/project-1058>>,
       + #<Project id:1058 group443/project-1056>>,
       + #<Project id:1059 group444/project-1057>>]
     Shared Example Group: "an idempotent worker" called from ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:148
     # ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:155:in `block (5 levels) in <top (required)>'
     # ./spec/spec_helper.rb:426:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:417:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:413:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:70:in `with_raw_context'
     # ./spec/spec_helper.rb:413:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:260:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/fast_quarantine.rb:22:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
Finished in 27 minutes 31 seconds (files took 1 minute 48.89 seconds to load)
2118 examples, 1 failure, 3 pending
Failed examples:
rspec ./ee/spec/workers/search/elastic/trigger_indexing_worker_spec.rb:149 # Search::Elastic::TriggerIndexingWorker#perform for task: projects behaves like an idempotent worker indexes projects

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.

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.

Edited by Dmitry Gruzd

Merge request reports