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-05-09 18:07:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-09 18:07:50 +0300
commitfb19b392e2331e7663c3d65c05aeb81a1db3630d (patch)
treeedec8b9bfc56a39279df88578ccb6da5ca4783b4 /spec
parente4b9c52cc9ca9478d9881d03f31517be46376060 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/sidekiq_cluster/cli_spec.rb26
-rw-r--r--spec/controllers/groups_controller_spec.rb2
-rw-r--r--spec/features/groups/group_settings_spec.rb2
-rw-r--r--spec/frontend/branches/components/delete_branch_modal_spec.js4
-rw-r--r--spec/frontend/cycle_analytics/base_spec.js3
-rw-r--r--spec/frontend/cycle_analytics/value_stream_filters_spec.js54
-rw-r--r--spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js2
-rw-r--r--spec/helpers/invite_members_helper_spec.rb4
-rw-r--r--spec/lib/container_registry/migration_spec.rb14
-rw-r--r--spec/lib/gitlab/background_migration/backfill_artifact_expiry_date_spec.rb82
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/config/entry/root_spec.rb37
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb10
-rw-r--r--spec/lib/gitlab/process_supervisor_spec.rb76
-rw-r--r--spec/metrics_server/metrics_server_spec.rb27
-rw-r--r--spec/migrations/20210413132500_reschedule_artifact_expiry_backfill_again_spec.rb38
-rw-r--r--spec/models/container_repository_spec.rb14
-rw-r--r--spec/models/namespace_spec.rb9
-rw-r--r--spec/requests/api/graphql/ci/config_spec.rb18
-rw-r--r--spec/requests/api/internal/container_registry/migration_spec.rb6
-rw-r--r--spec/requests/api/lint_spec.rb13
-rw-r--r--spec/support/shared_examples/features/inviting_groups_shared_examples.rb2
-rw-r--r--spec/workers/container_registry/migration/enqueuer_worker_spec.rb17
23 files changed, 161 insertions, 301 deletions
diff --git a/spec/commands/sidekiq_cluster/cli_spec.rb b/spec/commands/sidekiq_cluster/cli_spec.rb
index ecad3f6b0bf..223d0c3b0ec 100644
--- a/spec/commands/sidekiq_cluster/cli_spec.rb
+++ b/spec/commands/sidekiq_cluster/cli_spec.rb
@@ -402,32 +402,18 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
end
it 'stops the entire process cluster if one of the workers has been terminated' do
- expect(supervisor).to receive(:alive).and_return(true)
- expect(supervisor).to receive(:supervise).and_yield([2])
expect(MetricsServer).to receive(:start_for_sidekiq).once.and_return(metrics_server_pid)
- expect(Gitlab::ProcessManagement).to receive(:signal_processes).with([42, 99], :TERM)
+ expect(supervisor).to receive(:supervise).and_yield([2, 99])
+ expect(supervisor).to receive(:shutdown)
cli.run(%w(foo))
end
- context 'when the supervisor is alive' do
- it 'restarts the metrics server when it is down' do
- expect(supervisor).to receive(:alive).and_return(true)
- expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
- expect(MetricsServer).to receive(:start_for_sidekiq).twice.and_return(metrics_server_pid)
+ it 'restarts the metrics server when it is down' do
+ expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
+ expect(MetricsServer).to receive(:start_for_sidekiq).twice.and_return(metrics_server_pid)
- cli.run(%w(foo))
- end
- end
-
- context 'when the supervisor is shutting down' do
- it 'does not restart the metrics server' do
- expect(supervisor).to receive(:alive).and_return(false)
- expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
- expect(MetricsServer).to receive(:start_for_sidekiq).once.and_return(metrics_server_pid)
-
- cli.run(%w(foo))
- end
+ cli.run(%w(foo))
end
end
end
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 1a2c2b646a4..d61541ffe90 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -787,7 +787,7 @@ RSpec.describe GroupsController, factory_default: :keep do
end
it 'does not update the attribute' do
- expect { subject }.not_to change { group.namespace_settings.reload.prevent_sharing_groups_outside_hierarchy }
+ expect { subject }.not_to change { group.reload.prevent_sharing_groups_outside_hierarchy }
expect(response).to have_gitlab_http_status(:not_found)
end
diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb
index 50982cb1452..019b094ccb5 100644
--- a/spec/features/groups/group_settings_spec.rb
+++ b/spec/features/groups/group_settings_spec.rb
@@ -223,7 +223,7 @@ RSpec.describe 'Edit group settings' do
check 'group_prevent_sharing_groups_outside_hierarchy'
expect { save_permissions_group }.to change {
- group.reload.namespace_settings.prevent_sharing_groups_outside_hierarchy
+ group.reload.prevent_sharing_groups_outside_hierarchy
}.to(true)
end
diff --git a/spec/frontend/branches/components/delete_branch_modal_spec.js b/spec/frontend/branches/components/delete_branch_modal_spec.js
index 0c6111bda9e..2b8c8d408c4 100644
--- a/spec/frontend/branches/components/delete_branch_modal_spec.js
+++ b/spec/frontend/branches/components/delete_branch_modal_spec.js
@@ -49,7 +49,7 @@ const findForm = () => wrapper.find('form');
describe('Delete branch modal', () => {
const expectedUnmergedWarning =
- 'This branch hasn’t been merged into default. To avoid data loss, consider merging this branch before deleting it.';
+ "This branch hasn't been merged into default. To avoid data loss, consider merging this branch before deleting it.";
afterEach(() => {
wrapper.destroy();
@@ -110,7 +110,7 @@ describe('Delete branch modal', () => {
"You're about to permanently delete the protected branch test_modal.";
const expectedMessageProtected = `${expectedWarningProtected} ${expectedUnmergedWarning}`;
const expectedConfirmationText =
- 'Once you confirm and press Yes, delete protected branch, it cannot be undone or recovered. Please type the following to confirm: test_modal';
+ 'After you confirm and select Yes, delete protected branch, you cannot recover this branch. Please type the following to confirm: test_modal';
beforeEach(() => {
createComponent({ isProtectedBranch: true });
diff --git a/spec/frontend/cycle_analytics/base_spec.js b/spec/frontend/cycle_analytics/base_spec.js
index bdf35f904ed..7b1ef71da63 100644
--- a/spec/frontend/cycle_analytics/base_spec.js
+++ b/spec/frontend/cycle_analytics/base_spec.js
@@ -143,12 +143,9 @@ describe('Value stream analytics component', () => {
expect(findFilters().props()).toEqual({
groupId,
groupPath,
- canToggleAggregation: false,
endDate: createdBefore,
hasDateRangeFilter: true,
hasProjectFilter: false,
- isAggregationEnabled: false,
- isUpdatingAggregationData: false,
selectedProjects: [],
startDate: createdAfter,
});
diff --git a/spec/frontend/cycle_analytics/value_stream_filters_spec.js b/spec/frontend/cycle_analytics/value_stream_filters_spec.js
index f3ae6e6cf76..6e96a6d756a 100644
--- a/spec/frontend/cycle_analytics/value_stream_filters_spec.js
+++ b/spec/frontend/cycle_analytics/value_stream_filters_spec.js
@@ -1,5 +1,4 @@
import { shallowMount } from '@vue/test-utils';
-import { GlToggle } from '@gitlab/ui';
import Daterange from '~/analytics/shared/components/daterange.vue';
import ProjectsDropdownFilter from '~/analytics/shared/components/projects_dropdown_filter.vue';
import FilterBar from '~/cycle_analytics/components/filter_bar.vue';
@@ -30,7 +29,6 @@ describe('ValueStreamFilters', () => {
const findProjectsDropdown = () => wrapper.findComponent(ProjectsDropdownFilter);
const findDateRangePicker = () => wrapper.findComponent(Daterange);
const findFilterBar = () => wrapper.findComponent(FilterBar);
- const findAggregationToggle = () => wrapper.findComponent(GlToggle);
beforeEach(() => {
wrapper = createComponent();
@@ -59,10 +57,6 @@ describe('ValueStreamFilters', () => {
expect(findDateRangePicker().exists()).toBe(true);
});
- it('will not render the aggregation toggle', () => {
- expect(findAggregationToggle().exists()).toBe(false);
- });
-
it('will emit `selectProject` when a project is selected', () => {
findProjectsDropdown().vm.$emit('selected');
@@ -94,52 +88,4 @@ describe('ValueStreamFilters', () => {
expect(findProjectsDropdown().exists()).toBe(false);
});
});
-
- describe('canToggleAggregation = true', () => {
- beforeEach(() => {
- wrapper = createComponent({ isAggregationEnabled: false, canToggleAggregation: true });
- });
-
- it('will render the aggregation toggle', () => {
- expect(findAggregationToggle().exists()).toBe(true);
- });
-
- it('will set the aggregation toggle to the `isAggregationEnabled` value', () => {
- expect(findAggregationToggle().props('value')).toBe(false);
-
- wrapper = createComponent({
- isAggregationEnabled: true,
- canToggleAggregation: true,
- });
-
- expect(findAggregationToggle().props('value')).toBe(true);
- });
-
- it('will emit `toggleAggregation` when the toggle is changed', () => {
- expect(wrapper.emitted('toggleAggregation')).toBeUndefined();
-
- findAggregationToggle().vm.$emit('change', true);
-
- expect(wrapper.emitted('toggleAggregation')).toHaveLength(1);
- expect(wrapper.emitted('toggleAggregation')).toEqual([[true]]);
- });
- });
-
- describe('isUpdatingAggregationData = true', () => {
- beforeEach(() => {
- wrapper = createComponent({ canToggleAggregation: true, isUpdatingAggregationData: true });
- });
-
- it('will disable the aggregation toggle', () => {
- expect(findAggregationToggle().props('disabled')).toBe(true);
- });
-
- it('will not emit `toggleAggregation` when the toggle is changed', () => {
- expect(wrapper.emitted('toggleAggregation')).toBeUndefined();
-
- findAggregationToggle().vm.$emit('change', true);
-
- expect(wrapper.emitted('toggleAggregation')).toBeUndefined();
- });
- });
});
diff --git a/spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js b/spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js
index d4b6b987c69..aa41df438d2 100644
--- a/spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js
+++ b/spec/frontend/vue_shared/components/date_time_picker/date_time_picker_spec.js
@@ -15,7 +15,7 @@ describe('DateTimePicker', () => {
const dropdownToggle = () => wrapper.find('.dropdown-toggle');
const dropdownMenu = () => wrapper.find('.dropdown-menu');
const cancelButton = () => wrapper.find('[data-testid="cancelButton"]');
- const applyButtonElement = () => wrapper.find('button.btn-success').element;
+ const applyButtonElement = () => wrapper.find('button.btn-confirm').element;
const findQuickRangeItems = () => wrapper.findAll('.dropdown-item');
const createComponent = (props) => {
diff --git a/spec/helpers/invite_members_helper_spec.rb b/spec/helpers/invite_members_helper_spec.rb
index 1e439bfbdbb..4d47732e008 100644
--- a/spec/helpers/invite_members_helper_spec.rb
+++ b/spec/helpers/invite_members_helper_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe InviteMembersHelper do
let_it_be(:group) { create(:group) }
before do
- group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: true)
+ group.update!(prevent_sharing_groups_outside_hierarchy: true)
end
it 'provides the correct attributes' do
@@ -45,7 +45,7 @@ RSpec.describe InviteMembersHelper do
context 'when sharing with groups outside the hierarchy is enabled' do
before do
- group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: false)
+ group.update!(prevent_sharing_groups_outside_hierarchy: false)
end
it 'does not return filter attributes' do
diff --git a/spec/lib/container_registry/migration_spec.rb b/spec/lib/container_registry/migration_spec.rb
index 416e39b3aa6..654991fd61a 100644
--- a/spec/lib/container_registry/migration_spec.rb
+++ b/spec/lib/container_registry/migration_spec.rb
@@ -189,4 +189,18 @@ RSpec.describe ContainerRegistry::Migration do
it { is_expected.to eq(false) }
end
end
+
+ describe '.enqueue_twice?' do
+ subject { described_class.enqueue_twice? }
+
+ it { is_expected.to eq(true) }
+
+ context 'feature flag disabled' do
+ before do
+ stub_feature_flags(container_registry_migration_phase2_enqueue_twice: false)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
end
diff --git a/spec/lib/gitlab/background_migration/backfill_artifact_expiry_date_spec.rb b/spec/lib/gitlab/background_migration/backfill_artifact_expiry_date_spec.rb
deleted file mode 100644
index f5d2224747a..00000000000
--- a/spec/lib/gitlab/background_migration/backfill_artifact_expiry_date_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::BackgroundMigration::BackfillArtifactExpiryDate, :migration, schema: 20210301200959 do
- subject(:perform) { migration.perform(1, 99) }
-
- let(:migration) { described_class.new }
- let(:artifact_outside_id_range) { create_artifact!(id: 100, created_at: 1.year.ago, expire_at: nil) }
- let(:artifact_outside_date_range) { create_artifact!(id: 40, created_at: Time.current, expire_at: nil) }
- let(:old_artifact) { create_artifact!(id: 10, created_at: 16.months.ago, expire_at: nil) }
- let(:recent_artifact) { create_artifact!(id: 20, created_at: 1.year.ago, expire_at: nil) }
- let(:artifact_with_expiry) { create_artifact!(id: 30, created_at: 1.year.ago, expire_at: Time.current + 1.day) }
-
- before do
- table(:namespaces).create!(id: 1, name: 'the-namespace', path: 'the-path')
- table(:projects).create!(id: 1, name: 'the-project', namespace_id: 1)
- table(:ci_builds).create!(id: 1, allow_failure: false)
- end
-
- context 'when current date is before the 22nd' do
- before do
- travel_to(Time.zone.local(2020, 1, 1, 0, 0, 0))
- end
-
- it 'backfills the expiry date for old artifacts' do
- expect(old_artifact.reload.expire_at).to eq(nil)
-
- perform
-
- expect(old_artifact.reload.expire_at).to be_within(1.minute).of(Time.zone.local(2020, 4, 22, 0, 0, 0))
- end
-
- it 'backfills the expiry date for recent artifacts' do
- expect(recent_artifact.reload.expire_at).to eq(nil)
-
- perform
-
- expect(recent_artifact.reload.expire_at).to be_within(1.minute).of(Time.zone.local(2021, 1, 22, 0, 0, 0))
- end
- end
-
- context 'when current date is after the 22nd' do
- before do
- travel_to(Time.zone.local(2020, 1, 23, 0, 0, 0))
- end
-
- it 'backfills the expiry date for old artifacts' do
- expect(old_artifact.reload.expire_at).to eq(nil)
-
- perform
-
- expect(old_artifact.reload.expire_at).to be_within(1.minute).of(Time.zone.local(2020, 5, 22, 0, 0, 0))
- end
-
- it 'backfills the expiry date for recent artifacts' do
- expect(recent_artifact.reload.expire_at).to eq(nil)
-
- perform
-
- expect(recent_artifact.reload.expire_at).to be_within(1.minute).of(Time.zone.local(2021, 2, 22, 0, 0, 0))
- end
- end
-
- it 'does not touch artifacts with expiry date' do
- expect { perform }.not_to change { artifact_with_expiry.reload.expire_at }
- end
-
- it 'does not touch artifacts outside id range' do
- expect { perform }.not_to change { artifact_outside_id_range.reload.expire_at }
- end
-
- it 'does not touch artifacts outside date range' do
- expect { perform }.not_to change { artifact_outside_date_range.reload.expire_at }
- end
-
- private
-
- def create_artifact!(**args)
- table(:ci_job_artifacts).create!(**args, project_id: 1, job_id: 1, file_type: 1)
- end
-end
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index 97691504abd..ca336c3ecaa 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do
subject { described_class.nodes.keys }
let(:result) do
- %i[before_script script stage type after_script cache
+ %i[before_script script stage after_script cache
image services only except rules needs variables artifacts
environment coverage retry interruptible timeout release tags
inherit parallel]
diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb
index b9c32bc51be..55ad119ea21 100644
--- a/spec/lib/gitlab/ci/config/entry/root_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
# The purpose of `Root` is have only globally defined configuration.
expect(described_class.nodes.keys)
.to match_array(%i[before_script image services after_script
- variables cache stages types include default workflow])
+ variables cache stages include default workflow])
end
end
end
@@ -55,41 +55,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do
}
end
- context 'when deprecated types/type keywords are defined' do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- let(:hash) do
- { types: %w(test deploy),
- rspec: { script: 'rspec', type: 'test' } }
- end
-
- before do
- root.compose!
- end
-
- it 'returns array of types as stages with a warning' do
- expect(root.jobs_value[:rspec][:stage]).to eq 'test'
- expect(root.stages_value).to eq %w[test deploy]
- expect(root.warnings).to match_array([
- "root `types` is deprecated in 9.0 and will be removed in 15.0.",
- "jobs:rspec `type` is deprecated in 9.0 and will be removed in 15.0."
- ])
- end
-
- it 'logs usage of keywords' do
- expect(Gitlab::AppJsonLogger).to(
- receive(:info)
- .with(event: 'ci_used_deprecated_keyword',
- entry: root[:stages].key.to_s,
- user_id: user.id,
- project_id: project.id)
- )
-
- root.compose!
- end
- end
-
describe '#compose!' do
before do
root.compose!
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index 9b68ee2d6a2..1910057622b 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -630,7 +630,7 @@ module Gitlab
describe 'only / except policies validations' do
context 'when `only` has an invalid value' do
- let(:config) { { rspec: { script: "rspec", type: "test", only: only } } }
+ let(:config) { { rspec: { script: "rspec", stage: "test", only: only } } }
subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute }
@@ -2606,19 +2606,19 @@ module Gitlab
end
context 'returns errors if job stage is not a string' do
- let(:config) { YAML.dump({ rspec: { script: "test", type: 1 } }) }
+ let(:config) { YAML.dump({ rspec: { script: "test", stage: 1 } }) }
- it_behaves_like 'returns errors', 'jobs:rspec:type config should be a string'
+ it_behaves_like 'returns errors', 'jobs:rspec:stage config should be a string'
end
context 'returns errors if job stage is not a pre-defined stage' do
- let(:config) { YAML.dump({ rspec: { script: "test", type: "acceptance" } }) }
+ let(:config) { YAML.dump({ rspec: { script: "test", stage: "acceptance" } }) }
it_behaves_like 'returns errors', 'rspec job: chosen stage does not exist; available stages are .pre, build, test, deploy, .post'
end
context 'returns errors if job stage is not a defined stage' do
- let(:config) { YAML.dump({ stages: %w(build test), rspec: { script: "test", type: "acceptance" } }) }
+ let(:config) { YAML.dump({ stages: %w(build test), rspec: { script: "test", stage: "acceptance" } }) }
it_behaves_like 'returns errors', 'rspec job: chosen stage does not exist; available stages are .pre, build, test, .post'
end
diff --git a/spec/lib/gitlab/process_supervisor_spec.rb b/spec/lib/gitlab/process_supervisor_spec.rb
index 60b127dadda..8356197805c 100644
--- a/spec/lib/gitlab/process_supervisor_spec.rb
+++ b/spec/lib/gitlab/process_supervisor_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe Gitlab::ProcessSupervisor do
let(:health_check_interval_seconds) { 0.1 }
let(:check_terminate_interval_seconds) { 1 }
let(:forwarded_signals) { [] }
+ let(:term_signals) { [] }
let(:process_ids) { [spawn_process, spawn_process] }
def spawn_process
@@ -19,7 +20,8 @@ RSpec.describe Gitlab::ProcessSupervisor do
health_check_interval_seconds: health_check_interval_seconds,
check_terminate_interval_seconds: check_terminate_interval_seconds,
terminate_timeout_seconds: 1 + check_terminate_interval_seconds,
- forwarded_signals: forwarded_signals
+ forwarded_signals: forwarded_signals,
+ term_signals: term_signals
)
end
@@ -29,6 +31,8 @@ RSpec.describe Gitlab::ProcessSupervisor do
rescue Errno::ESRCH
# Ignore if a process wasn't actually alive.
end
+
+ supervisor.stop
end
describe '#supervise' do
@@ -60,7 +64,7 @@ RSpec.describe Gitlab::ProcessSupervisor do
[42] # Fake starting a new process in place of the terminated one.
end
- # Terminate the supervised process.
+ # Terminate a supervised process.
Process.kill('TERM', process_ids.first)
await_condition(sleep_sec: health_check_interval_seconds) do
@@ -71,6 +75,72 @@ RSpec.describe Gitlab::ProcessSupervisor do
expect(Gitlab::ProcessManagement.process_alive?(process_ids.last)).to be(true)
expect(supervisor.supervised_pids).to match_array([process_ids.last, 42])
end
+
+ it 'deduplicates PIDs returned from callback' do
+ expect(Gitlab::ProcessManagement.all_alive?(process_ids)).to be(true)
+ pids_killed = []
+
+ supervisor.supervise(process_ids) do |dead_pids|
+ pids_killed = dead_pids
+ # Fake a new process having the same pid as one that was just terminated.
+ [process_ids.last]
+ end
+
+ # Terminate a supervised process.
+ Process.kill('TERM', process_ids.first)
+
+ await_condition(sleep_sec: health_check_interval_seconds) do
+ pids_killed == [process_ids.first]
+ end
+
+ expect(supervisor.supervised_pids).to contain_exactly(process_ids.last)
+ end
+
+ it 'accepts single PID returned from callback' do
+ expect(Gitlab::ProcessManagement.all_alive?(process_ids)).to be(true)
+ pids_killed = []
+
+ supervisor.supervise(process_ids) do |dead_pids|
+ pids_killed = dead_pids
+ 42
+ end
+
+ # Terminate a supervised process.
+ Process.kill('TERM', process_ids.first)
+
+ await_condition(sleep_sec: health_check_interval_seconds) do
+ pids_killed == [process_ids.first]
+ end
+
+ expect(supervisor.supervised_pids).to contain_exactly(42, process_ids.last)
+ end
+
+ context 'but supervisor has entered shutdown' do
+ it 'does not trigger callback again' do
+ expect(Gitlab::ProcessManagement.all_alive?(process_ids)).to be(true)
+ callback_count = 0
+
+ supervisor.supervise(process_ids) do |dead_pids|
+ callback_count += 1
+
+ Thread.new { supervisor.shutdown }
+
+ [42]
+ end
+
+ # Terminate the supervised processes to trigger more than 1 callback.
+ Process.kill('TERM', process_ids.first)
+ Process.kill('TERM', process_ids.last)
+
+ await_condition(sleep_sec: health_check_interval_seconds * 3) do
+ supervisor.alive == false
+ end
+
+ # Since we shut down the supervisor during the first callback, it should not
+ # be called anymore.
+ expect(callback_count).to eq(1)
+ end
+ end
end
context 'signal handling' do
@@ -82,6 +152,8 @@ RSpec.describe Gitlab::ProcessSupervisor do
end
context 'termination signals' do
+ let(:term_signals) { %i(INT TERM) }
+
context 'when TERM results in timely shutdown of processes' do
it 'forwards them to observed processes without waiting for grace period to expire' do
allow(Gitlab::ProcessManagement).to receive(:any_alive?).and_return(false)
diff --git a/spec/metrics_server/metrics_server_spec.rb b/spec/metrics_server/metrics_server_spec.rb
index 4a3580ed4b1..7cc4f6724c4 100644
--- a/spec/metrics_server/metrics_server_spec.rb
+++ b/spec/metrics_server/metrics_server_spec.rb
@@ -267,28 +267,13 @@ RSpec.describe MetricsServer do # rubocop:disable RSpec/FilePath
end
context 'when the supervisor callback is invoked' do
- context 'and the supervisor is alive' do
- it 'restarts the metrics server' do
- expect(supervisor).to receive(:alive).and_return(true)
- expect(supervisor).to receive(:supervise).and_yield
- expect(Process).to receive(:spawn).with(
- include('METRICS_SERVER_TARGET' => 'puma'), end_with('bin/metrics-server'), anything
- ).twice.and_return(42)
-
- described_class.start_for_puma
- end
- end
+ it 'restarts the metrics server' do
+ expect(supervisor).to receive(:supervise).and_yield
+ expect(Process).to receive(:spawn).with(
+ include('METRICS_SERVER_TARGET' => 'puma'), end_with('bin/metrics-server'), anything
+ ).twice.and_return(42)
- context 'and the supervisor is not alive' do
- it 'does not restart the server' do
- expect(supervisor).to receive(:alive).and_return(false)
- expect(supervisor).to receive(:supervise).and_yield
- expect(Process).to receive(:spawn).with(
- include('METRICS_SERVER_TARGET' => 'puma'), end_with('bin/metrics-server'), anything
- ).once.and_return(42)
-
- described_class.start_for_puma
- end
+ described_class.start_for_puma
end
end
end
diff --git a/spec/migrations/20210413132500_reschedule_artifact_expiry_backfill_again_spec.rb b/spec/migrations/20210413132500_reschedule_artifact_expiry_backfill_again_spec.rb
deleted file mode 100644
index e1dc7487222..00000000000
--- a/spec/migrations/20210413132500_reschedule_artifact_expiry_backfill_again_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-require_migration!
-
-RSpec.describe RescheduleArtifactExpiryBackfillAgain, :migration do
- let(:migration_class) { Gitlab::BackgroundMigration::BackfillArtifactExpiryDate }
- let(:migration_name) { migration_class.to_s.demodulize }
-
- before do
- table(:namespaces).create!(id: 123, name: 'test_namespace', path: 'test_namespace')
- table(:projects).create!(id: 123, name: 'sample_project', path: 'sample_project', namespace_id: 123)
- end
-
- it 'correctly schedules background migrations' do
- first_artifact = create_artifact(job_id: 0, expire_at: nil, created_at: Date.new(2020, 06, 21))
- second_artifact = create_artifact(job_id: 1, expire_at: nil, created_at: Date.new(2020, 06, 21))
- create_artifact(job_id: 2, expire_at: Date.yesterday, created_at: Date.new(2020, 06, 21))
- create_artifact(job_id: 3, expire_at: nil, created_at: Date.new(2020, 06, 23))
-
- Sidekiq::Testing.fake! do
- freeze_time do
- migrate!
-
- expect(BackgroundMigrationWorker.jobs.size).to eq(1)
- expect(migration_name).to be_scheduled_migration_with_multiple_args(first_artifact.id, second_artifact.id)
- end
- end
- end
-
- private
-
- def create_artifact(params)
- table(:ci_builds).create!(id: params[:job_id], project_id: 123)
- table(:ci_job_artifacts).create!(project_id: 123, file_type: 1, **params)
- end
-end
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb
index 7d0dfad91b2..af4e40cecb7 100644
--- a/spec/models/container_repository_spec.rb
+++ b/spec/models/container_repository_spec.rb
@@ -208,9 +208,23 @@ RSpec.describe ContainerRepository, :aggregate_failures do
shared_examples 'queueing the next import' do
it 'starts the worker' do
expect(::ContainerRegistry::Migration::EnqueuerWorker).to receive(:perform_async)
+ expect(::ContainerRegistry::Migration::EnqueuerWorker).to receive(:perform_in)
subject
end
+
+ context 'enqueue_twice feature flag disabled' do
+ before do
+ stub_feature_flags(container_registry_migration_phase2_enqueue_twice: false)
+ end
+
+ it 'starts the worker only once' do
+ expect(::ContainerRegistry::Migration::EnqueuerWorker).to receive(:perform_async)
+ expect(::ContainerRegistry::Migration::EnqueuerWorker).not_to receive(:perform_in)
+
+ subject
+ end
+ end
end
describe '#start_pre_import' do
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index abfde1291cf..4373d9a0b24 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -338,6 +338,15 @@ RSpec.describe Namespace do
describe 'delegate' do
it { is_expected.to delegate_method(:name).to(:owner).with_prefix.with_arguments(allow_nil: true) }
it { is_expected.to delegate_method(:avatar_url).to(:owner).with_arguments(allow_nil: true) }
+ it do
+ is_expected.to delegate_method(:prevent_sharing_groups_outside_hierarchy)
+ .to(:namespace_settings).with_arguments(allow_nil: true)
+ end
+
+ it do
+ is_expected.to delegate_method(:prevent_sharing_groups_outside_hierarchy=)
+ .to(:namespace_settings).with_arguments(allow_nil: true)
+ end
end
describe "Respond to" do
diff --git a/spec/requests/api/graphql/ci/config_spec.rb b/spec/requests/api/graphql/ci/config_spec.rb
index d5ef9fdd783..5f4cc50ad10 100644
--- a/spec/requests/api/graphql/ci/config_spec.rb
+++ b/spec/requests/api/graphql/ci/config_spec.rb
@@ -234,24 +234,6 @@ RSpec.describe 'Query.ciConfig' do
)
end
- context 'when using deprecated keywords' do
- let_it_be(:content) do
- YAML.dump(
- rspec: { script: 'ls', type: 'test' },
- types: ['test']
- )
- end
-
- it 'returns a warning' do
- post_graphql_query
-
- expect(graphql_data['ciConfig']['warnings']).to include(
- 'root `types` is deprecated in 9.0 and will be removed in 15.0.',
- 'jobs:rspec `type` is deprecated in 9.0 and will be removed in 15.0.'
- )
- end
- end
-
context 'when the config file includes other files' do
let_it_be(:content) do
YAML.dump(
diff --git a/spec/requests/api/internal/container_registry/migration_spec.rb b/spec/requests/api/internal/container_registry/migration_spec.rb
index 017ea22a748..db2918e65f1 100644
--- a/spec/requests/api/internal/container_registry/migration_spec.rb
+++ b/spec/requests/api/internal/container_registry/migration_spec.rb
@@ -127,6 +127,12 @@ RSpec.describe API::Internal::ContainerRegistry::Migration, :aggregate_failures
it_behaves_like 'updating the repository migration status', from: 'pre_importing', to: 'import_aborted'
end
+
+ context 'with repository in unabortable migration state' do
+ let(:repository) { create(:container_repository, :import_skipped) }
+
+ it_behaves_like 'returning an error', with_message: 'Wrong migration state (import_skipped)'
+ end
end
end
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb
index 148410ecaa8..5d8ed3dd0f5 100644
--- a/spec/requests/api/lint_spec.rb
+++ b/spec/requests/api/lint_spec.rb
@@ -154,19 +154,6 @@ RSpec.describe API::Lint do
end
end
- context 'with valid .gitlab-ci.yml using deprecated keywords' do
- let(:yaml_content) { { job: { script: 'ls', type: 'test' }, types: ['test'] }.to_yaml }
-
- it 'passes validation but returns warnings' do
- post api('/ci/lint', api_user), params: { content: yaml_content }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['status']).to eq('valid')
- expect(json_response['warnings']).not_to be_empty
- expect(json_response['errors']).to match_array([])
- end
- end
-
context 'with an invalid .gitlab-ci.yml' do
context 'with invalid syntax' do
let(:yaml_content) { 'invalid content' }
diff --git a/spec/support/shared_examples/features/inviting_groups_shared_examples.rb b/spec/support/shared_examples/features/inviting_groups_shared_examples.rb
index f7b0410a0da..4921676a065 100644
--- a/spec/support/shared_examples/features/inviting_groups_shared_examples.rb
+++ b/spec/support/shared_examples/features/inviting_groups_shared_examples.rb
@@ -125,7 +125,7 @@ RSpec.shared_examples 'inviting groups search results' do
context 'when sharing with groups outside the hierarchy is disabled' do
before do
- group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: true)
+ group.update!(prevent_sharing_groups_outside_hierarchy: true)
end
it 'shows only groups within the hierarchy in search results' do
diff --git a/spec/workers/container_registry/migration/enqueuer_worker_spec.rb b/spec/workers/container_registry/migration/enqueuer_worker_spec.rb
index a24b46501e9..0ae31422d12 100644
--- a/spec/workers/container_registry/migration/enqueuer_worker_spec.rb
+++ b/spec/workers/container_registry/migration/enqueuer_worker_spec.rb
@@ -37,9 +37,23 @@ RSpec.describe ContainerRegistry::Migration::EnqueuerWorker, :aggregate_failures
it 're-enqueues the worker' do
expect(described_class).to receive(:perform_async)
+ expect(described_class).to receive(:perform_in).with(7.seconds)
subject
end
+
+ context 'enqueue_twice feature flag disabled' do
+ before do
+ stub_feature_flags(container_registry_migration_phase2_enqueue_twice: false)
+ end
+
+ it 'only enqueues the worker once' do
+ expect(described_class).to receive(:perform_async)
+ expect(described_class).not_to receive(:perform_in)
+
+ subject
+ end
+ end
end
context 'above capacity' do
@@ -49,6 +63,7 @@ RSpec.describe ContainerRegistry::Migration::EnqueuerWorker, :aggregate_failures
it 'does not re-enqueue the worker' do
expect(described_class).not_to receive(:perform_async)
+ expect(described_class).not_to receive(:perform_in).with(7.seconds)
subject
end
@@ -95,6 +110,7 @@ RSpec.describe ContainerRegistry::Migration::EnqueuerWorker, :aggregate_failures
it 'does not re-enqueue the worker' do
expect(described_class).not_to receive(:perform_async)
+ expect(described_class).not_to receive(:perform_in)
subject
end
@@ -142,6 +158,7 @@ RSpec.describe ContainerRegistry::Migration::EnqueuerWorker, :aggregate_failures
it 'does not re-enqueue the worker' do
expect(ContainerRegistry::Migration::EnqueuerWorker).not_to receive(:perform_async)
+ expect(ContainerRegistry::Migration::EnqueuerWorker).not_to receive(:perform_in)
subject
end