Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-19 21:09:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-19 21:09:10 +0300
commit33795139ea8e72756bee3675b4e16387425e6ab1 (patch)
tree3ca568fca61482e57810ee30ad5ce4b964a82c4e /spec/workers
parentc7e385e282bcb8505589bce526e692b7bb819ffa (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/background_migration_worker_spec.rb10
-rw-r--r--spec/workers/expire_job_cache_worker_spec.rb30
2 files changed, 30 insertions, 10 deletions
diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb
index aae6fa02a0c..2b2ffc9f5b9 100644
--- a/spec/workers/background_migration_worker_spec.rb
+++ b/spec/workers/background_migration_worker_spec.rb
@@ -11,7 +11,7 @@ describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do
end
end
- describe '.perform' do
+ describe '#perform' do
it 'performs a background migration' do
expect(Gitlab::BackgroundMigration)
.to receive(:perform)
@@ -52,6 +52,14 @@ describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do
worker.perform('Foo', [10, 20])
end
+
+ it 'sets the class that will be executed as the caller_id' do
+ expect(Gitlab::BackgroundMigration).to receive(:perform) do
+ expect(Labkit::Context.current.to_h).to include('meta.caller_id' => 'Foo')
+ end
+
+ worker.perform('Foo', [10, 20])
+ end
end
describe '#healthy_database?' do
diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb
index eeab304d926..ebca7020ee5 100644
--- a/spec/workers/expire_job_cache_worker_spec.rb
+++ b/spec/workers/expire_job_cache_worker_spec.rb
@@ -6,20 +6,32 @@ describe ExpireJobCacheWorker do
set(:pipeline) { create(:ci_empty_pipeline) }
let(:project) { pipeline.project }
- subject { described_class.new }
-
describe '#perform' do
context 'with a job in the pipeline' do
let(:job) { create(:ci_build, pipeline: pipeline) }
+ let(:job_args) { job.id }
+
+ include_examples 'an idempotent worker' do
+ it 'invalidates Etag caching for the job path' do
+ pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
+ job_path = "/#{project.full_path}/builds/#{job.id}.json"
+
+ spy_store = Gitlab::EtagCaching::Store.new
+
+ allow(Gitlab::EtagCaching::Store).to receive(:new) { spy_store }
- it 'invalidates Etag caching for the job path' do
- pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
- job_path = "/#{project.full_path}/builds/#{job.id}.json"
+ expect(spy_store).to receive(:touch)
+ .exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
+ .with(pipeline_path)
+ .and_call_original
- expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(pipeline_path)
- expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(job_path)
+ expect(spy_store).to receive(:touch)
+ .exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
+ .with(job_path)
+ .and_call_original
- subject.perform(job.id)
+ subject
+ end
end
end
@@ -27,7 +39,7 @@ describe ExpireJobCacheWorker do
it 'does not change the etag store' do
expect(Gitlab::EtagCaching::Store).not_to receive(:new)
- subject.perform(9999)
+ perform_multiple(9999)
end
end
end