Commit 35bb453b authored by Stan Hu's avatar Stan Hu

Fix broken master due to pipeline cache refactoring

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27334 broke EE
because an EE-specific port was not created. This commit moves
EE-specific code from the Sidekiq worker to a service object.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/11172
parent 9682aef7
......@@ -60,3 +60,5 @@ module Ci
end
end
end
Ci::ExpirePipelineCacheService.prepend(EE::Ci::ExpirePipelineCacheService)
......@@ -15,5 +15,3 @@ class ExpirePipelineCacheWorker
end
# rubocop: enable CodeReuse/ActiveRecord
end
ExpirePipelineCacheWorker.prepend(EE::ExpirePipelineCacheWorker)
# frozen_string_literal: true
module EE
module Ci
module ExpirePipelineCacheService
extend ::Gitlab::Utils::Override
override :update_etag_cache
def update_etag_cache(pipeline, store)
super
triggered_by = pipeline.triggered_by_pipeline
store.touch(project_pipeline_path(triggered_by.project, triggered_by)) if triggered_by
pipeline.triggered_pipelines.each do |triggered|
store.touch(project_pipeline_path(triggered.project, triggered))
end
end
end
end
end
# frozen_string_literal: true
module EE
module ExpirePipelineCacheWorker
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
override :update_etag_cache
def update_etag_cache(pipeline, store)
super
triggered_by = pipeline.triggered_by_pipeline
store.touch(project_pipeline_path(triggered_by.project, triggered_by)) if triggered_by
pipeline.triggered_pipelines.each do |triggered|
store.touch(project_pipeline_path(triggered.project, triggered))
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Ci::ExpirePipelineCacheService do
let(:pipeline) { create(:ci_empty_pipeline) }
subject { described_class.new }
describe '#perform' do
context 'when pipeline is triggered by other pipeline' do
let(:source) { create(:ci_sources_pipeline, pipeline: pipeline) }
it 'updates the cache of dependent pipeline' do
dependent_pipeline_path = "/#{source.source_project.full_path}/pipelines/#{source.source_pipeline.id}.json"
allow_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch)
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(dependent_pipeline_path)
subject.execute(pipeline)
end
end
context 'when pipeline triggered other pipeline' do
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:source) { create(:ci_sources_pipeline, source_job: build) }
it 'updates the cache of dependent pipeline' do
dependent_pipeline_path = "/#{source.project.full_path}/pipelines/#{source.pipeline.id}.json"
allow_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch)
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(dependent_pipeline_path)
subject.execute(pipeline)
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