Commit baf540ed authored by Rémy Coutable's avatar Rémy Coutable

Improve our Sidekiq testing best practices

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 37f94825
...@@ -356,17 +356,22 @@ However, if a spec makes direct Redis calls, it should mark itself with the ...@@ -356,17 +356,22 @@ However, if a spec makes direct Redis calls, it should mark itself with the
`:clean_gitlab_redis_cache`, `:clean_gitlab_redis_shared_state` or `:clean_gitlab_redis_cache`, `:clean_gitlab_redis_shared_state` or
`:clean_gitlab_redis_queues` traits as appropriate. `:clean_gitlab_redis_queues` traits as appropriate.
Sidekiq jobs are typically not run in specs, but this behaviour can be altered #### Background jobs / Sidekiq
in each spec through the use of `perform_enqueued_jobs` blocks.
Any spec that causes Sidekiq jobs to be pushed to Redis should use the By default, Sidekiq jobs are enqueued into a jobs array and aren't processed.
`:sidekiq_inline` trait, to ensure that they are removed once the spec completes. If a test enqueues Sidekiq jobs and need them to be processed, the
`:sidekiq_inline` trait can be used.
The `:sidekiq_might_not_need_inline` trait was added when [Sidekiq inline mode was The `:sidekiq_might_not_need_inline` trait was added when [Sidekiq inline mode was
changed to fake mode](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31662) changed to fake mode](https://gitlab.com/gitlab-org/gitlab/merge_requests/15479)
to all the examples that needed Sidekiq to actually process jobs. Examples with to all the tests that needed Sidekiq to actually process jobs. Tests with
this trait should be either fixed to not rely on Sidekiq processing jobs, or their this trait should be either fixed to not rely on Sidekiq processing jobs, or their
`:sidekiq_might_not_need_inline` trait should be updated to `:sidekiq_inline` if the `:sidekiq_might_not_need_inline` trait should be updated to `:sidekiq_inline` if
processing of background jobs is needed/expected. the processing of background jobs is needed/expected.
NOTE: **Note:**
The usage of `perform_enqueued_jobs` is currently useless since our
workers aren't inheriting from `ApplicationJob` / `ActiveJob::Base`.
#### Filesystem #### Filesystem
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment