Commit c3a5452b authored by Maxime Orefice's avatar Maxime Orefice

Remove test report count endpoint

This MR removes an unused endpoin which has been
rewrote to be more performat by fetching data from
the database.
parent 82678ecc
...@@ -192,12 +192,6 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -192,12 +192,6 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
end end
def test_reports_count
return unless Feature.enabled?(:junit_pipeline_view, project)
render json: { total_count: pipeline.test_reports_count }.to_json
end
private private
def serialize_pipelines def serialize_pipelines
......
...@@ -915,12 +915,6 @@ module Ci ...@@ -915,12 +915,6 @@ module Ci
end end
end end
def test_reports_count
Rails.cache.fetch(['project', project.id, 'pipeline', id, 'test_reports_count'], force: false) do
test_reports.total_count
end
end
def accessibility_reports def accessibility_reports
Gitlab::Ci::Reports::AccessibilityReports.new.tap do |accessibility_reports| Gitlab::Ci::Reports::AccessibilityReports.new.tap do |accessibility_reports|
builds.latest.with_reports(Ci::JobArtifact.accessibility_reports).each do |build| builds.latest.with_reports(Ci::JobArtifact.accessibility_reports).each do |build|
......
...@@ -19,7 +19,6 @@ resources :pipelines, only: [:index, :new, :create, :show, :destroy] do ...@@ -19,7 +19,6 @@ resources :pipelines, only: [:index, :new, :create, :show, :destroy] do
get :failures get :failures
get :status get :status
get :test_report get :test_report
get :test_reports_count
end end
resources :stages, only: [], param: :name, controller: 'pipelines/stages' do resources :stages, only: [], param: :name, controller: 'pipelines/stages' do
......
...@@ -989,76 +989,6 @@ RSpec.describe Projects::PipelinesController do ...@@ -989,76 +989,6 @@ RSpec.describe Projects::PipelinesController do
end end
end end
describe 'GET test_report_count.json' do
subject(:test_reports_count_json) do
get :test_reports_count, params: {
namespace_id: project.namespace,
project_id: project,
id: pipeline.id
},
format: :json
end
context 'when feature is enabled' do
before do
stub_feature_flags(junit_pipeline_view: true)
end
context 'when pipeline does not have a test report' do
let(:pipeline) { create(:ci_pipeline, project: project) }
it 'renders an empty badge counter' do
test_reports_count_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(0)
end
end
context 'when pipeline has a test report' do
let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
it 'renders the badge counter value' do
test_reports_count_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(4)
end
end
context 'when pipeline has corrupt test reports' do
let(:pipeline) { create(:ci_pipeline, project: project) }
before do
job = create(:ci_build, pipeline: pipeline)
create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project)
end
it 'renders 0' do
test_reports_count_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['total_count']).to eq(0)
end
end
end
context 'when feature is disabled' do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
before do
stub_feature_flags(junit_pipeline_view: false)
end
it 'renders empty response' do
test_reports_count_json
expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty
end
end
end
describe 'GET latest' do describe 'GET latest' do
let(:branch_main) { project.repository.branches[0] } let(:branch_main) { project.repository.branches[0] }
let(:branch_secondary) { project.repository.branches[1] } let(:branch_secondary) { project.repository.branches[1] }
......
...@@ -3126,40 +3126,6 @@ RSpec.describe Ci::Pipeline, :mailer do ...@@ -3126,40 +3126,6 @@ RSpec.describe Ci::Pipeline, :mailer do
end end
end end
describe '#test_reports_count', :use_clean_rails_memory_store_caching do
subject { pipeline.test_reports }
context 'when pipeline has multiple builds with test reports' do
let!(:build_rspec) { create(:ci_build, :success, name: 'rspec', pipeline: pipeline, project: project) }
let!(:build_java) { create(:ci_build, :success, name: 'java', pipeline: pipeline, project: project) }
before do
create(:ci_job_artifact, :junit, job: build_rspec, project: project)
create(:ci_job_artifact, :junit_with_ant, job: build_java, project: project)
end
it 'returns test report count equal to test reports total_count' do
expect(subject.total_count).to eq(7)
expect(subject.total_count).to eq(pipeline.test_reports_count)
end
it 'reads from cache when records are cached' do
expect(Rails.cache.fetch(['project', project.id, 'pipeline', pipeline.id, 'test_reports_count'], force: false)).to be_nil
pipeline.test_reports_count
expect(ActiveRecord::QueryRecorder.new { pipeline.test_reports_count }.count).to eq(0)
end
end
context 'when pipeline does not have any builds with test reports' do
it 'returns empty test report count' do
expect(subject.total_count).to eq(0)
expect(subject.total_count).to eq(pipeline.test_reports_count)
end
end
end
describe '#accessibility_reports' do describe '#accessibility_reports' do
subject { pipeline.accessibility_reports } subject { pipeline.accessibility_reports }
......
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