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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 13:17:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-12 13:17:34 +0300
commit3a6238c2e23454c462ccd229b1802583e657bfd0 (patch)
tree808c1151b9916516e41cea4869791cbf3dab345f /spec
parentc301cf0ca5fbb998c22be5d8033e77be4bf0a451 (diff)
Add latest changes from gitlab-org/gitlab@14-9-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb4
-rw-r--r--spec/lib/gitlab/import_export/command_line_util_spec.rb1
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb44
-rw-r--r--spec/services/ci/register_job_service_spec.rb19
-rw-r--r--spec/services/ci/update_build_queue_service_spec.rb22
-rw-r--r--spec/tasks/gitlab/background_migrations_rake_spec.rb11
6 files changed, 99 insertions, 2 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index d71a4f81901..9505da8fd12 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -2211,7 +2211,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
table_name: :events,
column_name: :id,
- job_arguments: [["id"], ["id_convert_to_bigint"]]
+ job_arguments: [["id"], ["id_convert_to_bigint"], nil]
}
end
@@ -2226,7 +2226,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
"\n\n" \
"Finalize it manualy by running" \
"\n\n" \
- "\tsudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,events,id,'[[\"id\"]\\, [\"id_convert_to_bigint\"]]']" \
+ "\tsudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,events,id,'[[\"id\"]\\,[\"id_convert_to_bigint\"]\\,null]']" \
"\n\n" \
"For more information, check the documentation" \
"\n\n" \
diff --git a/spec/lib/gitlab/import_export/command_line_util_spec.rb b/spec/lib/gitlab/import_export/command_line_util_spec.rb
index f5913da08ba..59d97357045 100644
--- a/spec/lib/gitlab/import_export/command_line_util_spec.rb
+++ b/spec/lib/gitlab/import_export/command_line_util_spec.rb
@@ -167,6 +167,7 @@ RSpec.describe Gitlab::ImportExport::CommandLineUtil do
context 'for object_storage uri' do
let(:enabled_object_storage_setting) do
{
+ 'enabled' => true,
'object_store' =>
{
'enabled' => true,
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 57b0297a0a0..8f505606e04 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -43,6 +43,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
let(:import_url) { "#{host}/external-diffs/merge_request_diffs/mr-1/diff-1" }
let(:enabled_object_storage_setting) do
{
+ 'enabled' => true,
'object_store' =>
{
'enabled' => true,
@@ -81,6 +82,49 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
let(:expected_hostname) { nil }
end
end
+
+ context 'when LFS object storage is enabled' do
+ let(:lfs_config) do
+ {
+ 'enabled' => lfs_enabled,
+ # This nesting of Settingslogic is necessary to trigger the bug
+ 'object_store' => Settingslogic.new({ 'enabled' => true })
+ }
+ end
+
+ let(:config) do
+ {
+ 'gitlab' => Gitlab.config.gitlab,
+ 'repositories' => { 'storages' => { 'default' => 'test' } },
+ 'lfs' => Settingslogic.new(lfs_config)
+ }
+ end
+
+ let(:host) { 'http://127.0.0.1:9000' }
+ let(:settings) { Settingslogic.new(config) }
+
+ before do
+ allow(Gitlab).to receive(:config).and_return(settings)
+ # Triggers Settingslogic bug: https://gitlab.com/gitlab-org/gitlab/-/issues/286873
+ settings.repositories.storages.default
+ end
+
+ context 'when LFS is disabled' do
+ let(:lfs_enabled) { false }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(described_class::BlockedUrlError)
+ end
+ end
+
+ context 'when LFS is enabled with no connection endpoint' do
+ let(:lfs_enabled) { true }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(described_class::BlockedUrlError)
+ end
+ end
+ end
end
context 'when allow_object_storage is false' do
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index 2127a4fa0fc..245118e71fa 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -771,6 +771,25 @@ module Ci
include_examples 'handles runner assignment'
end
+
+ context 'when a conflicting data is stored in denormalized table' do
+ let!(:specific_runner) { create(:ci_runner, :project, projects: [project], tag_list: %w[conflict]) }
+ let!(:pending_job) { create(:ci_build, :pending, :queued, pipeline: pipeline, tag_list: %w[conflict]) }
+
+ before do
+ pending_job.update_column(:status, :running)
+ end
+
+ it 'removes queuing entry upon build assignment attempt' do
+ expect(pending_job.reload).to be_running
+ expect(pending_job.queuing_entry).to be_present
+
+ result = described_class.new(specific_runner).execute
+
+ expect(result).not_to be_valid
+ expect(pending_job.reload.queuing_entry).not_to be_present
+ end
+ end
end
context 'when not using pending builds table' do
diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb
index ef43866d8d4..d3f537a1aa0 100644
--- a/spec/services/ci/update_build_queue_service_spec.rb
+++ b/spec/services/ci/update_build_queue_service_spec.rb
@@ -103,6 +103,28 @@ RSpec.describe Ci::UpdateBuildQueueService do
end
end
end
+
+ describe '#remove!' do
+ context 'when pending build exists' do
+ before do
+ create(:ci_pending_build, build: build, project: build.project)
+ end
+
+ it 'removes pending build in a transaction' do
+ dequeued = subject.remove!(build)
+
+ expect(dequeued).to eq build.id
+ end
+ end
+
+ context 'when pending build does not exist' do
+ it 'does nothing if there is no pending build to remove' do
+ dequeued = subject.remove!(build)
+
+ expect(dequeued).to be_nil
+ end
+ end
+ end
end
describe 'shared runner builds tracking' do
diff --git a/spec/tasks/gitlab/background_migrations_rake_spec.rb b/spec/tasks/gitlab/background_migrations_rake_spec.rb
index 98920df71ee..36623e86f27 100644
--- a/spec/tasks/gitlab/background_migrations_rake_spec.rb
+++ b/spec/tasks/gitlab/background_migrations_rake_spec.rb
@@ -42,6 +42,17 @@ RSpec.describe 'gitlab:background_migrations namespace rake tasks' do
end
end
+ context 'with a null parameter' do
+ let(:arguments) { %w[ProjectNamespaces::BackfillProjectNamespaces projects id] + ['[null\, "up"]'] }
+
+ it 'finalizes the matching migration' do
+ expect(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner).to receive(:finalize)
+ .with('ProjectNamespaces::BackfillProjectNamespaces', 'projects', 'id', [nil, "up"], connection: connection)
+
+ expect { finalize_task }.to output(/Done/).to_stdout
+ end
+ end
+
context 'when multiple database feature is enabled' do
subject(:finalize_task) { run_rake_task("gitlab:background_migrations:finalize:#{ci_database_name}", *arguments) }