Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
		
							parent
							
								
									69cab9b048
								
							
						
					
					
						commit
						e290137d5d
					
				|  | @ -15,6 +15,8 @@ module Ci | ||||||
| 
 | 
 | ||||||
|     PLAN_LIMIT_PREFIX = 'ci_max_artifact_size_' |     PLAN_LIMIT_PREFIX = 'ci_max_artifact_size_' | ||||||
| 
 | 
 | ||||||
|  |     InvalidArtifactError = Class.new(StandardError) | ||||||
|  | 
 | ||||||
|     self.table_name = :p_ci_job_artifacts |     self.table_name = :p_ci_job_artifacts | ||||||
|     self.primary_key = :id |     self.primary_key = :id | ||||||
|     self.sequence_name = :ci_job_artifacts_id_seq |     self.sequence_name = :ci_job_artifacts_id_seq | ||||||
|  | @ -243,7 +245,7 @@ module Ci | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       super |       super | ||||||
|     rescue StandardError => e |     rescue InvalidArtifactError => e | ||||||
|       artifact_report&.assign_attributes(status: :faulty, validation_error: e.message) |       artifact_report&.assign_attributes(status: :faulty, validation_error: e.message) | ||||||
| 
 | 
 | ||||||
|       raise e |       raise e | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ module Gitlab | ||||||
|           gzip: ::Gitlab::Ci::DecompressedGzipSizeValidator |           gzip: ::Gitlab::Ci::DecompressedGzipSizeValidator | ||||||
|         }.freeze |         }.freeze | ||||||
| 
 | 
 | ||||||
|         FileDecompressionError = Class.new(StandardError) |         FileDecompressionError = Class.new(::Ci::JobArtifact::InvalidArtifactError) | ||||||
| 
 | 
 | ||||||
|         def initialize(file:, file_format:, max_bytes: DEFAULT_MAX_BYTES) |         def initialize(file:, file_format:, max_bytes: DEFAULT_MAX_BYTES) | ||||||
|           @file = file |           @file = file | ||||||
|  |  | ||||||
|  | @ -925,15 +925,17 @@ RSpec.describe Ci::JobArtifact, feature_category: :job_artifacts do | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     context 'when parsing the junit fails' do |     context 'when parsing the junit fails from size error' do | ||||||
|       before do |       before do | ||||||
|         allow_next_instance_of(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator) do |instance| |         allow_next_instance_of(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator) do |instance| | ||||||
|           allow(instance).to receive(:validate!).and_raise(StandardError) |           allow(instance).to receive(:validate!) | ||||||
|  |             .and_raise(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator::FileDecompressionError) | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       it 'updates the artifact report to failed state' do |       it 'updates the artifact report to failed state' do | ||||||
|         expect { job_artifact.each_blob { |b| } }.to raise_error(StandardError) |         expect { job_artifact.each_blob { |b| } } | ||||||
|  |           .to raise_error(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator::FileDecompressionError) | ||||||
|         expect(job_artifact.artifact_report.status).to eq("faulty") |         expect(job_artifact.artifact_report.status).to eq("faulty") | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  | @ -947,10 +949,11 @@ RSpec.describe Ci::JobArtifact, feature_category: :job_artifacts do | ||||||
|         expect(job_artifact.artifact_report.status).to eq("validated") |         expect(job_artifact.artifact_report.status).to eq("validated") | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       context 'and parsing the junit fails' do |       context 'and parsing the junit fails from size error' do | ||||||
|         before do |         before do | ||||||
|           allow_next_instance_of(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator) do |instance| |           allow_next_instance_of(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator) do |instance| | ||||||
|             allow(instance).to receive(:validate!).and_raise(StandardError) |             allow(instance).to receive(:validate!) | ||||||
|  |               .and_raise(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator::FileDecompressionError) | ||||||
|           end |           end | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|  | @ -960,6 +963,20 @@ RSpec.describe Ci::JobArtifact, feature_category: :job_artifacts do | ||||||
|           expect(job_artifact.artifact_report.status).to eq("faulty") |           expect(job_artifact.artifact_report.status).to eq("faulty") | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|  | 
 | ||||||
|  |       context 'and parsing the junit fails from unknown error' do | ||||||
|  |         before do | ||||||
|  |           allow_next_instance_of(Gitlab::Ci::Artifacts::DecompressedArtifactSizeValidator) do |instance| | ||||||
|  |             allow(instance).to receive(:validate!).and_raise(StandardError) | ||||||
|  |           end | ||||||
|  |         end | ||||||
|  | 
 | ||||||
|  |         it 'updates the artifact report to validated and saves when job artifact saves' do | ||||||
|  |           expect { job_artifact.each_blob { |b| } }.to raise_error(StandardError) | ||||||
|  |           expect { job_artifact.save! }.to change { Ci::JobArtifactReport.count }.by(1) | ||||||
|  |           expect(job_artifact.artifact_report.status).to eq("validated") | ||||||
|  |         end | ||||||
|  |       end | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue