diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/factories | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/factories')
21 files changed, 171 insertions, 94 deletions
diff --git a/spec/factories/bulk_import/trackers.rb b/spec/factories/bulk_import/trackers.rb index 94340b0f389..22e0aa096fc 100644 --- a/spec/factories/bulk_import/trackers.rb +++ b/spec/factories/bulk_import/trackers.rb @@ -19,5 +19,11 @@ FactoryBot.define do sequence(:jid) { |n| "bulk_import_entity_#{n}" } end + + trait :failed do + status { -1 } + + sequence(:jid) { |n| "bulk_import_entity_#{n}" } + end end end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index f99021ad223..395d3ea598c 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -79,6 +79,7 @@ FactoryBot.define do trait :pending do queued_at { 'Di 29. Okt 09:50:59 CET 2013' } + status { 'pending' } end @@ -237,6 +238,20 @@ FactoryBot.define do coverage_regex { '/(d+)/' } end + trait :trace_with_coverage do + coverage { nil } + coverage_regex { '(\d+\.\d+)%' } + + transient do + trace_coverage { 60.0 } + end + + after(:create) do |build, evaluator| + build.trace.set("Coverage #{evaluator.trace_coverage}%") + build.trace.archive! if build.complete? + end + end + trait :trace_live do after(:create) do |build, evaluator| build.trace.set('BUILD TRACE') @@ -286,6 +301,15 @@ FactoryBot.define do trait :queued do queued_at { Time.now } + + after(:create) do |build| + build.create_queuing_entry! + end + end + + trait :picked do + running + runner factory: :ci_runner end @@ -484,14 +508,6 @@ FactoryBot.define do end end - trait :license_management do - options do - { - artifacts: { reports: { license_management: 'gl-license-management-report.json' } } - } - end - end - trait :license_scanning do options do { diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index 17cd495e217..642437b1119 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -317,21 +317,6 @@ FactoryBot.define do end end - trait :cluster_applications do - file_type { :cluster_applications } - file_format { :gzip } - - transient do - file do - fixture_file_upload(Rails.root.join('spec/fixtures/helm/helm_list_v2_prometheus_missing.json.gz'), 'application/x-gzip') - end - end - - after(:build) do |artifact, evaluator| - artifact.file = evaluator.file - end - end - trait :correct_checksum do after(:build) do |artifact, evaluator| artifact.file_sha256 = Digest::SHA256.file(artifact.file.path).hexdigest diff --git a/spec/factories/ci/job_token/project_scope_links.rb b/spec/factories/ci/job_token/project_scope_links.rb new file mode 100644 index 00000000000..a11edd87e4e --- /dev/null +++ b/spec/factories/ci/job_token/project_scope_links.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_job_token_project_scope_link, class: 'Ci::JobToken::ProjectScopeLink' do + association :source_project, factory: :project + association :target_project, factory: :project + association :added_by, factory: :user + end +end diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb index 1ff1292c36e..29197768ec0 100644 --- a/spec/factories/clusters/applications/helm.rb +++ b/spec/factories/clusters/applications/helm.rb @@ -96,26 +96,7 @@ FactoryBot.define do end factory :clusters_applications_ingress, class: 'Clusters::Applications::Ingress' do - modsecurity_enabled { false } cluster factory: %i(cluster with_installed_helm provided_by_gcp) - - trait :modsecurity_blocking do - modsecurity_enabled { true } - modsecurity_mode { :blocking } - end - - trait :modsecurity_logging do - modsecurity_enabled { true } - modsecurity_mode { :logging } - end - - trait :modsecurity_disabled do - modsecurity_enabled { false } - end - - trait :modsecurity_not_installed do - modsecurity_enabled { nil } - end end factory :clusters_applications_cert_manager, class: 'Clusters::Applications::CertManager' do @@ -151,13 +132,6 @@ FactoryBot.define do cluster factory: %i(cluster with_installed_helm provided_by_gcp project) end - factory :clusters_applications_fluentd, class: 'Clusters::Applications::Fluentd' do - host { 'example.com' } - waf_log_enabled { true } - cilium_log_enabled { true } - cluster factory: %i(cluster with_installed_helm provided_by_gcp) - end - factory :clusters_applications_cilium, class: 'Clusters::Applications::Cilium' do cluster factory: %i(cluster with_installed_helm provided_by_gcp) end diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb index 0daf624ae7e..7666533691e 100644 --- a/spec/factories/clusters/clusters.rb +++ b/spec/factories/clusters/clusters.rb @@ -88,6 +88,7 @@ FactoryBot.define do trait :with_installed_prometheus do application_prometheus factory: %i(clusters_applications_prometheus installed) + integration_prometheus factory: %i(clusters_integrations_prometheus) end trait :with_all_applications do @@ -100,7 +101,6 @@ FactoryBot.define do application_jupyter factory: %i(clusters_applications_jupyter installed) application_knative factory: %i(clusters_applications_knative installed) application_elastic_stack factory: %i(clusters_applications_elastic_stack installed) - application_fluentd factory: %i(clusters_applications_fluentd installed) application_cilium factory: %i(clusters_applications_cilium installed) end @@ -138,10 +138,6 @@ FactoryBot.define do cleanup_status { 1 } end - trait :cleanup_uninstalling_applications do - cleanup_status { 2 } - end - trait :cleanup_removing_project_namespaces do cleanup_status { 3 } end diff --git a/spec/factories/environments.rb b/spec/factories/environments.rb index 072a5f1f402..148ee64fb08 100644 --- a/spec/factories/environments.rb +++ b/spec/factories/environments.rb @@ -16,19 +16,19 @@ FactoryBot.define do end trait :production do - tier { :production } + name { 'production' } end trait :staging do - tier { :staging } + name { 'staging' } end trait :testing do - tier { :testing } + name { 'testing' } end trait :development do - tier { :development } + name { 'development' } end trait :with_review_app do |environment| diff --git a/spec/factories/gitlab/database/background_migration/batched_migrations.rb b/spec/factories/gitlab/database/background_migration/batched_migrations.rb index c03841d8c02..de57e0c1565 100644 --- a/spec/factories/gitlab/database/background_migration/batched_migrations.rb +++ b/spec/factories/gitlab/database/background_migration/batched_migrations.rb @@ -9,6 +9,7 @@ FactoryBot.define do job_class_name { 'CopyColumnUsingBackgroundMigrationJob' } table_name { :events } column_name { :id } + sequence(:job_arguments) { |n| [["column_#{n}"], ["column_#{n}_convert_to_bigint"]] } total_tuple_count { 10_000 } pause_ms { 100 } end diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 5d232a9d09a..bd6e37c1cef 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -58,6 +58,13 @@ FactoryBot.define do shared_runners_enabled { false } end + trait :with_export do + after(:create) do |group, _evaluator| + export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz') + create(:import_export_upload, group: group, export_file: export_file) + end + end + trait :allow_descendants_override_disabled_shared_runners do allow_descendants_override_disabled_shared_runners { true } end diff --git a/spec/factories/integration_data.rb b/spec/factories/integration_data.rb index 2541a3d2da3..a6b2693b8df 100644 --- a/spec/factories/integration_data.rb +++ b/spec/factories/integration_data.rb @@ -3,15 +3,15 @@ # These factories should not be called directly unless we are testing a _tracker_data model. # The factories are used when creating integrations. FactoryBot.define do - factory :jira_tracker_data do + factory :jira_tracker_data, class: 'Integrations::JiraTrackerData' do integration factory: :jira_service end - factory :issue_tracker_data do + factory :issue_tracker_data, class: 'Integrations::IssueTrackerData' do integration end - factory :open_project_tracker_data do + factory :open_project_tracker_data, class: 'Integrations::OpenProjectTrackerData' do integration factory: :open_project_service url { 'http://openproject.example.com'} token { 'supersecret' } diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index 6bd6deb262a..fd570ca9c50 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -6,7 +6,7 @@ FactoryBot.define do type { 'Integration' } end - factory :custom_issue_tracker_service, class: 'CustomIssueTrackerService' do + factory :custom_issue_tracker_integration, class: 'Integrations::CustomIssueTracker' do project active { true } issue_tracker @@ -38,14 +38,14 @@ FactoryBot.define do end end - factory :drone_ci_service do + factory :drone_ci_integration, class: 'Integrations::DroneCi' do project active { true } drone_url { 'https://bamboo.example.com' } token { 'test' } end - factory :jira_service do + factory :jira_service, class: 'Integrations::Jira' do project active { true } type { 'JiraService' } @@ -79,31 +79,31 @@ FactoryBot.define do end end - factory :confluence_service, class: 'Integrations::Confluence' do + factory :confluence_integration, class: 'Integrations::Confluence' do project active { true } confluence_url { 'https://example.atlassian.net/wiki' } end - factory :bugzilla_service do + factory :bugzilla_integration, class: 'Integrations::Bugzilla' do project active { true } issue_tracker end - factory :redmine_service do + factory :redmine_service, class: 'Integrations::Redmine' do project active { true } issue_tracker end - factory :youtrack_service do + factory :youtrack_service, class: 'Integrations::Youtrack' do project active { true } issue_tracker end - factory :ewm_service do + factory :ewm_service, class: 'Integrations::Ewm' do project active { true } issue_tracker @@ -127,14 +127,14 @@ FactoryBot.define do end end - factory :external_wiki_service do + factory :external_wiki_service, class: 'Integrations::ExternalWiki' do project - type { ExternalWikiService } + type { 'ExternalWikiService' } active { true } external_wiki_url { 'http://external-wiki-url.com' } end - factory :open_project_service do + factory :open_project_service, class: 'Integrations::OpenProject' do project active { true } @@ -160,14 +160,20 @@ FactoryBot.define do password { 'my-secret-password' } end - factory :slack_service do + factory :slack_service, class: 'Integrations::Slack' do project active { true } webhook { 'https://slack.service.url' } type { 'SlackService' } end - factory :pipelines_email_service do + factory :slack_slash_commands_service, class: 'Integrations::SlackSlashCommands' do + project + active { true } + type { 'SlackSlashCommandsService' } + end + + factory :pipelines_email_service, class: 'Integrations::PipelinesEmail' do project active { true } type { 'PipelinesEmailService' } @@ -182,13 +188,13 @@ FactoryBot.define do create_data { false } after(:build) do - IssueTrackerService.skip_callback(:validation, :before, :handle_properties) + Integrations::BaseIssueTracker.skip_callback(:validation, :before, :handle_properties) end to_create { |instance| instance.save!(validate: false) } after(:create) do - IssueTrackerService.set_callback(:validation, :before, :handle_properties) + Integrations::BaseIssueTracker.set_callback(:validation, :before, :handle_properties) end end diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 0aab41df90b..6f706546402 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -341,6 +341,11 @@ FactoryBot.define do create(:diff_note_on_merge_request, noteable: mr, project: mr.source_project) end end + factory :merge_request_with_multiple_diffs do + after(:create) do |mr| + mr.merge_request_diffs.create!(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') + end + end factory :labeled_merge_request do transient do diff --git a/spec/factories/operations/feature_flag_scopes.rb b/spec/factories/operations/feature_flag_scopes.rb index a98c397b8b5..4ca9b53f320 100644 --- a/spec/factories/operations/feature_flag_scopes.rb +++ b/spec/factories/operations/feature_flag_scopes.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :operations_feature_flag_scope, class: 'Operations::FeatureFlagScope' do - association :feature_flag, factory: :operations_feature_flag + association :feature_flag, factory: [:operations_feature_flag, :legacy_flag] active { true } strategies { [{ name: "default", parameters: {} }] } sequence(:environment_scope) { |n| "review/patch-#{n}" } diff --git a/spec/factories/operations/feature_flags.rb b/spec/factories/operations/feature_flags.rb index 7e43d38a04f..32e5ec9fb26 100644 --- a/spec/factories/operations/feature_flags.rb +++ b/spec/factories/operations/feature_flags.rb @@ -5,6 +5,7 @@ FactoryBot.define do sequence(:name) { |n| "feature_flag_#{n}" } project active { true } + version { :new_version_flag } trait :legacy_flag do version { Operations::FeatureFlag.versions['legacy_flag'] } diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index a8020f396fd..cedda8d0854 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -75,7 +75,7 @@ FactoryBot.define do create :debian_package_file, :source, evaluator.file_metadatum_trait, package: package create :debian_package_file, :dsc, evaluator.file_metadatum_trait, package: package create :debian_package_file, :deb, evaluator.file_metadatum_trait, package: package - create :debian_package_file, :deb2, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :deb_dev, evaluator.file_metadatum_trait, package: package create :debian_package_file, :udeb, evaluator.file_metadatum_trait, package: package create :debian_package_file, :buildinfo, evaluator.file_metadatum_trait, package: package create :debian_package_file, :changes, evaluator.file_metadatum_trait, package: package diff --git a/spec/factories/packages/debian/component_file.rb b/spec/factories/packages/debian/component_file.rb index 19157b3c8c6..9aee91b0973 100644 --- a/spec/factories/packages/debian/component_file.rb +++ b/spec/factories/packages/debian/component_file.rb @@ -2,6 +2,10 @@ FactoryBot.define do factory :debian_project_component_file, class: 'Packages::Debian::ProjectComponentFile' do + transient do + file_fixture { 'spec/fixtures/packages/debian/distribution/Packages' } + end + component { association(:debian_project_component) } architecture { association(:debian_project_architecture, distribution: component.distribution) } @@ -13,7 +17,7 @@ FactoryBot.define do file_type { :packages } after(:build) do |component_file, evaluator| - component_file.file = fixture_file_upload('spec/fixtures/packages/debian/distribution/Packages') + component_file.file = fixture_file_upload(evaluator.file_fixture) if evaluator.file_fixture.present? end file_md5 { '12345abcde' } diff --git a/spec/factories/packages/debian/distribution_key.rb b/spec/factories/packages/debian/distribution_key.rb new file mode 100644 index 00000000000..6bd457c50d0 --- /dev/null +++ b/spec/factories/packages/debian/distribution_key.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :debian_project_distribution_key, class: 'Packages::Debian::ProjectDistributionKey' do + distribution { association(:debian_project_distribution) } + + private_key { '-----BEGIN PGP PRIVATE KEY BLOCK-----' } + passphrase { '12345' } + public_key { '-----BEGIN PGP PUBLIC KEY BLOCK-----' } + fingerprint { '12345' } + + factory :debian_group_distribution_key, class: 'Packages::Debian::GroupDistributionKey' do + distribution { association(:debian_group_distribution) } + end + end +end diff --git a/spec/factories/packages/debian/file_metadatum.rb b/spec/factories/packages/debian/file_metadatum.rb index 088d0140afe..f761dd18b4e 100644 --- a/spec/factories/packages/debian/file_metadatum.rb +++ b/spec/factories/packages/debian/file_metadatum.rb @@ -33,7 +33,53 @@ FactoryBot.define do file_type { 'deb' } component { 'main' } architecture { 'amd64' } - fields { { 'a': 'b' } } + fields do + { + 'Package' => 'libsample0', + 'Source' => package_file.package.name, + 'Version' => package_file.package.version, + 'Architecture' => 'amd64', + 'Maintainer' => "#{FFaker::Name.name} <#{FFaker::Internet.email}>", + 'Installed-Size' => '7', + 'Section' => 'libs', + 'Priority' => 'optional', + 'Multi-Arch' => 'same', + 'Homepage' => FFaker::Internet.http_url, + 'Description' => <<~EOF.rstrip + Some mostly empty lib + Used in GitLab tests. + + Testing another paragraph. + EOF + } + end + end + + trait(:deb_dev) do + file_type { 'deb' } + component { 'main' } + architecture { 'amd64' } + fields do + { + 'Package' => 'sample-dev', + 'Source' => "#{package_file.package.name} (#{package_file.package.version})", + 'Version' => '1.2.3~binary', + 'Architecture' => 'amd64', + 'Maintainer' => "#{FFaker::Name.name} <#{FFaker::Internet.email}>", + 'Installed-Size' => '7', + 'Depends' => 'libsample0 (= 1.2.3~binary)', + 'Section' => 'libdevel', + 'Priority' => 'optional', + 'Multi-Arch' => 'same', + 'Homepage' => FFaker::Internet.http_url, + 'Description' => <<~EOF.rstrip + Some mostly empty development files + Used in GitLab tests. + + Testing another paragraph. + EOF + } + end end trait(:udeb) do diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb index e49e3f36635..b02af85dbeb 100644 --- a/spec/factories/packages/package_file.rb +++ b/spec/factories/packages/package_file.rb @@ -125,9 +125,9 @@ FactoryBot.define do trait(:source) do file_name { 'sample_1.2.3~alpha2.tar.xz' } - file_md5 { 'd79b34f58f61ff4ad696d9bd0b8daa68' } - file_sha1 { '5f8bba5574eb01ac3b1f5e2988e8c29307788236' } - file_sha256 { 'b5a599e88e7cbdda3bde808160a21ba1dd1ec76b2ec8d4912aae769648d68362' } + file_md5 { 'd5ca476e4229d135a88f9c729c7606c9' } + file_sha1 { 'c5cfc111ea924842a89a06d5673f07dfd07de8ca' } + file_sha256 { '40e4682bb24a73251ccd7c7798c0094a649091e5625d6a14bcec9b4e7174f3da' } transient do file_metadatum_trait { :source } @@ -136,9 +136,9 @@ FactoryBot.define do trait(:dsc) do file_name { 'sample_1.2.3~alpha2.dsc' } - file_md5 { '3b0817804f669e16cdefac583ad88f0e' } - file_sha1 { '32ecbd674f0bfd310df68484d87752490685a8d6' } - file_sha256 { '844f79825b7e8aaa191e514b58a81f9ac1e58e2180134b0c9512fa66d896d7ba' } + file_md5 { 'ceccb6bb3e45ce6550b24234d4023e0f' } + file_sha1 { '375ba20ea1789e1e90d469c3454ce49a431d0442' } + file_sha256 { '81fc156ba937cdb6215362cc4bf6b8dc47be9b4253ba0f1a4ab10c7ea0c4c4e5' } transient do file_metadatum_trait { :dsc } @@ -156,14 +156,14 @@ FactoryBot.define do end end - trait(:deb2) do + trait(:deb_dev) do file_name { 'sample-dev_1.2.3~binary_amd64.deb' } - file_md5 { 'd2afbd28e4d74430d22f9504e18bfdf5' } - file_sha1 { 'f81e4f66c8c6bb899653a3340c157965ee69634f' } - file_sha256 { '9fbeee2191ce4dab5288fad5ecac1bd369f58fef9a992a880eadf0caf25f086d' } + file_md5 { '5fafc04dcae1525e1367b15413e5a5c7' } + file_sha1 { 'fcd5220b1501ec150ccf37f06e4da919a8612be4' } + file_sha256 { 'b8aa8b73a14bc1e0012d4c5309770f5160a8ea7f9dfe6f45222ea6b8a3c35325' } transient do - file_metadatum_trait { :deb } + file_metadatum_trait { :deb_dev } end end @@ -180,9 +180,9 @@ FactoryBot.define do trait(:buildinfo) do file_name { 'sample_1.2.3~alpha2_amd64.buildinfo' } - file_md5 { '4e085dd67c120ca967ec314f65770a42' } - file_sha1 { '0d47e899f3cc67a2253a4629456ff927e0db5c60' } - file_sha256 { 'f9900d3c94e94b329232668dcbef3dba2d96c07147b15b6dc0533452e4dd8a43' } + file_md5 { '12a5ac4f16ad75f8741327ac23b4c0d7' } + file_sha1 { '661f7507efa6fdd3763c95581d0baadb978b7ef5' } + file_sha256 { 'd0c169e9caa5b303a914b27b5adf69768fe6687d4925905b7d0cd9c0f9d4e56c' } transient do file_metadatum_trait { :buildinfo } diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index f4f1e1bcbda..cc561ef65a2 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -47,6 +47,7 @@ FactoryBot.define do import_last_error { nil } forward_deployment_enabled { nil } restrict_user_defined_variables { nil } + ci_job_token_scope_enabled { nil } end before(:create) do |project, evaluator| @@ -88,6 +89,7 @@ FactoryBot.define do project.merge_trains_enabled = evaluator.merge_trains_enabled unless evaluator.merge_trains_enabled.nil? project.keep_latest_artifact = evaluator.keep_latest_artifact unless evaluator.keep_latest_artifact.nil? project.restrict_user_defined_variables = evaluator.restrict_user_defined_variables unless evaluator.restrict_user_defined_variables.nil? + project.ci_job_token_scope_enabled = evaluator.ci_job_token_scope_enabled unless evaluator.ci_job_token_scope_enabled.nil? if evaluator.import_status import_state = project.import_state || project.build_import_state @@ -242,6 +244,8 @@ FactoryBot.define do branch_name: evaluator.create_branch) end + + project.track_project_repository end end diff --git a/spec/factories/user_details.rb b/spec/factories/user_details.rb index 3442f057c44..d3cf0d48577 100644 --- a/spec/factories/user_details.rb +++ b/spec/factories/user_details.rb @@ -4,5 +4,6 @@ FactoryBot.define do factory :user_detail do user job_title { 'VP of Sales' } + pronouns { nil } end end |