Commit 1ccf720c authored by Toon Claes's avatar Toon Claes

Override #save_result to write to tracking database

parent 0b28c8cd
...@@ -3,6 +3,8 @@ module RepositoryCheck ...@@ -3,6 +3,8 @@ module RepositoryCheck
include ApplicationWorker include ApplicationWorker
include RepositoryCheckQueue include RepositoryCheckQueue
prepend ::EE::RepositoryCheck::SingleRepositoryWorker
def perform(project_id) def perform(project_id)
project = Project.find(project_id) project = Project.find(project_id)
result = check(project) result = check(project)
......
module EE
module RepositoryCheck
module SingleRepositoryWorker
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
private
override :save_result
def save_result(project, failure)
# TODO: Check for Geo
# TODO: What if project registry does not exist
project_registry = Geo::ProjectRegistry.find_by(project_id: project.id)
project_registry.update_columns(
last_repository_check_failed: failure,
last_repository_check_at: Time.now
)
end
end
end
end
require 'spec_helper'
describe EE::RepositoryCheck::SingleRepositoryWorker do
set(:project) { create(:project) }
set(:project_registry) { create(:geo_project_registry, project: project) }
set(:secondary) { create(:geo_node) }
subject(:worker) { RepositoryCheck::SingleRepositoryWorker.new }
it 'saves results to Geo registry' do
expect do
worker.perform(project.id)
end.to change { project_registry.reload.last_repository_check_at }
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