Skip to content
Snippets Groups Projects
Commit 58a1f0f9 authored by Jan Provaznik's avatar Jan Provaznik
Browse files

Merge branch 'ee-22992-default-sidekiq-to-fake-mode-in-test-env' into 'master'

Change Sidekiq testing mode to `fake` instead of `inline`

See merge request !15479
parents a2f03694 6309f06b
No related branches found
No related tags found
1 merge request!15479Change Sidekiq testing mode to `fake` instead of `inline`
Pipeline #90795240 failed
Showing
with 61 additions and 49 deletions
---
title: Make 'Sidekiq::Testing.fake!' mode as default
merge_request: 31662
author: "@blackst0ne"
type: other
......@@ -357,9 +357,16 @@ However, if a spec makes direct Redis calls, it should mark itself with the
`:clean_gitlab_redis_queues` traits as appropriate.
Sidekiq jobs are typically not run in specs, but this behaviour can be altered
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 `:sidekiq` trait, to
ensure that they are removed once the spec completes.
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
`:sidekiq_inline` trait, to ensure that they are removed once the spec completes.
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)
to all the examples that needed Sidekiq to actually process jobs. Examples with
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
processing of background jobs is needed/expected.
#### Filesystem
......
......@@ -111,7 +111,7 @@
stub_uploads_object_storage(FileUploader)
end
it 'creates the project from project template' do
it 'creates the project from project template', :sidekiq_might_not_need_inline do
post :create, params: { project: templates_params }
created_project = Project.find_by_path('foo')
......
......@@ -2,7 +2,7 @@
require "spec_helper"
describe "Admin sends notification", :js do
describe "Admin sends notification", :js, :sidekiq_might_not_need_inline do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
let(:admin) { create(:admin) }
......
......@@ -169,7 +169,7 @@ def create_merge_request(id, extra_params = {})
{ title: "Production", description: "From issue creation until deploy to production", events_count: 1, median: "5 days" }
]
it 'each stage will have median values' do
it 'each stage will have median values', :sidekiq_might_not_need_inline do
stages = page.all(".stage-nav .stage-median").collect(&:text)
stages.each_with_index do |median, index|
......@@ -177,7 +177,7 @@ def create_merge_request(id, extra_params = {})
end
end
it 'each stage will display the events description when selected' do
it 'each stage will display the events description when selected', :sidekiq_might_not_need_inline do
dummy_stages.each do |stage|
select_stage(stage[:title])
......@@ -185,7 +185,7 @@ def create_merge_request(id, extra_params = {})
end
end
it 'each stage with events will display the stage events list when selected' do
it 'each stage with events will display the stage events list when selected', :sidekiq_might_not_need_inline do
dummy_stages.each do |stage|
select_stage(stage[:title])
......
......@@ -105,7 +105,7 @@
wait_for_requests
end
it 'creates a note with reference and cross references the epic' do
it 'creates a note with reference and cross references the epic', :sidekiq_might_not_need_inline do
page.within('div#notes li.note div.note-text') do
expect(page).to have_content(note_text)
expect(page.find('a')).to have_content(epic.to_reference(full: true))
......@@ -131,7 +131,7 @@
wait_for_requests
end
it 'creates a note with reference and cross references the issue' do
it 'creates a note with reference and cross references the issue', :sidekiq_might_not_need_inline do
page.within('div#notes li.note div.note-text') do
expect(page).to have_content(note_text)
expect(page.find('a')).to have_content(issue.to_reference(full: true))
......
......@@ -49,13 +49,13 @@ def csv
expect(page).to have_content "emailed to #{user.notification_email}"
end
it 'includes a csv attachment' do
it 'includes a csv attachment', :sidekiq_might_not_need_inline do
request_csv
expect(attachment.content_type).to include('text/csv')
end
it 'ignores pagination' do
it 'ignores pagination', :sidekiq_might_not_need_inline do
create_list(:issue, 30, project: project, author: user)
request_csv
......@@ -63,13 +63,13 @@ def csv
expect(csv.count).to eq 31
end
it 'uses filters from issue index' do
it 'uses filters from issue index', :sidekiq_might_not_need_inline do
request_csv(state: :closed)
expect(csv.count).to eq 0
end
it 'ignores sorting from issue index' do
it 'ignores sorting from issue index', :sidekiq_might_not_need_inline do
issue2 = create(:labeled_issue, project: project, author: user, labels: [feature_label])
request_csv(sort: :label_priority)
......@@ -78,7 +78,7 @@ def csv
expect(csv.map { |row| row['Issue ID'] }).to eq expected
end
it 'uses array filters, such as label_name' do
it 'uses array filters, such as label_name', :sidekiq_might_not_need_inline do
issue.update!(labels: [idea_label])
request_csv("label_name[]" => 'Bug')
......
......@@ -70,7 +70,7 @@
let(:traits) { [:with_detached_merge_request_pipeline] }
let(:options) { {} }
it 'shows a warning that fork project cannot create merge request pipelines' do
it 'shows a warning that fork project cannot create merge request pipelines', :sidekiq_might_not_need_inline do
visit project_merge_request_path(project, merge_request)
within('.warning_message') do
......
......@@ -24,7 +24,7 @@ def page_rule_names
wait_for_requests
end
it "shows approval rules from target project" do
it "shows approval rules from target project", :sidekiq_might_not_need_inline do
names = page_rule_names
regular_rules.each_with_index do |rule, idx|
expect(names[idx]).to have_text(rule.name)
......
......@@ -45,7 +45,7 @@
visit project_new_merge_request_path(forked_project, merge_request: { target_branch: 'master', source_branch: 'feature' })
end
it 'allows setting other users as approvers but does not allow setting the current user as an approver, and filters non members from approvers list' do
it 'allows setting other users as approvers but does not allow setting the current user as an approver, and filters non members from approvers list', :sidekiq_might_not_need_inline do
open_modal
open_approver_select
......
......@@ -48,7 +48,7 @@
merge_request_2.reload
end
it 'creates a pipeline for merge request 1' do
it 'creates a pipeline for merge request 1', :sidekiq_might_not_need_inline do
expect(merge_request_1.merge_train.pipeline).to be_merge_request_pipeline
expect(merge_request_1.merge_train.pipeline.user).to eq(maintainer_1)
expect(merge_request_1.merge_train.pipeline.ref).to eq(merge_request_1.train_ref_path)
......@@ -56,7 +56,7 @@
.to eq(project.repository.commit('refs/heads/master').sha)
end
it 'creates a pipeline for merge request 2' do
it 'creates a pipeline for merge request 2', :sidekiq_might_not_need_inline do
expect(merge_request_2.merge_train.pipeline).to be_merge_request_pipeline
expect(merge_request_2.merge_train.pipeline.user).to eq(maintainer_2)
expect(merge_request_2.merge_train.pipeline.ref).to eq(merge_request_2.train_ref_path)
......@@ -70,7 +70,7 @@
end
shared_examples_for 'drops merge request 1 from the merge train' do
it 'drops merge request 1 from the merge train' do
it 'drops merge request 1 from the merge train', :sidekiq_might_not_need_inline do
expect(merge_request_1).to be_opened
expect(merge_request_1.merge_train).to be_nil
expect(merge_request_1.notes.last.note).to eq(system_note)
......@@ -78,7 +78,7 @@
end
shared_examples_for 'has an intact pipeline for merge request 2' do
it 'does not create a new pipeline for merge request 2' do
it 'does not create a new pipeline for merge request 2', :sidekiq_might_not_need_inline do
expect(merge_request_2.all_pipelines.count).to eq(1)
end
......@@ -89,7 +89,7 @@
merge_request_2.reload
end
it 'merges merge request 2' do
it 'merges merge request 2', :sidekiq_might_not_need_inline do
expect(merge_request_2).to be_merged
expect(merge_request_2.metrics.merged_by).to eq(maintainer_2)
expect(merge_request_2.merge_train).to be_nil
......@@ -98,7 +98,7 @@
end
shared_examples_for 're-creates a pipeline for merge request 2' do
it 'has recreated pipeline' do
it 'has recreated pipeline', :sidekiq_might_not_need_inline do
expect(merge_request_2.all_pipelines.count).to eq(2)
expect(merge_request_2.merge_train.pipeline.target_sha)
.to eq(target_branch_sha)
......@@ -111,7 +111,7 @@
merge_request_2.reload
end
it 'merges merge request 2' do
it 'merges merge request 2', :sidekiq_might_not_need_inline do
expect(merge_request_2).to be_merged
expect(merge_request_2.metrics.merged_by).to eq(maintainer_2)
expect(merge_request_2.merge_train).to be_nil
......@@ -127,7 +127,7 @@
merge_request_2.reload
end
it 'merges merge request 1' do
it 'merges merge request 1', :sidekiq_might_not_need_inline do
expect(merge_request_1).to be_merged
expect(merge_request_1.metrics.merged_by).to eq(maintainer_1)
expect(merge_request_1.merge_train).to be_nil
......@@ -194,7 +194,7 @@
end
end
context 'when master got a new commit and pipeline for merge request 1 finished' do
context 'when master got a new commit and pipeline for merge request 1 finished', :sidekiq_might_not_need_inline do
before do
create_file_in_repo(project, 'master', 'master', 'test.txt', 'This is test')
......
......@@ -61,7 +61,7 @@
end
end
context 'when pipeline for merge train succeeds' do
context 'when pipeline for merge train succeeds', :sidekiq_might_not_need_inline do
before do
visit project_merge_request_path(project, merge_request)
merge_request.merge_train.pipeline.builds.map(&:success!)
......
......@@ -35,7 +35,7 @@
end
context 'with logs', :use_clean_rails_memory_store_caching do
it "shows pod logs" do
it "shows pod logs", :sidekiq_might_not_need_inline do
visit logs_project_environment_path(environment.project, environment, pod_name: pod_name)
wait_for_requests
......
......@@ -85,7 +85,7 @@
end
end
it 'creates CI/CD project from repo URL' do
it 'creates CI/CD project from repo URL', :sidekiq_might_not_need_inline do
visit new_project_path
find('#ci-cd-project-tab').click
......
......@@ -75,7 +75,7 @@
Gitlab::Elastic::Helper.refresh_index
end
it "has a pagination" do
it "has a pagination", :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('initial')
......@@ -93,7 +93,7 @@
Gitlab::Elastic::Helper.refresh_index
end
it "has a pagination" do
it "has a pagination", :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('foo')
......@@ -112,7 +112,7 @@
Gitlab::Elastic::Helper.refresh_index
end
it "finds files" do
it "finds files", :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('application.js')
......@@ -153,7 +153,7 @@
Gitlab::Elastic::Helper.refresh_index
end
it "finds files" do
it "finds files", :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('term')
......@@ -171,7 +171,7 @@
Gitlab::Elastic::Helper.refresh_index
end
it "finds commits" do
it "finds commits", :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('add')
......@@ -181,7 +181,7 @@
expect(page).to have_selector('.project-namespace')
end
it 'shows proper page 2 results' do
it 'shows proper page 2 results', :sidekiq_might_not_need_inline do
visit dashboard_projects_path
submit_search('add')
......@@ -207,7 +207,7 @@
submit_search('project')
end
it 'displays result counts for all categories' do
it 'displays result counts for all categories', :sidekiq_might_not_need_inline do
expect(page).to have_content('Projects 1')
expect(page).to have_content('Issues 1')
expect(page).to have_content('Merge requests 0')
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe 'Group elastic search', :js, :elastic do
describe 'Group elastic search', :js, :elastic, :sidekiq_might_not_need_inline do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :wiki_repo, namespace: group) }
......
......@@ -16,7 +16,7 @@
end
describe 'searching' do
it 'finds issues' do
it 'finds issues', :sidekiq_might_not_need_inline do
create(:issue, project: project, title: 'Test searching for an issue')
submit_search('Test')
......@@ -25,7 +25,7 @@
expect(page).to have_selector('.results', text: 'Test searching for an issue')
end
it 'finds merge requests' do
it 'finds merge requests', :sidekiq_might_not_need_inline do
create(:merge_request, source_project: project, target_project: project, title: 'Test searching for an MR')
submit_search('Test')
......@@ -34,7 +34,7 @@
expect(page).to have_selector('.results', text: 'Test searching for an MR')
end
it 'finds milestones' do
it 'finds milestones', :sidekiq_might_not_need_inline do
create(:milestone, project: project, title: 'Test searching for a milestone')
submit_search('Test')
......@@ -43,7 +43,7 @@
expect(page).to have_selector('.results', text: 'Test searching for a milestone')
end
it 'finds wiki pages' do
it 'finds wiki pages', :sidekiq_might_not_need_inline do
project.wiki.create_page('test.md', 'Test searching for a wiki page')
project.wiki.index_wiki_blobs
......@@ -53,7 +53,7 @@
expect(page).to have_selector('.results', text: 'Test searching for a wiki page')
end
it 'finds notes' do
it 'finds notes', :sidekiq_might_not_need_inline do
create(:note, project: project, note: 'Test searching for a comment')
submit_search('Test')
......@@ -62,7 +62,7 @@
expect(page).to have_selector('.results', text: 'Test searching for a comment')
end
it 'finds commits' do
it 'finds commits', :sidekiq_might_not_need_inline do
project.repository.index_commits_and_blobs
submit_search('initial')
......@@ -71,7 +71,7 @@
expect(page).to have_selector('.results', text: 'Initial commit')
end
it 'finds blobs' do
it 'finds blobs', :sidekiq_might_not_need_inline do
project.repository.index_commits_and_blobs
submit_search('def')
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe 'Snippet elastic search', :js, :elastic do
describe 'Snippet elastic search', :js, :elastic, :sidekiq_might_not_need_inline do
let(:public_project) { create(:project, :public) }
let(:authorized_user) { create(:user) }
let(:authorized_project) { create(:project, namespace: authorized_user.namespace) }
......
# frozen_string_literal: true
require 'spec_helper'
describe 'Analytics (JavaScript fixtures)' do
describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
include JavaScriptFixturesHelpers
let(:group) { create(:group)}
......
......@@ -59,7 +59,7 @@
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
it "returns parsed result" do
it "returns parsed result", :sidekiq_might_not_need_inline do
project = create :project, :repository
project.repository.index_commits_and_blobs
......@@ -96,7 +96,7 @@ def es_blob_search
)[:blobs][:results]
end
it 'returns all projects in the result page without causing an N+1' do
it 'returns all projects in the result page without causing an N+1', :sidekiq_might_not_need_inline do
control_count = ActiveRecord::QueryRecorder.new { blob_projects(es_blob_search) }.count
projects = create_list :project, 3, :repository, :public
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment