Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
commit7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch)
tree5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/models/ci
parent185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff)
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/bridge_spec.rb93
-rw-r--r--spec/models/ci/build_metadata_spec.rb32
-rw-r--r--spec/models/ci/build_runner_session_spec.rb6
-rw-r--r--spec/models/ci/build_spec.rb121
-rw-r--r--spec/models/ci/build_trace_chunk_spec.rb5
-rw-r--r--spec/models/ci/build_trace_spec.rb4
-rw-r--r--spec/models/ci/pipeline_metadata_spec.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb39
-rw-r--r--spec/models/ci/processable_spec.rb22
-rw-r--r--spec/models/ci/secure_file_spec.rb11
-rw-r--r--spec/models/ci/sources/pipeline_spec.rb4
-rw-r--r--spec/models/ci/stage_spec.rb2
-rw-r--r--spec/models/ci/trigger_request_spec.rb2
-rw-r--r--spec/models/ci/unit_test_spec.rb2
14 files changed, 280 insertions, 65 deletions
diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb
index 44a6bec0130..df24c92149d 100644
--- a/spec/models/ci/bridge_spec.rb
+++ b/spec/models/ci/bridge_spec.rb
@@ -27,6 +27,8 @@ RSpec.describe Ci::Bridge do
it_behaves_like 'has ID tokens', :ci_bridge
+ it_behaves_like 'a retryable job'
+
it 'has one downstream pipeline' do
expect(bridge).to have_one(:sourced_pipeline)
expect(bridge).to have_one(:downstream_pipeline)
@@ -35,18 +37,8 @@ RSpec.describe Ci::Bridge do
describe '#retryable?' do
let(:bridge) { create(:ci_bridge, :success) }
- it 'returns true' do
- expect(bridge.retryable?).to eq(true)
- end
-
- context 'without ci_recreate_downstream_pipeline ff' do
- before do
- stub_feature_flags(ci_recreate_downstream_pipeline: false)
- end
-
- it 'returns false' do
- expect(bridge.retryable?).to eq(false)
- end
+ it 'returns false' do
+ expect(bridge.retryable?).to eq(false)
end
end
@@ -204,6 +196,8 @@ RSpec.describe Ci::Bridge do
end
describe '#downstream_variables' do
+ subject(:downstream_variables) { bridge.downstream_variables }
+
it 'returns variables that are going to be passed downstream' do
expect(bridge.downstream_variables)
.to include(key: 'BRIDGE', value: 'cross')
@@ -309,7 +303,7 @@ RSpec.describe Ci::Bridge do
end
context 'when the pipeline runs from a pipeline schedule' do
- let(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) }
+ let(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) }
let(:pipeline) { create(:ci_pipeline, pipeline_schedule: pipeline_schedule) }
let(:options) do
@@ -328,6 +322,79 @@ RSpec.describe Ci::Bridge do
end
end
end
+
+ context 'when using raw variables' do
+ let(:options) do
+ {
+ trigger: {
+ project: 'my/project',
+ branch: 'master',
+ forward: { yaml_variables: true,
+ pipeline_variables: true }.compact
+ }
+ }
+ end
+
+ let(:yaml_variables) do
+ [
+ {
+ key: 'VAR6',
+ value: 'value6 $VAR1'
+ },
+ {
+ key: 'VAR7',
+ value: 'value7 $VAR1',
+ raw: true
+ }
+ ]
+ end
+
+ let(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) }
+ let(:pipeline) { create(:ci_pipeline, pipeline_schedule: pipeline_schedule) }
+
+ before do
+ create(:ci_pipeline_variable, pipeline: pipeline, key: 'VAR1', value: 'value1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: 'VAR2', value: 'value2 $VAR1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: 'VAR3', value: 'value3 $VAR1', raw: true)
+
+ pipeline_schedule.variables.create!(key: 'VAR4', value: 'value4 $VAR1')
+ pipeline_schedule.variables.create!(key: 'VAR5', value: 'value5 $VAR1', raw: true)
+
+ bridge.yaml_variables.concat(yaml_variables)
+ end
+
+ it 'expands variables according to their raw attributes' do
+ expect(downstream_variables).to contain_exactly(
+ { key: 'BRIDGE', value: 'cross' },
+ { key: 'VAR1', value: 'value1' },
+ { key: 'VAR2', value: 'value2 value1' },
+ { key: 'VAR3', value: 'value3 $VAR1', raw: true },
+ { key: 'VAR4', value: 'value4 value1' },
+ { key: 'VAR5', value: 'value5 $VAR1', raw: true },
+ { key: 'VAR6', value: 'value6 value1' },
+ { key: 'VAR7', value: 'value7 $VAR1', raw: true }
+ )
+ end
+
+ context 'when the FF ci_raw_variables_in_yaml_config is disabled' do
+ before do
+ stub_feature_flags(ci_raw_variables_in_yaml_config: false)
+ end
+
+ it 'ignores the raw attribute' do
+ expect(downstream_variables).to contain_exactly(
+ { key: 'BRIDGE', value: 'cross' },
+ { key: 'VAR1', value: 'value1' },
+ { key: 'VAR2', value: 'value2 value1' },
+ { key: 'VAR3', value: 'value3 value1' },
+ { key: 'VAR4', value: 'value4 value1' },
+ { key: 'VAR5', value: 'value5 value1' },
+ { key: 'VAR6', value: 'value6 value1' },
+ { key: 'VAR7', value: 'value7 value1' }
+ )
+ end
+ end
+ end
end
describe 'metadata support' do
diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb
index 16cff72db64..e728ce0f474 100644
--- a/spec/models/ci/build_metadata_spec.rb
+++ b/spec/models/ci/build_metadata_spec.rb
@@ -182,4 +182,36 @@ RSpec.describe Ci::BuildMetadata do
end
end
end
+
+ describe 'routing table switch' do
+ context 'with ff disabled' do
+ before do
+ stub_feature_flags(ci_partitioning_use_ci_builds_metadata_routing_table: false)
+ end
+
+ it 'uses the legacy table' do
+ expect(described_class.table_name).to eq('ci_builds_metadata')
+ end
+ end
+
+ context 'with ff enabled' do
+ before do
+ stub_feature_flags(ci_partitioning_use_ci_builds_metadata_routing_table: true)
+ end
+
+ it 'uses the routing table' do
+ expect(described_class.table_name).to eq('p_ci_builds_metadata')
+ end
+ end
+ end
+
+ context 'jsonb fields serialization' do
+ it 'changing other fields does not change config_options' do
+ expect { metadata.id = metadata.id }.not_to change(metadata, :changes)
+ end
+
+ it 'accessing config_options does not change it' do
+ expect { metadata.config_options }.not_to change(metadata, :changes)
+ end
+ end
end
diff --git a/spec/models/ci/build_runner_session_spec.rb b/spec/models/ci/build_runner_session_spec.rb
index ed5ed456d7b..9bb8a1bd626 100644
--- a/spec/models/ci/build_runner_session_spec.rb
+++ b/spec/models/ci/build_runner_session_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe Ci::BuildRunnerSession, model: true do
let(:specification) { subject.service_specification(service: service, port: port, path: path, subprotocols: subprotocols) }
it 'returns service proxy url' do
- expect(specification[:url]).to eq "https://localhost/proxy/#{service}/#{port}/#{path}"
+ expect(specification[:url]).to eq "https://gitlab.example.com/proxy/#{service}/#{port}/#{path}"
end
it 'returns default service proxy websocket subprotocol' do
@@ -89,7 +89,7 @@ RSpec.describe Ci::BuildRunnerSession, model: true do
let(:port) { nil }
it 'uses the default port name' do
- expect(specification[:url]).to eq "https://localhost/proxy/#{service}/default_port/#{path}"
+ expect(specification[:url]).to eq "https://gitlab.example.com/proxy/#{service}/default_port/#{path}"
end
end
@@ -97,7 +97,7 @@ RSpec.describe Ci::BuildRunnerSession, model: true do
let(:service) { '' }
it 'uses the service name "build" as default' do
- expect(specification[:url]).to eq "https://localhost/proxy/build/#{port}/#{path}"
+ expect(specification[:url]).to eq "https://gitlab.example.com/proxy/build/#{port}/#{path}"
end
end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 9713734e97a..813b4b3faa6 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -25,6 +25,7 @@ RSpec.describe Ci::Build do
it { is_expected.to have_many(:needs) }
it { is_expected.to have_many(:sourced_pipelines) }
+ it { is_expected.to have_one(:sourced_pipeline) }
it { is_expected.to have_many(:job_variables) }
it { is_expected.to have_many(:report_results) }
it { is_expected.to have_many(:pages_deployments) }
@@ -86,6 +87,8 @@ RSpec.describe Ci::Build do
it_behaves_like 'has ID tokens', :ci_build
+ it_behaves_like 'a retryable job'
+
describe '.manual_actions' do
let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) }
let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) }
@@ -605,8 +608,8 @@ RSpec.describe Ci::Build do
end
end
- describe '#prevent_rollback_deployment?' do
- subject { build.prevent_rollback_deployment? }
+ describe '#outdated_deployment?' do
+ subject { build.outdated_deployment? }
let(:build) { create(:ci_build, :created, :with_deployment, project: project, environment: 'production') }
@@ -624,21 +627,33 @@ RSpec.describe Ci::Build do
it { expect(subject).to be_falsey }
end
- context 'when deployment cannot rollback' do
+ context 'when build is not an outdated deployment' do
before do
- expect(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(false)
+ allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(false)
end
it { expect(subject).to be_falsey }
end
- context 'when build can prevent rollback deployment' do
+ context 'when build is older than the latest deployment and still pending status' do
before do
- expect(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true)
+ allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true)
end
it { expect(subject).to be_truthy }
end
+
+ context 'when build is older than the latest deployment but succeeded once' do
+ let(:build) { create(:ci_build, :success, :with_deployment, project: project, environment: 'production') }
+
+ before do
+ allow(build.deployment).to receive(:older_than_last_successful_deployment?).and_return(true)
+ end
+
+ it 'returns false for allowing rollback' do
+ expect(subject).to be_falsey
+ end
+ end
end
describe '#schedulable?' do
@@ -1316,6 +1331,8 @@ RSpec.describe Ci::Build do
end
context 'hide build token' do
+ let_it_be(:build) { FactoryBot.build(:ci_build, pipeline: pipeline) }
+
let(:data) { "new #{build.token} data" }
it { is_expected.to match(/^new x+ data$/) }
@@ -1606,8 +1623,8 @@ RSpec.describe Ci::Build do
end
describe 'environment' do
- describe '#has_environment?' do
- subject { build.has_environment? }
+ describe '#has_environment_keyword?' do
+ subject { build.has_environment_keyword? }
context 'when environment is defined' do
before do
@@ -1751,7 +1768,7 @@ RSpec.describe Ci::Build do
context 'and start action is defined' do
before do
- build.update!(options: { environment: { action: 'start' } } )
+ build.update!(options: { environment: { action: 'start' } })
end
it { is_expected.to be_truthy }
@@ -1781,7 +1798,7 @@ RSpec.describe Ci::Build do
context 'and stop action is defined' do
before do
- build.update!(options: { environment: { action: 'stop' } } )
+ build.update!(options: { environment: { action: 'stop' } })
end
it { is_expected.to be_truthy }
@@ -2783,16 +2800,6 @@ RSpec.describe Ci::Build do
expect(environment_based_variables_collection).to be_empty
end
- context 'when ci_job_jwt feature flag is disabled' do
- before do
- stub_feature_flags(ci_job_jwt: false)
- end
-
- it 'CI_JOB_JWT is not included' do
- expect(subject.pluck(:key)).not_to include('CI_JOB_JWT')
- end
- end
-
context 'when CI_JOB_JWT generation fails' do
[
OpenSSL::PKey::RSAError,
@@ -3806,6 +3813,26 @@ RSpec.describe Ci::Build do
build.enqueue
end
+
+ it 'assigns the token' do
+ expect { build.enqueue }.to change(build, :token).from(nil).to(an_instance_of(String))
+ end
+
+ context 'with ci_assign_job_token_on_scheduling disabled' do
+ before do
+ stub_feature_flags(ci_assign_job_token_on_scheduling: false)
+ end
+
+ it 'assigns the token on creation' do
+ expect(build.token).to be_present
+ end
+
+ it 'does not change the token when enqueuing' do
+ expect { build.enqueue }.not_to change(build, :token)
+
+ expect(build).to be_pending
+ end
+ end
end
describe 'state transition: pending: :running' do
@@ -5083,6 +5110,60 @@ RSpec.describe Ci::Build do
context 'when CI_DEBUG_TRACE is not in variables' do
it { is_expected.to eq false }
end
+
+ context 'when CI_DEBUG_SERVICES=true is in variables' do
+ context 'when in instance variables' do
+ before do
+ create(:ci_instance_variable, key: 'CI_DEBUG_SERVICES', value: 'true')
+ end
+
+ it { is_expected.to eq true }
+ end
+
+ context 'when in group variables' do
+ before do
+ create(:ci_group_variable, key: 'CI_DEBUG_SERVICES', value: 'true', group: project.group)
+ end
+
+ it { is_expected.to eq true }
+ end
+
+ context 'when in pipeline variables' do
+ before do
+ create(:ci_pipeline_variable, key: 'CI_DEBUG_SERVICES', value: 'true', pipeline: pipeline)
+ end
+
+ it { is_expected.to eq true }
+ end
+
+ context 'when in project variables' do
+ before do
+ create(:ci_variable, key: 'CI_DEBUG_SERVICES', value: 'true', project: project)
+ end
+
+ it { is_expected.to eq true }
+ end
+
+ context 'when in job variables' do
+ before do
+ create(:ci_job_variable, key: 'CI_DEBUG_SERVICES', value: 'true', job: build)
+ end
+
+ it { is_expected.to eq true }
+ end
+
+ context 'when in yaml variables' do
+ before do
+ build.update!(yaml_variables: [{ key: :CI_DEBUG_SERVICES, value: 'true' }])
+ end
+
+ it { is_expected.to eq true }
+ end
+ end
+
+ context 'when CI_DEBUG_SERVICES is not in variables' do
+ it { is_expected.to eq false }
+ end
end
describe '#drop_with_exit_code!' do
diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb
index e08fe196d65..3328ed62f15 100644
--- a/spec/models/ci/build_trace_chunk_spec.rb
+++ b/spec/models/ci/build_trace_chunk_spec.rb
@@ -29,6 +29,11 @@ RSpec.describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state, :clean_git
}[data_store]
end
+ describe 'default attributes' do
+ it { expect(described_class.new.data_store).to eq('redis_trace_chunks') }
+ it { expect(described_class.new(data_store: :fog).data_store).to eq('fog') }
+ end
+
describe 'chunk creation' do
let(:metrics) { spy('metrics') }
diff --git a/spec/models/ci/build_trace_spec.rb b/spec/models/ci/build_trace_spec.rb
index f2df4874b84..907b49dc180 100644
--- a/spec/models/ci/build_trace_spec.rb
+++ b/spec/models/ci/build_trace_spec.rb
@@ -38,9 +38,9 @@ RSpec.describe Ci::BuildTrace do
let(:data) { StringIO.new("UTF-8 dashes here: ā”€ā”€ā”€\nšŸ¤šŸ¤šŸ¤šŸ¤\xF0\x9F\x90\n") }
it 'returns valid UTF-8 data', :aggregate_failures do
- expect(subject.lines[0]).to eq({ offset: 0, content: [{ text: 'UTF-8 dashes here: ā”€ā”€ā”€' }] } )
+ expect(subject.lines[0]).to eq({ offset: 0, content: [{ text: 'UTF-8 dashes here: ā”€ā”€ā”€' }] })
# Each of the dashes is 3 bytes, so we get 19 + 9 + 1 = 29
- expect(subject.lines[1]).to eq({ offset: 29, content: [{ text: 'šŸ¤šŸ¤šŸ¤šŸ¤ļæ½' }] } )
+ expect(subject.lines[1]).to eq({ offset: 29, content: [{ text: 'šŸ¤šŸ¤šŸ¤šŸ¤ļæ½' }] })
end
end
end
diff --git a/spec/models/ci/pipeline_metadata_spec.rb b/spec/models/ci/pipeline_metadata_spec.rb
index 0704cbc8ec1..977c90bcc2a 100644
--- a/spec/models/ci/pipeline_metadata_spec.rb
+++ b/spec/models/ci/pipeline_metadata_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Ci::PipelineMetadata do
it { is_expected.to belong_to(:pipeline) }
describe 'validations' do
- it { is_expected.to validate_length_of(:title).is_at_least(1).is_at_most(255) }
+ it { is_expected.to validate_length_of(:name).is_at_least(1).is_at_most(255) }
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:pipeline) }
end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 42b5210a080..2c945898e61 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it { is_expected.to respond_to :git_author_full_text }
it { is_expected.to respond_to :short_sha }
it { is_expected.to delegate_method(:full_path).to(:project).with_prefix }
- it { is_expected.to delegate_method(:title).to(:pipeline_metadata).allow_nil }
+ it { is_expected.to delegate_method(:name).to(:pipeline_metadata).allow_nil }
describe 'validations' do
it { is_expected.to validate_presence_of(:sha) }
@@ -166,7 +166,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it do
pipeline.status = from_status.to_s
- if from_status != to_status
+ if from_status != to_status || success_to_success?
expect(pipeline.set_status(to_status.to_s))
.to eq(true)
else
@@ -174,6 +174,12 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
.to eq(false), "loopback transitions are not allowed"
end
end
+
+ private
+
+ def success_to_success?
+ from_status == :success && to_status == :success
+ end
end
end
@@ -1601,7 +1607,8 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
describe 'track artifact report' do
- let(:pipeline) { create(:ci_pipeline, :running, :with_test_reports, status: :running, user: create(:user)) }
+ let_it_be(:user) { create(:user) }
+ let_it_be_with_reload(:pipeline) { create(:ci_pipeline, :running, :with_test_reports, :with_coverage_reports, status: :running, user: user) }
context 'when transitioning to completed status' do
%i[drop! skip! succeed! cancel!].each do |command|
@@ -1613,11 +1620,29 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
context 'when pipeline retried from failed to success', :clean_gitlab_redis_shared_state do
- let(:test_event_name) { 'i_testing_test_report_uploaded' }
+ let(:test_event_name_1) { 'i_testing_test_report_uploaded' }
+ let(:test_event_name_2) { 'i_testing_coverage_report_uploaded' }
let(:start_time) { 1.week.ago }
let(:end_time) { 1.week.from_now }
- it 'counts only one report' do
+ it 'counts only one test event report' do
+ expect(Ci::JobArtifacts::TrackArtifactReportWorker).to receive(:perform_async).with(pipeline.id).twice.and_call_original
+
+ Sidekiq::Testing.inline! do
+ pipeline.drop!
+ pipeline.run!
+ pipeline.succeed!
+ end
+
+ unique_pipeline_pass = Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(
+ event_names: test_event_name_1,
+ start_date: start_time,
+ end_date: end_time
+ )
+ expect(unique_pipeline_pass).to eq(1)
+ end
+
+ it 'counts only one coverage event report' do
expect(Ci::JobArtifacts::TrackArtifactReportWorker).to receive(:perform_async).with(pipeline.id).twice.and_call_original
Sidekiq::Testing.inline! do
@@ -1627,7 +1652,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
unique_pipeline_pass = Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(
- event_names: test_event_name,
+ event_names: test_event_name_2,
start_date: start_time,
end_date: end_time
)
@@ -4173,7 +4198,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let(:pipeline) { create(:ci_pipeline) }
let!(:old_job) { create(:ci_build, name: 'rspec', retried: true, pipeline: pipeline) }
let!(:job_without_artifacts) { create(:ci_build, name: 'rspec', pipeline: pipeline) }
- let!(:expected_job) { create(:ci_build, :artifacts, name: 'rspec', pipeline: pipeline ) }
+ let!(:expected_job) { create(:ci_build, :artifacts, name: 'rspec', pipeline: pipeline) }
let!(:different_job) { create(:ci_build, name: 'deploy', pipeline: pipeline) }
subject { pipeline.find_job_with_archive_artifacts('rspec') }
diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb
index a199111b1e3..e62e5f84a6d 100644
--- a/spec/models/ci/processable_spec.rb
+++ b/spec/models/ci/processable_spec.rb
@@ -52,7 +52,11 @@ RSpec.describe Ci::Processable do
let_it_be(:internal_job_variable) { create(:ci_job_variable, job: processable) }
- let(:clone_accessors) { ::Ci::Build.clone_accessors.without(::Ci::Build.extra_accessors) }
+ let(:clone_accessors) do
+ %i[pipeline project ref tag options name allow_failure stage stage_idx trigger_request yaml_variables
+ when environment coverage_regex description tag_list protected needs_attributes job_variables_attributes
+ resource_group scheduling_type ci_stage partition_id id_tokens]
+ end
let(:reject_accessors) do
%i[id status user token_encrypted coverage runner artifacts_expire_at
@@ -77,13 +81,14 @@ RSpec.describe Ci::Processable do
commit_id deployment erased_by_id project_id
runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried failure_reason
- sourced_pipelines artifacts_file_store artifacts_metadata_store
+ sourced_pipelines sourced_pipeline artifacts_file_store artifacts_metadata_store
metadata runner_session trace_chunks upstream_pipeline_id
artifacts_file artifacts_metadata artifacts_size commands
resource resource_group_id processed security_scans author
pipeline_id report_results pending_state pages_deployments
queuing_entry runtime_metadata trace_metadata
- dast_site_profile dast_scanner_profile stage_id].freeze
+ dast_site_profile dast_scanner_profile stage_id dast_site_profiles_build
+ dast_scanner_profiles_build].freeze
end
before_all do
@@ -177,10 +182,7 @@ RSpec.describe Ci::Processable do
Ci::Build.attribute_names.map(&:to_sym) +
Ci::Build.attribute_aliases.keys.map(&:to_sym) +
Ci::Build.reflect_on_all_associations.map(&:name) +
- [:tag_list, :needs_attributes, :job_variables_attributes, :id_tokens] -
- # ToDo: Move EE accessors to ee/
- ::Ci::Build.extra_accessors -
- [:dast_site_profiles_build, :dast_scanner_profiles_build]
+ [:tag_list, :needs_attributes, :job_variables_attributes, :id_tokens]
current_accessors.uniq!
@@ -284,12 +286,6 @@ RSpec.describe Ci::Processable do
end
end
- context 'when the processable is a bridge' do
- subject(:processable) { create(:ci_bridge, pipeline: pipeline) }
-
- it_behaves_like 'retryable processable'
- end
-
context 'when the processable is a build' do
subject(:processable) { create(:ci_build, pipeline: pipeline) }
diff --git a/spec/models/ci/secure_file_spec.rb b/spec/models/ci/secure_file_spec.rb
index 20f64d40865..4413bd8e98b 100644
--- a/spec/models/ci/secure_file_spec.rb
+++ b/spec/models/ci/secure_file_spec.rb
@@ -21,6 +21,15 @@ RSpec.describe Ci::SecureFile do
subject { build(:ci_secure_file, project: create(:project)) }
end
+ describe 'default attributes' do
+ before do
+ allow(Ci::SecureFileUploader).to receive(:default_store).and_return(5)
+ end
+
+ it { expect(described_class.new.file_store).to eq(5) }
+ it { expect(described_class.new(file_store: 3).file_store).to eq(3) }
+ end
+
describe 'validations' do
it { is_expected.to validate_presence_of(:checksum) }
it { is_expected.to validate_presence_of(:file_store) }
@@ -131,7 +140,7 @@ RSpec.describe Ci::SecureFile do
describe '#update_metadata!' do
it 'assigns the expected metadata when a parsable file is supplied' do
file = create(:ci_secure_file, name: 'file1.cer',
- file: CarrierWaveStringFile.new(fixture_file('ci_secure_files/sample.cer') ))
+ file: CarrierWaveStringFile.new(fixture_file('ci_secure_files/sample.cer')))
file.update_metadata!
expect(file.expires_at).to eq(DateTime.parse('2022-04-26 19:20:40'))
diff --git a/spec/models/ci/sources/pipeline_spec.rb b/spec/models/ci/sources/pipeline_spec.rb
index 732dd5c3df3..fdc1c111c40 100644
--- a/spec/models/ci/sources/pipeline_spec.rb
+++ b/spec/models/ci/sources/pipeline_spec.rb
@@ -20,14 +20,14 @@ RSpec.describe Ci::Sources::Pipeline do
context 'loose foreign key on ci_sources_pipelines.source_project_id' do
it_behaves_like 'cleanup by a loose foreign key' do
- let!(:parent) { create(:project) }
+ let!(:parent) { create(:project, namespace: create(:group)) }
let!(:model) { create(:ci_sources_pipeline, source_project: parent) }
end
end
context 'loose foreign key on ci_sources_pipelines.project_id' do
it_behaves_like 'cleanup by a loose foreign key' do
- let!(:parent) { create(:project) }
+ let!(:parent) { create(:project, namespace: create(:group)) }
let!(:model) { create(:ci_sources_pipeline, project: parent) }
end
end
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb
index dd9af33a562..b392ab4ed11 100644
--- a/spec/models/ci/stage_spec.rb
+++ b/spec/models/ci/stage_spec.rb
@@ -389,7 +389,7 @@ RSpec.describe Ci::Stage, :models do
end
context 'without pipeline' do
- subject(:stage) { build(:ci_stage, pipeline: nil) }
+ subject(:stage) { build(:ci_stage, pipeline: nil, project: build_stubbed(:project)) }
it { is_expected.to validate_presence_of(:partition_id) }
diff --git a/spec/models/ci/trigger_request_spec.rb b/spec/models/ci/trigger_request_spec.rb
index 0d462741089..a6e8e8496ac 100644
--- a/spec/models/ci/trigger_request_spec.rb
+++ b/spec/models/ci/trigger_request_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Ci::TriggerRequest do
describe 'validation' do
it 'be invalid if saving a variable' do
- trigger = build(:ci_trigger_request, variables: { TRIGGER_KEY_1: 'TRIGGER_VALUE_1' } )
+ trigger = build(:ci_trigger_request, variables: { TRIGGER_KEY_1: 'TRIGGER_VALUE_1' })
expect(trigger).not_to be_valid
end
diff --git a/spec/models/ci/unit_test_spec.rb b/spec/models/ci/unit_test_spec.rb
index b3180492a36..e35a4ce40da 100644
--- a/spec/models/ci/unit_test_spec.rb
+++ b/spec/models/ci/unit_test_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Ci::UnitTest do
it_behaves_like 'cleanup by a loose foreign key' do
- let!(:parent) { create(:project) }
+ let!(:parent) { create(:project, namespace: create(:group)) }
let!(:model) { create(:ci_unit_test, project: parent) }
end