Skip to content
Snippets Groups Projects
Commit dd04de77 authored by Marc Shaw's avatar Marc Shaw :two:
Browse files

Add temporary logging to the merge train refresh service

MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/179372
parent 1f1b71c5
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!180187Draft: Update dashboard editing to save visualizations directly to the dashboard file,!179372Add logging to merge train refresh service
......@@ -16,6 +16,9 @@ def execute(merge_request)
validate!
pipeline_created = create_pipeline! if merge_train_car.requires_new_pipeline? || require_recreate?
log_running_security_scans
merge! if merge_train_car.mergeable?
success(pipeline_created: pipeline_created.present?)
......@@ -166,5 +169,9 @@ def abort(error)
error(error.message)
end
def log_running_security_scans
Gitlab::AppLogger.warn("Security scans running") if merge_request.running_scan_result_policy_violations.any?
end
end
end
......@@ -296,8 +296,40 @@
end
context 'when the merge request is the first queue' do
let(:policy) { create(:scan_result_policy_read, project: project) }
it_behaves_like 'merges the merge request'
context 'when a security scan is running' do
before do
create(:scan_result_policy_violation, :running, project: project, merge_request: merge_request,
scan_result_policy_read: policy, violation_data: nil)
end
it 'logs that the scan is running' do
project.update!(merge_method: :ff)
project.repository.raw_repository.write_ref(merge_request.train_ref_path, pipeline.sha)
expect(Gitlab::AppLogger).to receive(:warn).with("Security scans running")
subject
end
end
context 'when no scan is running' do
before do
create(:scan_result_policy_violation, :warn, project: project, merge_request: merge_request,
scan_result_policy_read: policy, violation_data: nil)
end
it 'does not log' do
project.update!(merge_method: :ff)
project.repository.raw_repository.write_ref(merge_request.train_ref_path, pipeline.sha)
expect(Gitlab::AppLogger).not_to receive(:warn)
subject
end
end
using RSpec::Parameterized::TableSyntax
where(:merge_method) do
......
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