diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /spec/db | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'spec/db')
-rw-r--r-- | spec/db/development/create_base_work_item_types_spec.rb | 2 | ||||
-rw-r--r-- | spec/db/docs_spec.rb | 41 | ||||
-rw-r--r-- | spec/db/migration_spec.rb | 2 | ||||
-rw-r--r-- | spec/db/production/create_base_work_item_types_spec.rb | 2 | ||||
-rw-r--r-- | spec/db/schema_spec.rb | 20 |
5 files changed, 40 insertions, 27 deletions
diff --git a/spec/db/development/create_base_work_item_types_spec.rb b/spec/db/development/create_base_work_item_types_spec.rb index 914b84d8668..7652ccdc487 100644 --- a/spec/db/development/create_base_work_item_types_spec.rb +++ b/spec/db/development/create_base_work_item_types_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Create base work item types in development' do +RSpec.describe 'Create base work item types in development', feature_category: :team_planning do subject { load Rails.root.join('db', 'fixtures', 'development', '001_create_base_work_item_types.rb') } it_behaves_like 'work item base types importer' diff --git a/spec/db/docs_spec.rb b/spec/db/docs_spec.rb index 5960b8bebcc..8d4cb3ac5ef 100644 --- a/spec/db/docs_spec.rb +++ b/spec/db/docs_spec.rb @@ -2,13 +2,6 @@ require 'spec_helper' -# This list is used to provide temporary exceptions for feature categories -# that are transitioning and not yet in the feature_categories.yml file -# any additions here should be accompanied by a link to an issue link -VALID_FEATURE_CATEGORIES = [ - 'jihu' # https://gitlab.com/gitlab-org/database-team/team-tasks/-/issues/192 -].freeze - RSpec.shared_examples 'validate dictionary' do |objects, directory_path, required_fields| context 'for each object' do let(:directory_path) { directory_path } @@ -32,6 +25,19 @@ RSpec.shared_examples 'validate dictionary' do |objects, directory_path, require end end + # This list is used to provide temporary exceptions for feature categories + # that are transitioning and not yet in the feature_categories.yml file + # any additions here should be accompanied by a link to an issue link + let(:valid_feature_categories) do + [ + 'jihu' # https://gitlab.com/gitlab-org/database-team/team-tasks/-/issues/192 + ] + end + + let(:all_feature_categories) do + YAML.load_file(Rails.root.join('config/feature_categories.yml')) + valid_feature_categories + end + let(:objects_without_metadata) do objects.reject { |t| metadata.has_key?(t) } end @@ -68,9 +74,15 @@ RSpec.shared_examples 'validate dictionary' do |objects, directory_path, require end it 'has a valid feature category' do + message = <<~TEXT.chomp + Please use a category from https://about.gitlab.com/handbook/product/categories/#categories-a-z + + Table metadata files with an invalid feature category + TEXT + expect(objects_with_invalid_feature_category).to be_empty, object_metadata_errors( - 'Table metadata files with an invalid feature category', - :error, + message, + :invalid_feature_category, objects_with_invalid_feature_category ) end @@ -102,11 +114,10 @@ RSpec.shared_examples 'validate dictionary' do |objects, directory_path, require Rails.root.join(object_metadata_file(object_name)) end - def feature_categories_valid?(object_feature_categories) + def invalid_feature_categories(object_feature_categories) return false unless object_feature_categories.present? - all_feature_categories = YAML.load_file(Rails.root.join('config/feature_categories.yml')) + VALID_FEATURE_CATEGORIES - object_feature_categories.all? { |category| all_feature_categories.include?(category) } + object_feature_categories - all_feature_categories end def load_object_metadata(required_fields, object_name) @@ -125,10 +136,8 @@ RSpec.shared_examples 'validate dictionary' do |objects, directory_path, require if required_fields.include?(:feature_categories) object_feature_categories = result.dig(:metadata, :feature_categories) - unless feature_categories_valid?(object_feature_categories) - result[:invalid_feature_category] = - "invalid feature category: #{object_feature_categories}" \ - "Please use a category from https://about.gitlab.com/handbook/product/categories/#categories-a-z" + if (invalid = invalid_feature_categories(object_feature_categories)).any? + result[:invalid_feature_category] = "invalid feature category: #{invalid.join(', ')}" end end rescue Psych::SyntaxError => ex diff --git a/spec/db/migration_spec.rb b/spec/db/migration_spec.rb index a5449c6dccd..b7a4a302290 100644 --- a/spec/db/migration_spec.rb +++ b/spec/db/migration_spec.rb @@ -9,7 +9,7 @@ RSpec.describe 'Migrations Validation', feature_category: :database do let(:all_migration_classes) do { 2022_12_01_02_15_00.. => Gitlab::Database::Migration[2.1], - 2022_01_26_21_06_58.. => Gitlab::Database::Migration[2.0], + 2022_01_26_21_06_58..2023_01_11_12_45_12 => Gitlab::Database::Migration[2.0], 2021_09_01_15_33_24..2022_04_25_12_06_03 => Gitlab::Database::Migration[1.0], 2021_05_31_05_39_16..2021_09_01_15_33_24 => ActiveRecord::Migration[6.1], ..2021_05_31_05_39_16 => ActiveRecord::Migration[6.0] diff --git a/spec/db/production/create_base_work_item_types_spec.rb b/spec/db/production/create_base_work_item_types_spec.rb index 81d80104bb4..f6c3b0f6395 100644 --- a/spec/db/production/create_base_work_item_types_spec.rb +++ b/spec/db/production/create_base_work_item_types_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Create base work item types in production' do +RSpec.describe 'Create base work item types in production', feature_category: :team_planning do subject { load Rails.root.join('db', 'fixtures', 'production', '003_create_base_work_item_types.rb') } it_behaves_like 'work item base types importer' diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index 7f3cab55d5a..6019f10eeeb 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -10,7 +10,10 @@ RSpec.describe 'Database schema', feature_category: :database do let(:columns_name_with_jsonb) { retrieve_columns_name_with_jsonb } IGNORED_INDEXES_ON_FKS = { - slack_integrations_scopes: %w[slack_api_scope_id] + slack_integrations_scopes: %w[slack_api_scope_id], + # Will be removed in https://gitlab.com/gitlab-org/gitlab/-/issues/391312 + approval_project_rules: %w[scan_result_policy_id], + approval_merge_request_rules: %w[scan_result_policy_id] }.with_indifferent_access.freeze TABLE_PARTITIONS = %w[ci_builds_metadata].freeze @@ -33,26 +36,26 @@ RSpec.describe 'Database schema', feature_category: :database do chat_names: %w[chat_id team_id user_id integration_id], chat_teams: %w[team_id], ci_build_needs: %w[partition_id], - ci_build_pending_states: %w[partition_id], + ci_build_pending_states: %w[partition_id build_id], ci_build_report_results: %w[partition_id], - ci_build_trace_chunks: %w[partition_id], + ci_build_trace_chunks: %w[partition_id build_id], ci_build_trace_metadata: %w[partition_id], ci_builds: %w[erased_by_id trigger_request_id partition_id], - ci_builds_runner_session: %w[partition_id], - p_ci_builds_metadata: %w[partition_id runner_machine_id], # NOTE: FK will be added in follow-up https://gitlab.com/gitlab-org/gitlab/-/merge_requests/108167 + ci_builds_runner_session: %w[partition_id build_id], + p_ci_builds_metadata: %w[partition_id], ci_job_artifacts: %w[partition_id], ci_job_variables: %w[partition_id], ci_namespace_monthly_usages: %w[namespace_id], ci_pending_builds: %w[partition_id], ci_pipeline_variables: %w[partition_id], ci_pipelines: %w[partition_id], - ci_resources: %w[partition_id], + ci_resources: %w[partition_id build_id], ci_runner_projects: %w[runner_id], ci_running_builds: %w[partition_id], ci_sources_pipelines: %w[partition_id source_partition_id], ci_stages: %w[partition_id], ci_trigger_requests: %w[commit_id], - ci_unit_test_failures: %w[partition_id], + ci_unit_test_failures: %w[partition_id build_id], cluster_providers_aws: %w[security_group_id vpc_id access_key_id], cluster_providers_gcp: %w[gcp_project_id operation_id], compliance_management_frameworks: %w[group_id], @@ -80,6 +83,7 @@ RSpec.describe 'Database schema', feature_category: :database do ldap_group_links: %w[group_id], members: %w[source_id created_by_id], merge_requests: %w[last_edited_by_id state_id], + merge_requests_compliance_violations: %w[target_project_id], merge_request_diff_commits: %w[commit_author_id committer_id], namespaces: %w[owner_id parent_id], notes: %w[author_id commit_id noteable_id updated_by_id resolved_by_id confirmed_by_id discussion_id], @@ -89,6 +93,7 @@ RSpec.describe 'Database schema', feature_category: :database do oauth_applications: %w[owner_id], product_analytics_events_experimental: %w[event_id txn_id user_id], project_build_artifacts_size_refreshes: %w[last_job_artifact_id], + project_data_transfers: %w[project_id namespace_id], project_error_tracking_settings: %w[sentry_project_id], project_group_links: %w[group_id], project_statistics: %w[namespace_id], @@ -185,7 +190,6 @@ RSpec.describe 'Database schema', feature_category: :database do # These pre-existing enums have limits > 2 bytes IGNORED_LIMIT_ENUMS = { 'Analytics::CycleAnalytics::Stage' => %w[start_event_identifier end_event_identifier], - 'Analytics::CycleAnalytics::ProjectStage' => %w[start_event_identifier end_event_identifier], 'Ci::Bridge' => %w[failure_reason], 'Ci::Build' => %w[failure_reason], 'Ci::BuildMetadata' => %w[timeout_source], |