Commit 5cd539b8 authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '224097-flaky-elasticindexerworker-specs-fail-for-400-error-ee-spec-workers' into 'master'

Improve the en/dis-ablement of the ES feature in a flaky test

Closes #224097

See merge request gitlab-org/gitlab!36326
parents 03603d33 8756cf51
...@@ -2,45 +2,52 @@ ...@@ -2,45 +2,52 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ElasticNamespaceIndexerWorker, :elastic do RSpec.describe ElasticNamespaceIndexerWorker do
subject { described_class.new } subject { described_class.new }
before do context 'when ES is disabled' do
stub_ee_application_setting(elasticsearch_indexing: true) before do
stub_ee_application_setting(elasticsearch_limit_indexing: true) stub_ee_application_setting(elasticsearch_indexing: false)
end stub_ee_application_setting(elasticsearch_limit_indexing: false)
end
it 'returns true if ES disabled' do
stub_ee_application_setting(elasticsearch_indexing: false)
expect(Elastic::ProcessInitialBookkeepingService).not_to receive(:backfill_projects!) it 'returns true' do
expect(Elastic::ProcessInitialBookkeepingService).not_to receive(:backfill_projects!)
expect(subject.perform(1, "index")).to be_truthy expect(subject.perform(1, "index")).to be_truthy
end
end end
it 'returns true if limited indexing is not enabled' do context 'when ES is enabled', :elastic do
stub_ee_application_setting(elasticsearch_limit_indexing: false) before do
stub_ee_application_setting(elasticsearch_indexing: true)
stub_ee_application_setting(elasticsearch_limit_indexing: true)
end
expect(Elastic::ProcessInitialBookkeepingService).not_to receive(:backfill_projects!) it 'returns true if limited indexing is not enabled' do
stub_ee_application_setting(elasticsearch_limit_indexing: false)
expect(subject.perform(1, "index")).to be_truthy expect(Elastic::ProcessInitialBookkeepingService).not_to receive(:backfill_projects!)
end
expect(subject.perform(1, "index")).to be_truthy
end
describe 'indexing and deleting' do describe 'indexing and deleting' do
let_it_be(:namespace) { create :namespace } let_it_be(:namespace) { create :namespace }
let(:projects) { create_list :project, 3, namespace: namespace } let(:projects) { create_list :project, 3, namespace: namespace }
it 'indexes all projects belonging to the namespace' do it 'indexes all projects belonging to the namespace' do
expect(Elastic::ProcessInitialBookkeepingService).to receive(:backfill_projects!).with(*projects) expect(Elastic::ProcessInitialBookkeepingService).to receive(:backfill_projects!).with(*projects)
subject.perform(namespace.id, :index) subject.perform(namespace.id, :index)
end end
it 'deletes all projects belonging to the namespace' do it 'deletes all projects belonging to the namespace' do
args = projects.map { |project| [project.id, project.es_id] } args = projects.map { |project| [project.id, project.es_id] }
expect(ElasticDeleteProjectWorker).to receive(:bulk_perform_async).with(args) expect(ElasticDeleteProjectWorker).to receive(:bulk_perform_async).with(args)
subject.perform(namespace.id, :delete) subject.perform(namespace.id, :delete)
end
end end
end end
end end
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