diff options
107 files changed, 595 insertions, 335 deletions
diff --git a/.gitlab/ci/cng.gitlab-ci.yml b/.gitlab/ci/cng.gitlab-ci.yml index 96ffd3941ab..fa22c22a8ab 100644 --- a/.gitlab/ci/cng.gitlab-ci.yml +++ b/.gitlab/ci/cng.gitlab-ci.yml @@ -1,5 +1,5 @@ # Make sure to update all the similar conditions in other CI config files if you modify these conditions -.if-canonical-gitlab-tag: &if-canonical-gitlab-tag +.if-canonical-dot-com-gitlab-org-groups-tag: &if-canonical-dot-com-gitlab-org-groups-tag if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ && $CI_COMMIT_TAG' cloud-native-image: @@ -13,5 +13,5 @@ cloud-native-image: - install_gitlab_gem - CNG_PROJECT_PATH="gitlab-org/build/CNG" BUILD_TRIGGER_TOKEN=$CI_JOB_TOKEN ./scripts/trigger-build cng rules: - - <<: *if-canonical-gitlab-tag + - <<: *if-canonical-dot-com-gitlab-org-groups-tag when: manual diff --git a/.gitlab/ci/docs.gitlab-ci.yml b/.gitlab/ci/docs.gitlab-ci.yml index 4acc3c7d1fe..b834fb1a37a 100644 --- a/.gitlab/ci/docs.gitlab-ci.yml +++ b/.gitlab/ci/docs.gitlab-ci.yml @@ -1,12 +1,55 @@ +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-canonical-dot-com-gitlab-org-groups-merge-request: &if-canonical-dot-com-gitlab-org-groups-merge-request + if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE =~ /^gitlab-org($|\/)/ && $CI_MERGE_REQUEST_IID' + +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-not-ee: &if-not-ee + if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/' + +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-default-refs: &if-default-refs + if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG' + +# Make sure to update all the similar patterns in other CI config files if you modify these patterns +.code-docs-patterns: &code-docs-patterns + - ".gitlab/route-map.yml" + - "doc/**/*" + - ".markdownlint.json" + +# Make sure to update all the similar patterns in other CI config files if you modify these patterns +.code-backstage-qa-patterns: &code-backstage-qa-patterns + - ".gitlab/ci/**/*" + - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}" + - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml" + - ".csscomb.json" + - "Dockerfile.assets" + - "*_VERSION" + - "Gemfile{,.lock}" + - "Rakefile" + - "{babel.config,jest.config}.js" + - "config.ru" + - "{package.json,yarn.lock}" + - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" + - "doc/api/graphql/reference/*" # Files in this folder are auto-generated + # Backstage changes + - "Dangerfile" + - "danger/**/*" + - "{,ee/}fixtures/**/*" + - "{,ee/}rubocop/**/*" + - "{,ee/}spec/**/*" + - "doc/README.md" # Some RSpec test rely on this file + # QA changes + - ".dockerignore" + - "qa/**/*" + .review-docs: extends: - .default-tags - .default-retry - - .only:variables-canonical-dot-com - - .only:changes-docs - only: - refs: - - merge_requests + rules: + - <<: *if-canonical-dot-com-gitlab-org-groups-merge-request + changes: *code-docs-patterns + when: manual image: ruby:2.6-alpine stage: review dependencies: [] @@ -32,7 +75,6 @@ review-docs-deploy: extends: .review-docs script: - ./scripts/trigger-build-docs deploy - when: manual # Cleanup remote environment of gitlab-docs review-docs-cleanup: @@ -42,14 +84,15 @@ review-docs-cleanup: action: stop script: - ./scripts/trigger-build-docs cleanup - when: manual docs lint: extends: - .default-tags - .default-retry - - .default-only - - .only:changes-docs + rules: + - <<: *if-default-refs + changes: *code-docs-patterns + when: on_success image: "registry.gitlab.com/gitlab-org/gitlab-docs:docs-lint" stage: test dependencies: [] @@ -69,14 +112,17 @@ docs lint: graphql-reference-verify: extends: - - .only-ee - .default-tags - .default-retry - .default-cache - - .default-only - .default-before_script - - .only:changes-code-backstage-qa - .use-pg9 + rules: + - <<: *if-not-ee + when: never + - <<: *if-default-refs + changes: *code-backstage-qa-patterns + when: on_success stage: test needs: ["setup-test-env"] script: diff --git a/.gitlab/ci/memory.gitlab-ci.yml b/.gitlab/ci/memory.gitlab-ci.yml index ba14024df34..e0b430354d0 100644 --- a/.gitlab/ci/memory.gitlab-ci.yml +++ b/.gitlab/ci/memory.gitlab-ci.yml @@ -1,11 +1,33 @@ +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-default-refs: &if-default-refs + if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG' + +# Make sure to update all the similar patterns in other CI config files if you modify these patterns +.code-patterns: &code-patterns + - ".gitlab/ci/**/*" + - ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}" + - ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml" + - ".csscomb.json" + - "Dockerfile.assets" + - "*_VERSION" + - "Gemfile{,.lock}" + - "Rakefile" + - "{babel.config,jest.config}.js" + - "config.ru" + - "{package.json,yarn.lock}" + - "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*" + - "doc/api/graphql/reference/*" # Files in this folder are auto-generated + .only-code-memory-job-base: extends: - .default-tags - .default-retry - .default-cache - - .default-only - .default-before_script - - .only:changes-code + rules: + - <<: *if-default-refs + changes: *code-patterns + when: on_success memory-static: extends: .only-code-memory-job-base diff --git a/.gitlab/ci/pages.gitlab-ci.yml b/.gitlab/ci/pages.gitlab-ci.yml index 6a2d3702bdd..9d80f4cba94 100644 --- a/.gitlab/ci/pages.gitlab-ci.yml +++ b/.gitlab/ci/pages.gitlab-ci.yml @@ -1,14 +1,15 @@ +# Make sure to update all the similar conditions in other CI config files if you modify these conditions +.if-canonical-dot-com-gitlab-org-group-master-refs: &if-canonical-dot-com-gitlab-org-group-master-refs + if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_COMMIT_REF_NAME == "master"' + pages: extends: - .default-tags - .default-retry - .default-cache - - .default-only - - .only:variables-canonical-dot-com - - .only:changes-code-backstage-qa - only: - refs: - - master + rules: + - <<: *if-canonical-dot-com-gitlab-org-group-master-refs + when: on_success stage: pages dependencies: ["coverage", "karma", "gitlab:assets:compile pull-cache"] script: diff --git a/.gitlab/ci/qa.gitlab-ci.yml b/.gitlab/ci/qa.gitlab-ci.yml index c950c219c96..862d1249360 100644 --- a/.gitlab/ci/qa.gitlab-ci.yml +++ b/.gitlab/ci/qa.gitlab-ci.yml @@ -1,5 +1,5 @@ # Make sure to update all the similar conditions in other CI config files if you modify these conditions -.if-canonical-gitlab-schedule: &if-canonical-gitlab-schedule +.if-canonical-dot-com-gitlab-org-group-schedule: &if-canonical-dot-com-gitlab-org-group-schedule if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"' # Make sure to update all the similar conditions in other CI config files if you modify these conditions @@ -86,7 +86,7 @@ package-and-qa: - <<: *if-canonical-gitlab-merge-request changes: *code-patterns when: manual - - <<: *if-canonical-gitlab-schedule + - <<: *if-canonical-dot-com-gitlab-org-group-schedule when: on_success needs: ["build-qa-image", "gitlab:assets:compile pull-cache"] allow_failure: true diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml index b970b590ae0..2e42aa46ac0 100644 --- a/.gitlab/ci/review.gitlab-ci.yml +++ b/.gitlab/ci/review.gitlab-ci.yml @@ -1,5 +1,5 @@ # Make sure to update all the similar conditions in other CI config files if you modify these conditions -.if-canonical-gitlab-schedule: &if-canonical-gitlab-schedule +.if-canonical-dot-com-gitlab-org-group-schedule: &if-canonical-dot-com-gitlab-org-group-schedule if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"' # Make sure to update all the similar conditions in other CI config files if you modify these conditions @@ -47,7 +47,7 @@ build-qa-image: - <<: *if-canonical-gitlab-merge-request changes: *code-qa-patterns when: on_success - - <<: *if-canonical-gitlab-schedule + - <<: *if-canonical-dot-com-gitlab-org-group-schedule when: on_success script: - '[[ ! -d "ee/" ]] || export GITLAB_EDITION="ee"' diff --git a/app/assets/javascripts/commons/polyfills.js b/app/assets/javascripts/commons/polyfills.js index dd300b8a307..dec3c637c22 100644 --- a/app/assets/javascripts/commons/polyfills.js +++ b/app/assets/javascripts/commons/polyfills.js @@ -1,24 +1,4 @@ -// ECMAScript polyfills -import 'core-js/es/array/fill'; -import 'core-js/es/array/find'; -import 'core-js/es/array/find-index'; -import 'core-js/es/array/from'; -import 'core-js/es/array/includes'; -import 'core-js/es/number/is-integer'; -import 'core-js/es/object/assign'; -import 'core-js/es/object/values'; -import 'core-js/es/object/entries'; -import 'core-js/es/promise'; -import 'core-js/es/promise/finally'; -import 'core-js/es/string/code-point-at'; -import 'core-js/es/string/from-code-point'; -import 'core-js/es/string/includes'; -import 'core-js/es/string/starts-with'; -import 'core-js/es/string/ends-with'; -import 'core-js/es/symbol'; -import 'core-js/es/map'; -import 'core-js/es/weak-map'; -import 'core-js/modules/web.url'; +import 'core-js/stable'; // Browser polyfills import 'formdata-polyfill'; diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index de69daf5c22..c762e298eb8 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -1,6 +1,7 @@ import $ from 'jquery'; import 'at.js'; import _ from 'underscore'; +import SidebarMediator from '~/sidebar/sidebar_mediator'; import glRegexp from './lib/utils/regexp'; import AjaxCache from './lib/utils/ajax_cache'; import { spriteIcon } from './lib/utils/common_utils'; @@ -53,8 +54,8 @@ export const defaultAutocompleteConfig = { }; class GfmAutoComplete { - constructor(dataSources) { - this.dataSources = dataSources || {}; + constructor(dataSources = {}) { + this.dataSources = dataSources; this.cachedData = {}; this.isLoadingData = {}; } @@ -199,6 +200,16 @@ class GfmAutoComplete { } setupMembers($input) { + const fetchData = this.fetchData.bind(this); + const MEMBER_COMMAND = { + ASSIGN: '/assign', + UNASSIGN: '/unassign', + REASSIGN: '/reassign', + CC: '/cc', + }; + let assignees = []; + let command = ''; + // Team Members $input.atwho({ at: '@', @@ -225,6 +236,48 @@ class GfmAutoComplete { callbacks: { ...this.getDefaultCallbacks(), beforeSave: membersBeforeSave, + matcher(flag, subtext) { + const subtextNodes = subtext + .split(/\n+/g) + .pop() + .split(GfmAutoComplete.regexSubtext); + + // Check if @ is followed by '/assign', '/reassign', '/unassign' or '/cc' commands. + command = subtextNodes.find(node => { + if (Object.values(MEMBER_COMMAND).includes(node)) { + return node; + } + return null; + }); + + // Cache assignees list for easier filtering later + assignees = SidebarMediator.singleton?.store?.assignees?.map( + assignee => `${assignee.username} ${assignee.name}`, + ); + + const match = GfmAutoComplete.defaultMatcher(flag, subtext, this.app.controllers); + return match && match.length ? match[1] : null; + }, + filter(query, data, searchKey) { + if (GfmAutoComplete.isLoading(data)) { + fetchData(this.$inputor, this.at); + return data; + } + + if (data === GfmAutoComplete.defaultLoadingData) { + return $.fn.atwho.default.callbacks.filter(query, data, searchKey); + } + + if (command === MEMBER_COMMAND.ASSIGN) { + // Only include members which are not assigned to Issuable currently + return data.filter(member => !assignees.includes(member.search)); + } else if (command === MEMBER_COMMAND.UNASSIGN) { + // Only include members which are assigned to Issuable currently + return data.filter(member => assignees.includes(member.search)); + } + + return data; + }, }, }); } diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js index 73c1bc8b582..0740e0523a9 100644 --- a/app/assets/javascripts/ide/stores/modules/commit/actions.js +++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js @@ -44,7 +44,7 @@ export const setLastCommitMessage = ({ commit, rootGetters }, data) => { const commitMsg = sprintf( __('Your changes have been committed. Commit %{commitId} %{commitStats}'), { - commitId: `<a href="${currentProject.web_url}/commit/${data.short_id}" class="commit-sha">${data.short_id}</a>`, + commitId: `<a href="${currentProject.web_url}/-/commit/${data.short_id}" class="commit-sha">${data.short_id}</a>`, commitStats, }, false, @@ -56,7 +56,7 @@ export const setLastCommitMessage = ({ commit, rootGetters }, data) => { export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetters }, { data }) => { const selectedProject = rootGetters.currentProject; const lastCommit = { - commit_path: `${selectedProject.web_url}/commit/${data.id}`, + commit_path: `${selectedProject.web_url}/-/commit/${data.id}`, commit: { id: data.id, message: data.message, diff --git a/app/assets/javascripts/monitoring/components/charts/time_series.vue b/app/assets/javascripts/monitoring/components/charts/time_series.vue index e79755f4fb2..e58d9f23201 100644 --- a/app/assets/javascripts/monitoring/components/charts/time_series.vue +++ b/app/assets/javascripts/monitoring/components/charts/time_series.vue @@ -209,7 +209,7 @@ export default { id, createdAt: created_at, sha, - commitUrl: `${this.projectPath}/commit/${sha}`, + commitUrl: `${this.projectPath}/-/commit/${sha}`, tag, tagUrl: tag ? `${this.tagsPath}/${ref.name}` : null, ref: ref.name, diff --git a/app/assets/javascripts/test_utils/index.js b/app/assets/javascripts/test_utils/index.js index 1a1f3e8d0a8..2727485fb95 100644 --- a/app/assets/javascripts/test_utils/index.js +++ b/app/assets/javascripts/test_utils/index.js @@ -1,5 +1,3 @@ -import 'core-js/es/map'; -import 'core-js/es/set'; import { Sortable } from 'sortablejs'; import simulateDrag from './simulate_drag'; import simulateInput from './simulate_input'; diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb index 094488cb431..e721fded1d9 100644 --- a/app/models/project_services/flowdock_service.rb +++ b/app/models/project_services/flowdock_service.rb @@ -36,7 +36,7 @@ class FlowdockService < Service token: token, repo: project.repository, repo_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}", - commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/%s", + commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/-/commit/%s", diff_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/compare/%s...%s" ) end diff --git a/app/models/repository.rb b/app/models/repository.rb index d720980faab..825fddf4e63 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -451,10 +451,6 @@ class Repository return unless repo_type.project? - # This call is stubbed in tests due to being an expensive operation - # It can be reenabled for specific tests via: - # - # allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original DetectRepositoryLanguagesWorker.perform_async(project.id) end diff --git a/app/views/clusters/clusters/gcp/_form.html.haml b/app/views/clusters/clusters/gcp/_form.html.haml index 17f6a064c0e..66da76d7a43 100644 --- a/app/views/clusters/clusters/gcp/_form.html.haml +++ b/app/views/clusters/clusters/gcp/_form.html.haml @@ -66,7 +66,7 @@ - if Feature.enabled?(:create_cloud_run_clusters, clusterable, default_enabled: true) .form-group - = provider_gcp_field.check_box :cloud_run, { label: s_('ClusterIntegration|Enable Cloud Run on GKE (beta)'), + = provider_gcp_field.check_box :cloud_run, { label: s_('ClusterIntegration|Enable Cloud Run for Anthos'), label_class: 'label-bold' } .form-text.text-muted = s_('ClusterIntegration|Uses the Cloud Run, Istio, and HTTP Load Balancing addons for this cluster.') diff --git a/app/workers/concerns/worker_attributes.rb b/app/workers/concerns/worker_attributes.rb index 266c8021761..babdb46bb85 100644 --- a/app/workers/concerns/worker_attributes.rb +++ b/app/workers/concerns/worker_attributes.rb @@ -22,7 +22,8 @@ module WorkerAttributes # EE-specific epics: 2, - incident_management: 2 + incident_management: 2, + security_scans: 2 }.stringify_keys.freeze class_methods do diff --git a/babel.config.js b/babel.config.js index ca3baaeee59..dfb3bf19c36 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,6 +6,8 @@ const presets = [ [ '@babel/preset-env', { + useBuiltIns: 'usage', + corejs: { version: 3, proposals: true }, modules: false, targets: { ie: '11', @@ -51,4 +53,4 @@ if (isJest) { plugins.push('babel-plugin-dynamic-import-node'); } -module.exports = { presets, plugins }; +module.exports = { presets, plugins, sourceType: 'unambiguous' }; diff --git a/changelogs/unreleased/199698-smart-member-suggestions.yml b/changelogs/unreleased/199698-smart-member-suggestions.yml new file mode 100644 index 00000000000..13e7c6d2347 --- /dev/null +++ b/changelogs/unreleased/199698-smart-member-suggestions.yml @@ -0,0 +1,5 @@ +--- +title: Make smarter user suggestions for assign slash commands +merge_request: 24294 +author: +type: added diff --git a/changelogs/unreleased/39462-cloud-run-mislabeled-on-gke-cluster-creation-form.yml b/changelogs/unreleased/39462-cloud-run-mislabeled-on-gke-cluster-creation-form.yml new file mode 100644 index 00000000000..c62313b821b --- /dev/null +++ b/changelogs/unreleased/39462-cloud-run-mislabeled-on-gke-cluster-creation-form.yml @@ -0,0 +1,5 @@ +--- +title: Rename Cloud Run on GKE to Cloud Run for Anthos +merge_request: 23694 +author: +type: other diff --git a/changelogs/unreleased/dz-scope-commit-resource.yml b/changelogs/unreleased/dz-scope-commit-resource.yml new file mode 100644 index 00000000000..ed6be7ed9fc --- /dev/null +++ b/changelogs/unreleased/dz-scope-commit-resource.yml @@ -0,0 +1,5 @@ +--- +title: Move commit routes under - scope +merge_request: 24279 +author: +type: changed diff --git a/changelogs/unreleased/introduce-security-scan-model.yml b/changelogs/unreleased/introduce-security-scan-model.yml new file mode 100644 index 00000000000..003c437cd72 --- /dev/null +++ b/changelogs/unreleased/introduce-security-scan-model.yml @@ -0,0 +1,5 @@ +--- +title: Store security scans run in CI jobs +merge_request: 23669 +author: +type: other diff --git a/config/routes/project.rb b/config/routes/project.rb index 352184ed746..791f6cc2a4e 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -301,17 +301,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do defaults: { format: 'json' }, constraints: { template_type: %r{issue|merge_request}, format: 'json' } - resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do - member do - get :branches - get :pipelines - post :revert - post :cherry_pick - get :diff_for_path - get :merge_requests - end - end - resource :pages, only: [:show, :update, :destroy] do resources :domains, except: :index, controller: 'pages_domains', constraints: { id: %r{[^/]+} } do member do diff --git a/config/routes/repository.rb b/config/routes/repository.rb index d4805b67a5c..38d6cdbbaf8 100644 --- a/config/routes/repository.rb +++ b/config/routes/repository.rb @@ -10,6 +10,17 @@ resource :repository, only: [:create] do end end +resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do + member do + get :branches + get :pipelines + post :revert + post :cherry_pick + get :diff_for_path + get :merge_requests + end +end + # Don't use format parameter as file extension (old 3.0.x behavior) # See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments scope format: false do diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 1e1ed52650b..9a920a3e5e4 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -220,6 +220,8 @@ - 1 - - repository_update_remote_mirror - 1 +- - security_scans + - 2 - - self_monitoring_project_create - 2 - - self_monitoring_project_delete diff --git a/db/migrate/20200203232433_create_security_scan.rb b/db/migrate/20200203232433_create_security_scan.rb new file mode 100644 index 00000000000..a5fe73efbf2 --- /dev/null +++ b/db/migrate/20200203232433_create_security_scan.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class CreateSecurityScan < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :security_scans, id: :bigserial do |t| + t.timestamps_with_timezone null: false + + t.references :build, + null: false, + index: false, + foreign_key: { to_table: :ci_builds, on_delete: :cascade }, + type: :bigint + + t.integer :scan_type, + null: false, + index: { name: "idx_security_scans_on_scan_type" }, + limit: 2 + + t.index [:build_id, :scan_type], name: "idx_security_scans_on_build_and_scan_type", unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 258530ac3b3..0fa15317003 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3737,6 +3737,15 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do t.index ["group_id", "token_encrypted"], name: "index_scim_oauth_access_tokens_on_group_id_and_token_encrypted", unique: true end + create_table "security_scans", force: :cascade do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.bigint "build_id", null: false + t.integer "scan_type", limit: 2, null: false + t.index ["build_id", "scan_type"], name: "idx_security_scans_on_build_and_scan_type", unique: true + t.index ["scan_type"], name: "idx_security_scans_on_scan_type" + end + create_table "self_managed_prometheus_alert_events", force: :cascade do |t| t.bigint "project_id", null: false t.bigint "environment_id" @@ -4863,6 +4872,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do add_foreign_key "reviews", "users", column: "author_id", on_delete: :nullify add_foreign_key "saml_providers", "namespaces", column: "group_id", on_delete: :cascade add_foreign_key "scim_oauth_access_tokens", "namespaces", column: "group_id", on_delete: :cascade + add_foreign_key "security_scans", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "self_managed_prometheus_alert_events", "environments", on_delete: :cascade add_foreign_key "self_managed_prometheus_alert_events", "projects", on_delete: :cascade add_foreign_key "sentry_issues", "issues", on_delete: :cascade diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md index 58e802a9d27..78fbd421b4d 100644 --- a/doc/development/testing_guide/best_practices.md +++ b/doc/development/testing_guide/best_practices.md @@ -38,13 +38,13 @@ To run rspec tests: ```shell # run all tests -bundle exec rspec +bin/rspec # run test for path -bundle exec rspec spec/[path]/[to]/[spec].rb +bin/rspec spec/[path]/[to]/[spec].rb ``` -Use [guard](https://github.com/guard/guard) to continuously monitor for changes and only run matching tests: +Use [Guard](https://github.com/guard/guard) to continuously monitor for changes and only run matching tests: ```shell bundle exec guard @@ -130,7 +130,7 @@ Note: `live_debug` only works on JavaScript enabled specs. Run the spec with `CHROME_HEADLESS=0`, e.g.: ``` -CHROME_HEADLESS=0 bundle exec rspec some_spec.rb +CHROME_HEADLESS=0 bin/rspec some_spec.rb ``` The test will go by quickly, but this will give you an idea of what's happening. @@ -382,8 +382,8 @@ this trait should be either fixed to not rely on Sidekiq processing jobs, or the the processing of background jobs is needed/expected. NOTE: **Note:** -The usage of `perform_enqueued_jobs` is currently useless since our -workers aren't inheriting from `ApplicationJob` / `ActiveJob::Base`. +The usage of `perform_enqueued_jobs` is only useful for testing delayed mail +deliveries since our Sidekiq workers aren't inheriting from `ApplicationJob` / `ActiveJob::Base`. #### DNS diff --git a/doc/development/testing_guide/flaky_tests.md b/doc/development/testing_guide/flaky_tests.md index 94c45f5d2f7..5015c613557 100644 --- a/doc/development/testing_guide/flaky_tests.md +++ b/doc/development/testing_guide/flaky_tests.md @@ -50,6 +50,9 @@ is detected in any other branch (`flaky-examples-check` job). In the future, the This was originally implemented in: <https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/13021>. +If you want to enable retries locally, you can use the `RETRIES` env variable. +For instance `RETRIES=1 bin/rspec ...` would retry the failing examples once. + [rspec-retry]: https://github.com/NoRedInk/rspec-retry [`spec/spec_helper.rb`]: https://gitlab.com/gitlab-org/gitlab/blob/master/spec/spec_helper.rb diff --git a/doc/user/project/clusters/add_remove_clusters.md b/doc/user/project/clusters/add_remove_clusters.md index ef491a1971d..b52bff31794 100644 --- a/doc/user/project/clusters/add_remove_clusters.md +++ b/doc/user/project/clusters/add_remove_clusters.md @@ -232,8 +232,8 @@ To create and add a new Kubernetes cluster to your project, group, or instance: - **Number of nodes** - Enter the number of nodes you wish the cluster to have. - **Machine type** - The [machine type](https://cloud.google.com/compute/docs/machine-types) of the Virtual Machine instance that the cluster will be based on. - - **Enable Cloud Run on GKE (beta)** - Check this if you want to use Cloud Run on GKE for this cluster. - See the [Cloud Run on GKE section](#cloud-run-on-gke) for more information. + - **Enable Cloud Run for Anthos** - Check this if you want to use Cloud Run for Anthos for this cluster. + See the [Cloud Run for Anthos section](#cloud-run-for-anthos) for more information. - **GitLab-managed cluster** - Leave this checked if you want GitLab to manage namespaces and service accounts for this cluster. See the [Managed clusters section](index.md#gitlab-managed-clusters) for more information. 1. Finally, click the **Create Kubernetes cluster** button. @@ -241,11 +241,11 @@ To create and add a new Kubernetes cluster to your project, group, or instance: After a couple of minutes, your cluster will be ready to go. You can now proceed to install some [pre-defined applications](index.md#installing-applications). -#### Cloud Run on GKE +#### Cloud Run for Anthos > [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/16566) in GitLab 12.4. -You can choose to use Cloud Run on GKE in place of installing Knative and Istio +You can choose to use Cloud Run for Anthos in place of installing Knative and Istio separately after the cluster has been created. This means that Cloud Run (Knative), Istio, and HTTP Load Balancing will be enabled on the cluster at create time and cannot be [installed or uninstalled](../../clusters/applications.md) separately. diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index fa8b9ad79bd..1f1253c8542 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -45,7 +45,7 @@ module API end def authenticate_job! - job = Ci::Build.find_by_id(params[:id]) + job = current_job validate_job!(job) do forbidden! unless job_token_valid?(job) @@ -54,6 +54,10 @@ module API job end + def current_job + @current_job ||= Ci::Build.find_by_id(params[:id]) + end + def job_token_valid?(job) token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s token && job.valid_token?(token) diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 42a8d891dce..e1c79aa8efe 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -75,6 +75,13 @@ module API end resource :jobs do + before do + Gitlab::ApplicationContext.push( + user: -> { current_job&.user }, + project: -> { current_job&.project } + ) + end + desc 'Request a job' do success Entities::JobRequest::Response http_codes [[201, 'Job was scheduled'], diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb index 65cfd47e1e8..41ceeb329b3 100644 --- a/lib/gitlab/data_builder/push.rb +++ b/lib/gitlab/data_builder/push.rb @@ -37,7 +37,7 @@ module Gitlab id: "c5feabde2d8cd023215af4d2ceeb7a64839fc428", message: "Add simple search to projects in public area", timestamp: "2013-05-13T18:18:08+00:00", - url: "https://test.example.com/gitlab/gitlab/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", + url: "https://test.example.com/gitlab/gitlab/-/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", author: { name: "Test User", email: "test@example.com" diff --git a/lib/rspec_flaky/report.rb b/lib/rspec_flaky/report.rb index d88233aea8e..73f30362cfe 100644 --- a/lib/rspec_flaky/report.rb +++ b/lib/rspec_flaky/report.rb @@ -10,7 +10,7 @@ module RspecFlaky # This class is responsible for loading/saving JSON reports, and pruning # outdated examples. class Report < SimpleDelegator - OUTDATED_DAYS_THRESHOLD = 30 + OUTDATED_DAYS_THRESHOLD = 7 attr_reader :flaky_examples diff --git a/lib/tasks/gitlab/import_export/import.rake b/lib/tasks/gitlab/import_export/import.rake index 1f38b31c1e0..8fe61df605a 100644 --- a/lib/tasks/gitlab/import_export/import.rake +++ b/lib/tasks/gitlab/import_export/import.rake @@ -76,17 +76,26 @@ class GitlabProjectImport # synchronously as part of that process. # This ensures that all expensive operations do not escape # to general Sidekiq clusters/nodes. - def run_isolated_sidekiq_job + def with_isolated_sidekiq_job Sidekiq::Testing.fake! do with_request_store do - @project = create_project - - execute_sidekiq_job + ::Gitlab::GitalyClient.allow_n_plus_1_calls do + yield + end end + true end end + def run_isolated_sidekiq_job + with_isolated_sidekiq_job do + @project = create_project + + execute_sidekiq_job + end + end + def create_project # We are disabling ObjectStorage for `import` # as it is too slow to handle big archives: diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 4dd70043fd0..fba3dd8b55d 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4070,7 +4070,7 @@ msgstr "" msgid "ClusterIntegration|Elastic Stack" msgstr "" -msgid "ClusterIntegration|Enable Cloud Run on GKE (beta)" +msgid "ClusterIntegration|Enable Cloud Run for Anthos" msgstr "" msgid "ClusterIntegration|Enable Web Application Firewall" @@ -8976,9 +8976,6 @@ msgstr "" msgid "Geo|Status" msgstr "" -msgid "Geo|Sync" -msgstr "" - msgid "Geo|Synced" msgstr "" diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb index a680cfa96bd..ebc4cf8555f 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - context 'Manage', :orchestrated, :mattermost do + context 'Manage', :orchestrated, :mattermost, quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/202069' do describe 'Mattermost login' do it 'user logs into Mattermost using GitLab OAuth' do Flow::Login.sign_in diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb index 8c515b8d220..e33c9d7e64c 100644 --- a/spec/features/admin/admin_mode/workers_spec.rb +++ b/spec/features/admin/admin_mode/workers_spec.rb @@ -37,7 +37,7 @@ describe 'Admin mode for workers', :do_not_mock_admin_mode, :request_store, :cle gitlab_enable_admin_mode_sign_in(user) end - it 'can delete user', :sidekiq, :js do + it 'can delete user', :js do visit admin_user_path(user_to_delete) click_button 'Delete user' diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 0ff3809a915..b7ec445a7aa 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -282,6 +282,32 @@ describe 'GFM autocomplete', :js do end end + context 'assignees' do + let(:issue_assignee) { create(:issue, project: project) } + + before do + issue_assignee.update(assignees: [user]) + + visit project_issue_path(project, issue_assignee) + + wait_for_requests + end + + it 'lists users who are currently not assigned to the issue when using /assign' do + note = find('#note-body') + page.within '.timeline-content-form' do + note.native.send_keys('/as') + end + + find('.atwho-view li', text: '/assign') + note.native.send_keys(:tab) + + wait_for_requests + + expect(find('#at-view-users .atwho-view-ul')).not_to have_content(user.username) + end + end + context 'labels' do it 'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters' do create(:label, project: project, title: label_xss_title) diff --git a/spec/frontend/monitoring/components/charts/time_series_spec.js b/spec/frontend/monitoring/components/charts/time_series_spec.js index c734a706c9c..d4f197a708f 100644 --- a/spec/frontend/monitoring/components/charts/time_series_spec.js +++ b/spec/frontend/monitoring/components/charts/time_series_spec.js @@ -385,7 +385,7 @@ describe('Time series component', () => { describe('when tooltip is showing deployment data', () => { const mockSha = 'mockSha'; - const commitUrl = `${mockProjectDir}/commit/${mockSha}`; + const commitUrl = `${mockProjectDir}/-/commit/${mockSha}`; beforeEach(done => { timeSeriesAreaChart.vm.tooltip.isDeployment = true; diff --git a/spec/frontend/monitoring/mock_data.js b/spec/frontend/monitoring/mock_data.js index 0c985ba4fca..4d83933f2b8 100644 --- a/spec/frontend/monitoring/mock_data.js +++ b/spec/frontend/monitoring/mock_data.js @@ -169,7 +169,7 @@ export const deploymentData = [ iid: 3, sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', commitUrl: - 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', + 'http://test.host/frontend-fixtures/environments-project/-/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', ref: { name: 'master', }, @@ -183,7 +183,7 @@ export const deploymentData = [ iid: 2, sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', commitUrl: - 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', + 'http://test.host/frontend-fixtures/environments-project/-/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', ref: { name: 'master', }, @@ -197,7 +197,7 @@ export const deploymentData = [ iid: 1, sha: '6511e58faafaa7ad2228990ec57f19d66f7db7c2', commitUrl: - 'http://test.host/frontend-fixtures/environments-project/commit/6511e58faafaa7ad2228990ec57f19d66f7db7c2', + 'http://test.host/frontend-fixtures/environments-project/-/commit/6511e58faafaa7ad2228990ec57f19d66f7db7c2', ref: { name: 'update2-readme', }, diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index fa553710274..062fa8f106e 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -98,7 +98,7 @@ describe EventsHelper do it 'returns a commit note url' do event.target = create(:note_on_commit, note: '+1 from me') - expect(subject).to eq("#{project_base_url}/commit/#{event.target.commit_id}#note_#{event.target.id}") + expect(subject).to eq("#{project_base_url}/-/commit/#{event.target.commit_id}#note_#{event.target.id}") end it 'returns a project snippet note url' do diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js index 557244e237e..056822bcfe5 100644 --- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js @@ -131,7 +131,7 @@ describe('IDE commit module actions', () => { .dispatch('commit/setLastCommitMessage', { short_id: '123' }) .then(() => { expect(store.state.lastCommitMsg).toContain( - 'Your changes have been committed. Commit <a href="http://testing/commit/123" class="commit-sha">123</a>', + 'Your changes have been committed. Commit <a href="http://testing/-/commit/123" class="commit-sha">123</a>', ); }) .then(done) @@ -149,7 +149,7 @@ describe('IDE commit module actions', () => { }) .then(() => { expect(store.state.lastCommitMsg).toBe( - 'Your changes have been committed. Commit <a href="http://testing/commit/123" class="commit-sha">123</a> with 1 additions, 2 deletions.', + 'Your changes have been committed. Commit <a href="http://testing/-/commit/123" class="commit-sha">123</a> with 1 additions, 2 deletions.', ); }) .then(done) @@ -407,7 +407,7 @@ describe('IDE commit module actions', () => { .dispatch('commit/commitChanges') .then(() => { expect(store.state.lastCommitMsg).toBe( - 'Your changes have been committed. Commit <a href="webUrl/commit/123" class="commit-sha">123</a> with 1 additions, 2 deletions.', + 'Your changes have been committed. Commit <a href="webUrl/-/commit/123" class="commit-sha">123</a> with 1 additions, 2 deletions.', ); done(); diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb index 44f537ca8dd..f25804c3ca2 100644 --- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # Rollback DB to 10.5 (later than this was originally written for) because it still needs to work. -describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migration, schema: 20180208183958 do +describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, schema: 20180208183958 do include MigrationsHelpers::TrackUntrackedUploadsHelpers subject { described_class.new } diff --git a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb index 591368ee98e..9072431e8f6 100644 --- a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # Rollback DB to 10.5 (later than this was originally written for) because it still needs to work. -describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migration, schema: 20180208183958 do +describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :migration, schema: 20180208183958 do include MigrationsHelpers::TrackUntrackedUploadsHelpers let!(:untracked_files_for_uploads) { table(:untracked_files_for_uploads) } diff --git a/spec/lib/gitlab/background_migration/schedule_calculate_wiki_sizes_spec.rb b/spec/lib/gitlab/background_migration/schedule_calculate_wiki_sizes_spec.rb index 399db4ac259..cee9a3e8822 100644 --- a/spec/lib/gitlab/background_migration/schedule_calculate_wiki_sizes_spec.rb +++ b/spec/lib/gitlab/background_migration/schedule_calculate_wiki_sizes_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190527194900_schedule_calculate_wiki_sizes.rb') -describe ScheduleCalculateWikiSizes, :migration, :sidekiq do +describe ScheduleCalculateWikiSizes, :migration do let(:migration_class) { Gitlab::BackgroundMigration::CalculateWikiSizes } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb index 66a0b11606f..9546550bfc5 100644 --- a/spec/lib/gitlab/background_migration_spec.rb +++ b/spec/lib/gitlab/background_migration_spec.rb @@ -76,7 +76,7 @@ describe Gitlab::BackgroundMigration do end end - context 'when there are scheduled jobs present', :sidekiq, :redis do + context 'when there are scheduled jobs present', :redis do it 'steals all jobs from the scheduled sets' do Sidekiq::Testing.disable! do BackgroundMigrationWorker.perform_in(10.minutes, 'Object') @@ -91,7 +91,7 @@ describe Gitlab::BackgroundMigration do end end - context 'when there are enqueued and scheduled jobs present', :sidekiq, :redis do + context 'when there are enqueued and scheduled jobs present', :redis do it 'steals from the scheduled sets queue first' do Sidekiq::Testing.disable! do expect(described_class).to receive(:perform) @@ -107,7 +107,7 @@ describe Gitlab::BackgroundMigration do end end - context 'when retry_dead_jobs is true', :sidekiq, :redis do + context 'when retry_dead_jobs is true', :redis do let(:retry_queue) do [double(args: ['Object', [3]], queue: described_class.queue, delete: true)] end @@ -186,7 +186,7 @@ describe Gitlab::BackgroundMigration do end end - context 'when there are scheduled jobs present', :sidekiq, :redis do + context 'when there are scheduled jobs present', :redis do before do Sidekiq::Testing.disable! do BackgroundMigrationWorker.perform_in(10.minutes, 'Foo') diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 7a8e79fecb1..4cf2553b90d 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -1158,7 +1158,7 @@ describe Gitlab::Database::MigrationHelpers do end end - describe 'sidekiq migration helpers', :sidekiq, :redis do + describe 'sidekiq migration helpers', :redis do let(:worker) do Class.new do include Sidekiq::Worker @@ -1221,7 +1221,7 @@ describe Gitlab::Database::MigrationHelpers do end end - describe '#bulk_queue_background_migration_jobs_by_range', :sidekiq do + describe '#bulk_queue_background_migration_jobs_by_range' do context 'when the model has an ID column' do let!(:id1) { create(:user).id } let!(:id2) { create(:user).id } @@ -1293,7 +1293,7 @@ describe Gitlab::Database::MigrationHelpers do end end - describe '#queue_background_migration_jobs_by_range_at_intervals', :sidekiq do + describe '#queue_background_migration_jobs_by_range_at_intervals' do context 'when the model has an ID column' do let!(:id1) { create(:user).id } let!(:id2) { create(:user).id } diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb index 4cbabb5ad8d..b69e4668d61 100644 --- a/spec/lib/gitlab/etag_caching/router_spec.rb +++ b/spec/lib/gitlab/etag_caching/router_spec.rb @@ -59,7 +59,7 @@ describe Gitlab::EtagCaching::Router do it 'matches commit pipelines endpoint' do result = described_class.match( - '/my-group/my-project/commit/aa8260d253a53f73f6c26c734c72fdd600f6e6d4/pipelines.json' + '/my-group/my-project/-/commit/aa8260d253a53f73f6c26c734c72fdd600f6e6d4/pipelines.json' ) expect(result).to be_present diff --git a/spec/lib/gitlab/hashed_storage/migrator_spec.rb b/spec/lib/gitlab/hashed_storage/migrator_spec.rb index ce7f2c4530d..f3cbb811679 100644 --- a/spec/lib/gitlab/hashed_storage/migrator_spec.rb +++ b/spec/lib/gitlab/hashed_storage/migrator_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::HashedStorage::Migrator, :sidekiq, :redis do +describe Gitlab::HashedStorage::Migrator, :redis do describe '#bulk_schedule_migration' do it 'schedules job to HashedStorage::MigratorWorker' do Sidekiq::Testing.fake! do diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 22c2fc5545e..81f6138e2bf 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -215,6 +215,7 @@ ci_pipelines: - vulnerabilities_occurrence_pipelines - vulnerability_findings - pipeline_config +- security_scans pipeline_variables: - pipeline stages: diff --git a/spec/lib/gitlab/sidekiq_versioning_spec.rb b/spec/lib/gitlab/sidekiq_versioning_spec.rb index dade5961775..11c866894c2 100644 --- a/spec/lib/gitlab/sidekiq_versioning_spec.rb +++ b/spec/lib/gitlab/sidekiq_versioning_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::SidekiqVersioning, :sidekiq, :redis do +describe Gitlab::SidekiqVersioning, :redis do let(:foo_worker) do Class.new do def self.name diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index d349c2928b0..49011b100ab 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -10,7 +10,7 @@ describe Gitlab::UrlBuilder do url = described_class.build(commit) - expect(url).to eq "#{Settings.gitlab['url']}/#{commit.project.full_path}/commit/#{commit.id}" + expect(url).to eq "#{Settings.gitlab['url']}/#{commit.project.full_path}/-/commit/#{commit.id}" end end @@ -86,7 +86,7 @@ describe Gitlab::UrlBuilder do url = described_class.build(note) - expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}" + expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/-/commit/#{note.commit_id}#note_#{note.id}" end end @@ -96,7 +96,7 @@ describe Gitlab::UrlBuilder do url = described_class.build(note) - expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}" + expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/-/commit/#{note.commit_id}#note_#{note.id}" end end diff --git a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb index 53c176fc46f..0453ac87436 100644 --- a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb +++ b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190924152703_migrate_issue_trackers_data.rb') -describe MigrateIssueTrackersData, :migration, :sidekiq do +describe MigrateIssueTrackersData, :migration do let(:services) { table(:services) } let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb index f4155eab1bf..4de43e21ed3 100644 --- a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb +++ b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb') -describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do +describe ScheduleSetConfidentialNoteEventsOnServices, :migration do let(:services_table) { table(:services) } let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb b/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb index ae53b4e6443..17342dcaab3 100644 --- a/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb +++ b/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20180425131009_assure_commits_count_for_merge_request_diff.rb') -describe AssureCommitsCountForMergeRequestDiff, :migration, :sidekiq, :redis do +describe AssureCommitsCountForMergeRequestDiff, :migration, :redis do let(:migration) { spy('migration') } before do diff --git a/spec/migrations/cleanup_build_stage_migration_spec.rb b/spec/migrations/cleanup_build_stage_migration_spec.rb index 532212810c8..2142b7b5275 100644 --- a/spec/migrations/cleanup_build_stage_migration_spec.rb +++ b/spec/migrations/cleanup_build_stage_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20180420010616_cleanup_build_stage_migration.rb') -describe CleanupBuildStageMigration, :migration, :sidekiq, :redis do +describe CleanupBuildStageMigration, :migration, :redis do let(:migration) { spy('migration') } before do diff --git a/spec/migrations/cleanup_legacy_artifact_migration_spec.rb b/spec/migrations/cleanup_legacy_artifact_migration_spec.rb index dc269d32e5a..0ab7d7ec05f 100644 --- a/spec/migrations/cleanup_legacy_artifact_migration_spec.rb +++ b/spec/migrations/cleanup_legacy_artifact_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20190104182041_cleanup_legacy_artifact_migration.rb') -describe CleanupLegacyArtifactMigration, :migration, :sidekiq, :redis do +describe CleanupLegacyArtifactMigration, :migration, :redis do let(:migration) { spy('migration') } context 'when still legacy artifacts exist' do diff --git a/spec/migrations/cleanup_stages_position_migration_spec.rb b/spec/migrations/cleanup_stages_position_migration_spec.rb index 649fda1bb4e..c2077629919 100644 --- a/spec/migrations/cleanup_stages_position_migration_spec.rb +++ b/spec/migrations/cleanup_stages_position_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180604123514_cleanup_stages_position_migration.rb') -describe CleanupStagesPositionMigration, :migration, :sidekiq, :redis do +describe CleanupStagesPositionMigration, :migration, :redis do let(:migration) { spy('migration') } before do diff --git a/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb b/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb index 3c880c6f5fd..bdc248f2cf2 100644 --- a/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb +++ b/spec/migrations/enqueue_reset_merge_status_second_run_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190620112608_enqueue_reset_merge_status_second_run.rb') -describe EnqueueResetMergeStatusSecondRun, :migration, :sidekiq do +describe EnqueueResetMergeStatusSecondRun, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } diff --git a/spec/migrations/enqueue_reset_merge_status_spec.rb b/spec/migrations/enqueue_reset_merge_status_spec.rb index a6dd2e08079..4b312a3bc62 100644 --- a/spec/migrations/enqueue_reset_merge_status_spec.rb +++ b/spec/migrations/enqueue_reset_merge_status_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190528180441_enqueue_reset_merge_status.rb') -describe EnqueueResetMergeStatus, :migration, :sidekiq do +describe EnqueueResetMergeStatus, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } diff --git a/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb b/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb index 327fb09ffec..8efaab871a1 100644 --- a/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb +++ b/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers') -describe EnqueueVerifyPagesDomainWorkers, :sidekiq, :migration do +describe EnqueueVerifyPagesDomainWorkers, :migration do around do |example| Sidekiq::Testing.fake! do example.run diff --git a/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb b/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb index 4e7438fc182..a3ed9b722d5 100644 --- a/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb +++ b/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb') -describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do +describe MigrateClusterConfigureWorkerSidekiqQueue, :redis do include Gitlab::Database::MigrationHelpers include StubWorker diff --git a/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb b/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb index d54aac50dc8..6e0bd487d1f 100644 --- a/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb +++ b/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb') -describe MigrateCreateTraceArtifactSidekiqQueue, :sidekiq, :redis do +describe MigrateCreateTraceArtifactSidekiqQueue, :redis do include Gitlab::Database::MigrationHelpers include StubWorker diff --git a/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb b/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb index 5e25d1aed82..deeea74bd3b 100644 --- a/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb +++ b/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190715193142_migrate_discussion_id_on_promoted_epics.rb') -describe MigrateDiscussionIdOnPromotedEpics, :migration, :sidekiq do +describe MigrateDiscussionIdOnPromotedEpics, :migration do let(:migration_class) { described_class::MIGRATION } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb b/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb index 98bbe0ed5a2..d6259023c01 100644 --- a/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb +++ b/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb') -describe MigrateLegacyArtifactsToJobArtifacts, :migration, :sidekiq do +describe MigrateLegacyArtifactsToJobArtifacts, :migration do let(:migration_class) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb b/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb index 6a188f34854..aa4951b2f14 100644 --- a/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb +++ b/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180603190921_migrate_object_storage_upload_sidekiq_queue.rb') -describe MigrateObjectStorageUploadSidekiqQueue, :sidekiq, :redis do +describe MigrateObjectStorageUploadSidekiqQueue, :redis do include Gitlab::Database::MigrationHelpers include StubWorker diff --git a/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb b/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb index d8f39ce4e71..557eb52632f 100644 --- a/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb +++ b/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190124200344_migrate_storage_migrator_sidekiq_queue.rb') -describe MigrateStorageMigratorSidekiqQueue, :sidekiq, :redis do +describe MigrateStorageMigratorSidekiqQueue, :redis do include Gitlab::Database::MigrationHelpers include StubWorker diff --git a/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb b/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb index e517eef1320..204c38b3fc5 100644 --- a/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb +++ b/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb') -describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :sidekiq, :redis do +describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :redis do include Gitlab::Database::MigrationHelpers include StubWorker diff --git a/spec/migrations/patch_prometheus_services_for_shared_cluster_applications_spec.rb b/spec/migrations/patch_prometheus_services_for_shared_cluster_applications_spec.rb index 83f994c2a94..170251277e2 100644 --- a/spec/migrations/patch_prometheus_services_for_shared_cluster_applications_spec.rb +++ b/spec/migrations/patch_prometheus_services_for_shared_cluster_applications_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb') -describe PatchPrometheusServicesForSharedClusterApplications, :migration, :sidekiq do +describe PatchPrometheusServicesForSharedClusterApplications, :migration do include MigrationHelpers::PrometheusServiceHelpers let(:namespaces) { table(:namespaces) } diff --git a/spec/migrations/reschedule_builds_stages_migration_spec.rb b/spec/migrations/reschedule_builds_stages_migration_spec.rb index f9707d8f90b..8127934afab 100644 --- a/spec/migrations/reschedule_builds_stages_migration_spec.rb +++ b/spec/migrations/reschedule_builds_stages_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration') -describe RescheduleBuildsStagesMigration, :sidekiq, :migration do +describe RescheduleBuildsStagesMigration, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:pipelines) { table(:ci_pipelines) } diff --git a/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb b/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb index a62650c44fb..0e34e63fcc1 100644 --- a/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb +++ b/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20180309121820_reschedule_commits_count_for_merge_request_diff') -describe RescheduleCommitsCountForMergeRequestDiff, :migration, :sidekiq do +describe RescheduleCommitsCountForMergeRequestDiff, :migration do let(:merge_request_diffs) { table(:merge_request_diffs) } let(:merge_requests) { table(:merge_requests) } let(:projects) { table(:projects) } diff --git a/spec/migrations/schedule_digest_personal_access_tokens_spec.rb b/spec/migrations/schedule_digest_personal_access_tokens_spec.rb index ff859d07ff2..915397f0f4f 100644 --- a/spec/migrations/schedule_digest_personal_access_tokens_spec.rb +++ b/spec/migrations/schedule_digest_personal_access_tokens_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180913142237_schedule_digest_personal_access_tokens.rb') -describe ScheduleDigestPersonalAccessTokens, :migration, :sidekiq do +describe ScheduleDigestPersonalAccessTokens, :migration do let(:personal_access_tokens) { table(:personal_access_tokens) } let(:users) { table(:users) } diff --git a/spec/migrations/schedule_fill_valid_time_for_pages_domain_certificates_spec.rb b/spec/migrations/schedule_fill_valid_time_for_pages_domain_certificates_spec.rb index a0241f1d20c..43333ab9837 100644 --- a/spec/migrations/schedule_fill_valid_time_for_pages_domain_certificates_spec.rb +++ b/spec/migrations/schedule_fill_valid_time_for_pages_domain_certificates_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190524073827_schedule_fill_valid_time_for_pages_domain_certificates.rb') -describe ScheduleFillValidTimeForPagesDomainCertificates, :migration, :sidekiq do +describe ScheduleFillValidTimeForPagesDomainCertificates, :migration do let(:migration_class) { described_class::MIGRATION } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/schedule_pages_metadata_migration_spec.rb b/spec/migrations/schedule_pages_metadata_migration_spec.rb index 100ed520a32..bf9442808bc 100644 --- a/spec/migrations/schedule_pages_metadata_migration_spec.rb +++ b/spec/migrations/schedule_pages_metadata_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20191002031332_schedule_pages_metadata_migration') -describe SchedulePagesMetadataMigration, :migration, :sidekiq do +describe SchedulePagesMetadataMigration, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } diff --git a/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb b/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb index e397fbb7138..44ef72baa86 100644 --- a/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb +++ b/spec/migrations/schedule_populate_merge_request_assignees_table_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190322132835_schedule_populate_merge_request_assignees_table.rb') -describe SchedulePopulateMergeRequestAssigneesTable, :migration, :sidekiq do +describe SchedulePopulateMergeRequestAssigneesTable, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } diff --git a/spec/migrations/schedule_runners_token_encryption_spec.rb b/spec/migrations/schedule_runners_token_encryption_spec.rb index 6b9538c4d17..60abb98f629 100644 --- a/spec/migrations/schedule_runners_token_encryption_spec.rb +++ b/spec/migrations/schedule_runners_token_encryption_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20181121111200_schedule_runners_token_encryption') -describe ScheduleRunnersTokenEncryption, :migration, :sidekiq do +describe ScheduleRunnersTokenEncryption, :migration do let(:settings) { table(:application_settings) } let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } diff --git a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb index 845b0515177..c022610be08 100644 --- a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb +++ b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb') -describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do +describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration do let(:web_hooks_table) { table(:web_hooks) } let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks } let(:migration_name) { migration_class.to_s.demodulize } diff --git a/spec/migrations/schedule_stages_index_migration_spec.rb b/spec/migrations/schedule_stages_index_migration_spec.rb index 9ebc648f9d8..f2e9abe1eb8 100644 --- a/spec/migrations/schedule_stages_index_migration_spec.rb +++ b/spec/migrations/schedule_stages_index_migration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20180420080616_schedule_stages_index_migration') -describe ScheduleStagesIndexMigration, :sidekiq, :migration do +describe ScheduleStagesIndexMigration, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:pipelines) { table(:ci_pipelines) } diff --git a/spec/migrations/schedule_sync_issuables_state_id_spec.rb b/spec/migrations/schedule_sync_issuables_state_id_spec.rb index 4f841e8ce04..21844edeb40 100644 --- a/spec/migrations/schedule_sync_issuables_state_id_spec.rb +++ b/spec/migrations/schedule_sync_issuables_state_id_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190214112022_schedule_sync_issuables_state_id.rb') -describe ScheduleSyncIssuablesStateId, :migration, :sidekiq do +describe ScheduleSyncIssuablesStateId, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:merge_requests) { table(:merge_requests) } diff --git a/spec/migrations/schedule_sync_issuables_state_id_where_nil_spec.rb b/spec/migrations/schedule_sync_issuables_state_id_where_nil_spec.rb index 105c05bb7ca..5dbe0d973ae 100644 --- a/spec/migrations/schedule_sync_issuables_state_id_where_nil_spec.rb +++ b/spec/migrations/schedule_sync_issuables_state_id_where_nil_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190506135400_schedule_sync_issuables_state_id_where_nil') -describe ScheduleSyncIssuablesStateIdWhereNil, :migration, :sidekiq do +describe ScheduleSyncIssuablesStateIdWhereNil, :migration do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:merge_requests) { table(:merge_requests) } diff --git a/spec/migrations/sync_issuables_state_id_spec.rb b/spec/migrations/sync_issuables_state_id_spec.rb index c6e4b504bbb..3138d2bec33 100644 --- a/spec/migrations/sync_issuables_state_id_spec.rb +++ b/spec/migrations/sync_issuables_state_id_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20190911251732_sync_issuables_state_id') -describe SyncIssuablesStateId, :migration, :sidekiq do +describe SyncIssuablesStateId, :migration do let(:migration) { described_class.new } describe '#up' do diff --git a/spec/migrations/update_fingerprint_sha256_within_keys_spec.rb b/spec/migrations/update_fingerprint_sha256_within_keys_spec.rb index bdb661af904..20a506ea976 100644 --- a/spec/migrations/update_fingerprint_sha256_within_keys_spec.rb +++ b/spec/migrations/update_fingerprint_sha256_within_keys_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20200106071113_update_fingerprint_sha256_within_keys.rb') -describe UpdateFingerprintSha256WithinKeys, :sidekiq, :migration do +describe UpdateFingerprintSha256WithinKeys, :migration do let(:key_table) { table(:keys) } describe '#up' do diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index f0f6556deec..b99f51bb36e 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3854,6 +3854,10 @@ describe Ci::Build do set(:build) { create(:ci_build, project: project) } let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' } + around do |example| + Timecop.freeze { example.run } + end + before do stub_artifacts_object_storage end diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index 5b402e572c3..41630c71f21 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -267,7 +267,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do end it { expect(result[:issue].gitlab_commit).to eq(commit_id) } - it { expect(result[:issue].gitlab_commit_path).to eq("/#{project.namespace.path}/#{project.path}/commit/#{commit_id}") } + it { expect(result[:issue].gitlab_commit_path).to eq("/#{project.namespace.path}/#{project.path}/-/commit/#{commit_id}") } end end diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 6c3da490b08..c573bf7793a 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -421,7 +421,7 @@ describe JiraService do GlobalID: 'GitLab', relationship: 'mentioned on', object: { - url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/#{commit_id}", + url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/-/commit/#{commit_id}", title: "Solved by commit #{commit_id}.", icon: { title: 'GitLab', url16x16: favicon_path }, status: { resolved: true } @@ -464,7 +464,7 @@ describe JiraService do @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) expect(WebMock).to have_requested(:post, @comment_url).with( - body: %r{#{custom_base_url}/#{project.full_path}/commit/#{commit_id}} + body: %r{#{custom_base_url}/#{project.full_path}/-/commit/#{commit_id}} ).once end @@ -479,7 +479,7 @@ describe JiraService do @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) expect(WebMock).to have_requested(:post, @comment_url).with( - body: %r{#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/#{commit_id}} + body: %r{#{Gitlab.config.gitlab.url}/#{project.full_path}/-/commit/#{commit_id}} ).once end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 2b9ec4319f5..97b61b44856 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -6,8 +6,6 @@ shared_examples 'languages and percentages JSON response' do let(:expected_languages) { project.repository.languages.map { |language| language.values_at(:label, :value)}.to_h } before do - allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original - allow(project.repository).to receive(:languages).and_return( [{ value: 66.69, label: "Ruby", color: "#701516", highlight: "#701516" }, { value: 22.98, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" }, diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index e0f88caeab6..12fd9f431e5 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -61,9 +61,9 @@ describe API::Releases do it 'returns rendered helper paths' do get api("/projects/#{project.id}/releases", maintainer) - expect(json_response.first['commit_path']).to eq("/#{release_2.project.full_path}/commit/#{release_2.commit.id}") + expect(json_response.first['commit_path']).to eq("/#{release_2.project.full_path}/-/commit/#{release_2.commit.id}") expect(json_response.first['tag_path']).to eq("/#{release_2.project.full_path}/-/tags/#{release_2.tag}") - expect(json_response.second['commit_path']).to eq("/#{release_1.project.full_path}/commit/#{release_1.commit.id}") + expect(json_response.second['commit_path']).to eq("/#{release_1.project.full_path}/-/commit/#{release_1.commit.id}") expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}") end @@ -164,7 +164,7 @@ describe API::Releases do expect(response).to match_response_schema('public_api/v4/releases') expect(json_response.first['assets']['count']).to eq(release.links.count + release.sources.count) - expect(json_response.first['commit_path']).to eq("/#{release.project.full_path}/commit/#{release.commit.id}") + expect(json_response.first['commit_path']).to eq("/#{release.project.full_path}/-/commit/#{release.commit.id}") expect(json_response.first['tag_path']).to eq("/#{release.project.full_path}/-/tags/#{release.tag}") end end @@ -214,7 +214,7 @@ describe API::Releases do expect(json_response['author']['name']).to eq(maintainer.name) expect(json_response['commit']['id']).to eq(commit.id) expect(json_response['assets']['count']).to eq(4) - expect(json_response['commit_path']).to eq("/#{release.project.full_path}/commit/#{release.commit.id}") + expect(json_response['commit_path']).to eq("/#{release.project.full_path}/-/commit/#{release.commit.id}") expect(json_response['tag_path']).to eq("/#{release.project.full_path}/-/tags/#{release.tag}") end diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 23ce17b14fc..eb9db7ff6b7 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -311,11 +311,33 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end describe '/api/v4/jobs' do + shared_examples 'application context metadata' do |api_route| + it 'contains correct context metadata' do + # Avoids popping the context from the thread so we can + # check its content after the request. + allow(Labkit::Context).to receive(:pop) + + send_request + + Labkit::Context.with_context do |context| + expected_context = { + 'meta.caller_id' => api_route, + 'meta.user' => job.user.username, + 'meta.project' => job.project.full_path, + 'meta.root_namespace' => job.project.full_path_components.first + } + + expect(context.to_h).to include(expected_context) + end + end + end + let(:root_namespace) { create(:namespace) } let(:namespace) { create(:namespace, parent: root_namespace) } let(:project) { create(:project, namespace: namespace, shared_runners_enabled: false) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master') } let(:runner) { create(:ci_runner, :project, projects: [project]) } + let(:user) { create(:user) } let(:job) do create(:ci_build, :artifacts, :extended_options, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) @@ -984,12 +1006,18 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end describe 'PUT /api/v4/jobs/:id' do - let(:job) { create(:ci_build, :pending, :trace_live, pipeline: pipeline, runner_id: runner.id) } + let(:job) do + create(:ci_build, :pending, :trace_live, pipeline: pipeline, project: project, user: user, runner_id: runner.id) + end before do job.run! end + it_behaves_like 'application context metadata', '/api/:version/jobs/:id' do + let(:send_request) { update_job(state: 'success') } + end + context 'when status is given' do it 'mark job as succeeded' do update_job(state: 'success') @@ -1139,7 +1167,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end describe 'PATCH /api/v4/jobs/:id/trace' do - let(:job) { create(:ci_build, :running, :trace_live, runner_id: runner.id, pipeline: pipeline) } + let(:job) do + create(:ci_build, :running, :trace_live, + project: project, user: user, runner_id: runner.id, pipeline: pipeline) + end let(:headers) { { API::Helpers::Runner::JOB_TOKEN_HEADER => job.token, 'Content-Type' => 'text/plain' } } let(:headers_with_range) { headers.merge({ 'Content-Range' => '11-20' }) } let(:update_interval) { 10.seconds.to_i } @@ -1148,6 +1179,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do initial_patch_the_trace end + it_behaves_like 'application context metadata', '/api/:version/jobs/:id/trace' do + let(:send_request) { patch_the_trace } + end + context 'when request is valid' do it 'gets correct response' do expect(response.status).to eq 202 @@ -1399,7 +1434,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end describe 'artifacts' do - let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner_id: runner.id) } + let(:job) { create(:ci_build, :pending, user: user, project: project, pipeline: pipeline, runner_id: runner.id) } let(:jwt_token) { JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256') } let(:headers) { { 'GitLab-Workhorse' => '1.0', Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER => jwt_token } } let(:headers_with_token) { headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.token) } @@ -1418,6 +1453,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do authorize_artifacts_with_token_in_params end + it_behaves_like 'application context metadata', '/api/:version/jobs/:id/artifacts/authorize' do + let(:send_request) { subject } + end + shared_examples 'authorizes local file' do it 'succeeds' do subject @@ -1571,6 +1610,12 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end describe 'POST /api/v4/jobs/:id/artifacts' do + it_behaves_like 'application context metadata', '/api/:version/jobs/:id/artifacts' do + let(:send_request) do + upload_artifacts(file_upload, headers_with_token) + end + end + context 'when artifacts are being stored inside of tmp path' do before do # by configuring this path we allow to pass temp file from any path @@ -1971,6 +2016,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do describe 'GET /api/v4/jobs/:id/artifacts' do let(:token) { job.token } + it_behaves_like 'application context metadata', '/api/:version/jobs/:id/artifacts' do + let(:send_request) { download_artifact } + end + context 'when job has artifacts' do let(:job) { create(:ci_build) } let(:store) { JobArtifactUploader::Store::LOCAL } diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index ef26676a6e4..40c9dd565ff 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -445,10 +445,14 @@ describe 'project routing' do # project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /\h{7,40}/, project_id: /[^\/]+/} describe Projects::CommitController, 'routing' do it 'to #show' do + expect(get('/gitlab/gitlabhq/-/commit/4246fbd')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd') + expect(get('/gitlab/gitlabhq/-/commit/4246fbd.diff')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'diff') + expect(get('/gitlab/gitlabhq/-/commit/4246fbd.patch')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'patch') + expect(get('/gitlab/gitlabhq/-/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') + end + + it 'to #show unscoped routing' do expect(get('/gitlab/gitlabhq/commit/4246fbd')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd') - expect(get('/gitlab/gitlabhq/commit/4246fbd.diff')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'diff') - expect(get('/gitlab/gitlabhq/commit/4246fbd.patch')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'patch') - expect(get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') end end diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 83df54bc2ff..258403db089 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -46,7 +46,7 @@ describe Ci::RetryBuildService do sourced_pipelines 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].freeze + resource resource_group_id processed security_scans].freeze shared_examples 'build duplication' do let(:another_pipeline) { create(:ci_empty_pipeline, project: project) } diff --git a/spec/services/git/branch_hooks_service_spec.rb b/spec/services/git/branch_hooks_service_spec.rb index b1c64bc3c0a..8dc8c804ea5 100644 --- a/spec/services/git/branch_hooks_service_spec.rb +++ b/spec/services/git/branch_hooks_service_spec.rb @@ -69,6 +69,7 @@ describe Git::BranchHooksService do Gitlab.config.gitlab.url, project.namespace.to_param, project.to_param, + '-', 'commit', commit.id ].join('/') diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index 4d7ec7ac1d8..c64b93a2532 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -421,7 +421,7 @@ describe Git::BranchPushService, services: true do let(:message) { "this is some work.\n\ncloses JIRA-1" } let(:comment_body) do { - body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.full_path}/commit/#{closing_commit.id}]." + body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.full_path}/-/commit/#{closing_commit.id}]." }.to_json end diff --git a/spec/services/git/tag_hooks_service_spec.rb b/spec/services/git/tag_hooks_service_spec.rb index abb5b9b130b..094ccd8c9f0 100644 --- a/spec/services/git/tag_hooks_service_spec.rb +++ b/spec/services/git/tag_hooks_service_spec.rb @@ -107,6 +107,7 @@ describe Git::TagHooksService, :service do Gitlab.config.gitlab.url, project.namespace.to_param, project.to_param, + '-', 'commit', commit.id ].join('/') diff --git a/spec/services/merge_requests/migrate_external_diffs_service_spec.rb b/spec/services/merge_requests/migrate_external_diffs_service_spec.rb index 40ac747e66f..233b944624f 100644 --- a/spec/services/merge_requests/migrate_external_diffs_service_spec.rb +++ b/spec/services/merge_requests/migrate_external_diffs_service_spec.rb @@ -6,7 +6,7 @@ describe MergeRequests::MigrateExternalDiffsService do let(:merge_request) { create(:merge_request) } let(:diff) { merge_request.merge_request_diff } - describe '.enqueue!', :sidekiq do + describe '.enqueue!' do around do |example| Sidekiq::Testing.fake! { example.run } end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 9ef8b390b92..3df620d1fea 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -322,7 +322,7 @@ describe SystemNoteService do links = [] if link_exists url = if type == 'commit' - "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/commit/#{commit.id}" + "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/-/commit/#{commit.id}" else "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/-/merge_requests/#{merge_request.iid}" end @@ -462,7 +462,7 @@ describe SystemNoteService do describe "existing reference" do before do allow(JIRA::Resource::Remotelink).to receive(:all).and_return([]) - message = "[#{author.name}|http://localhost/#{author.username}] mentioned this issue in [a commit of #{project.full_path}|http://localhost/#{project.full_path}/commit/#{commit.id}]:\n'#{commit.title.chomp}'" + message = "[#{author.name}|http://localhost/#{author.username}] mentioned this issue in [a commit of #{project.full_path}|http://localhost/#{project.full_path}/-/commit/#{commit.id}]:\n'#{commit.title.chomp}'" allow_next_instance_of(JIRA::Resource::Issue) do |instance| allow(instance).to receive(:comments).and_return([OpenStruct.new(body: message)]) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 32eeeb5dfb4..ad15793f23b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -121,9 +121,9 @@ RSpec.configure do |config| config.include ExpectRequestWithStatus, type: :request config.include RailsHelpers - if ENV['CI'] + if ENV['CI'] || ENV['RETRIES'] # This includes the first try, i.e. tests will be run 4 times before failing. - config.default_retry_count = 4 + config.default_retry_count = ENV.fetch('RETRIES', 3).to_i + 1 config.reporter.register_listener( RspecFlaky::Listener.new, :example_passed, @@ -139,6 +139,16 @@ RSpec.configure do |config| TestEnv.clean_test_path end + # We can't use an `around` hook here because the wrapping transaction + # is not yet opened at the time that is triggered + config.prepend_before do + Gitlab::Database.set_open_transactions_baseline + end + + config.append_after do + Gitlab::Database.reset_open_transactions_baseline + end + config.before do |example| # Enable all features by default for testing allow(Feature).to receive(:enabled?) { true } @@ -176,12 +186,12 @@ RSpec.configure do |config| # Stub these calls due to being expensive operations # It can be reenabled for specific tests via: # - # allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original - # allow(Gitlab::Git::KeepAround).to receive(:execute).and_call_original - allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_return(true) + # expect(Gitlab::Git::KeepAround).to receive(:execute).and_call_original allow(Gitlab::Git::KeepAround).to receive(:execute) + # Clear thread cache and Sidekiq queues Gitlab::ThreadMemoryCache.cache_backend.clear + Sidekiq::Worker.clear_all # Temporary patch to force admin mode to be active by default in tests when # using the feature flag :user_mode_in_session, since this will require @@ -217,11 +227,14 @@ RSpec.configure do |config| RequestStore.clear! end - config.after do - Fog.unmock! if Fog.mock? + config.around do |example| + # Wrap each example in it's own context to make sure the contexts don't + # leak + Labkit::Context.with_context { example.run } end config.after do + Fog.unmock! if Fog.mock? Gitlab::CurrentSettings.clear_in_memory_application_settings! end @@ -236,90 +249,6 @@ RSpec.configure do |config| Gitlab::Metrics.reset_registry! end - config.around(:each, :use_clean_rails_memory_store_caching) do |example| - caching_store = Rails.cache - Rails.cache = ActiveSupport::Cache::MemoryStore.new - - example.run - - Rails.cache = caching_store - end - - config.around do |example| - # Wrap each example in it's own context to make sure the contexts don't - # leak - Labkit::Context.with_context { example.run } - end - - config.around(:each, :clean_gitlab_redis_cache) do |example| - redis_cache_cleanup! - - example.run - - redis_cache_cleanup! - end - - config.around(:each, :clean_gitlab_redis_shared_state) do |example| - redis_shared_state_cleanup! - - example.run - - redis_shared_state_cleanup! - end - - config.around(:each, :clean_gitlab_redis_queues) do |example| - redis_queues_cleanup! - - example.run - - redis_queues_cleanup! - end - - config.around(:each, :use_clean_rails_memory_store_fragment_caching) do |example| - caching_store = ActionController::Base.cache_store - ActionController::Base.cache_store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.perform_caching = true - - example.run - - ActionController::Base.perform_caching = false - ActionController::Base.cache_store = caching_store - end - - config.around(:each, :use_sql_query_cache) do |example| - ActiveRecord::Base.cache do - example.run - end - end - - # The :each scope runs "inside" the example, so this hook ensures the DB is in the - # correct state before any examples' before hooks are called. This prevents a - # problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends - # on background migrations being run inline during test setup) can be broken by - # altering Sidekiq behavior in an unrelated spec like so: - # - # around do |example| - # Sidekiq::Testing.fake! do - # example.run - # end - # end - config.before(:context, :migration) do - schema_migrate_down! - end - - # Each example may call `migrate!`, so we must ensure we are migrated down every time - config.before(:each, :migration) do - use_fake_application_settings - - schema_migrate_down! - end - - config.after(:context, :migration) do - schema_migrate_up! - - Gitlab::CurrentSettings.clear_in_memory_application_settings! - end - # This makes sure the `ApplicationController#can?` method is stubbed with the # original implementation for all view specs. config.before(:each, type: :view) do @@ -327,60 +256,8 @@ RSpec.configure do |config| Ability.allowed?(*args) end end - - config.before(:each, :http_pages_enabled) do |_| - allow(Gitlab.config.pages).to receive(:external_http).and_return(['1.1.1.1:80']) - end - - config.before(:each, :https_pages_enabled) do |_| - allow(Gitlab.config.pages).to receive(:external_https).and_return(['1.1.1.1:443']) - end - - config.before(:each, :http_pages_disabled) do |_| - allow(Gitlab.config.pages).to receive(:external_http).and_return(false) - end - - config.before(:each, :https_pages_disabled) do |_| - allow(Gitlab.config.pages).to receive(:external_https).and_return(false) - end - - # We can't use an `around` hook here because the wrapping transaction - # is not yet opened at the time that is triggered - config.prepend_before do - Gitlab::Database.set_open_transactions_baseline - end - - config.append_after do - Gitlab::Database.reset_open_transactions_baseline - end end -# add simpler way to match asset paths containing digest strings -RSpec::Matchers.define :match_asset_path do |expected| - match do |actual| - path = Regexp.escape(expected) - extname = Regexp.escape(File.extname(expected)) - digest_regex = Regexp.new(path.sub(extname, "(?:-\\h+)?#{extname}") << '$') - digest_regex =~ actual - end - - failure_message do |actual| - "expected that #{actual} would include an asset path for #{expected}" - end - - failure_message_when_negated do |actual| - "expected that #{actual} would not include an asset path for #{expected}" - end -end - -FactoryBot::SyntaxRunner.class_eval do - include RSpec::Mocks::ExampleMethods -end - -# Use FactoryBot 4.x behavior: -# https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations -FactoryBot.use_parent_strategy = false - ActiveRecord::Migration.maintain_test_schema! Shoulda::Matchers.configure do |config| diff --git a/spec/support/caching.rb b/spec/support/caching.rb new file mode 100644 index 00000000000..ecbe65f7e97 --- /dev/null +++ b/spec/support/caching.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + config.around(:each, :use_clean_rails_memory_store_caching) do |example| + caching_store = Rails.cache + Rails.cache = ActiveSupport::Cache::MemoryStore.new + + example.run + + Rails.cache = caching_store + end + + config.around(:each, :use_clean_rails_memory_store_fragment_caching) do |example| + caching_store = ActionController::Base.cache_store + ActionController::Base.cache_store = ActiveSupport::Cache::MemoryStore.new + ActionController::Base.perform_caching = true + + example.run + + ActionController::Base.perform_caching = false + ActionController::Base.cache_store = caching_store + end + + config.around(:each, :use_sql_query_cache) do |example| + ActiveRecord::Base.cache do + example.run + end + end +end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 00000000000..a86161bfded --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot::SyntaxRunner.class_eval do + include RSpec::Mocks::ExampleMethods +end + +# Use FactoryBot 4.x behavior: +# https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations +FactoryBot.use_parent_strategy = false diff --git a/spec/support/matchers/match_asset_path.rb b/spec/support/matchers/match_asset_path.rb new file mode 100644 index 00000000000..130b1ab02a3 --- /dev/null +++ b/spec/support/matchers/match_asset_path.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# add simpler way to match asset paths containing digest strings +RSpec::Matchers.define :match_asset_path do |expected| + match do |actual| + path = Regexp.escape(expected) + extname = Regexp.escape(File.extname(expected)) + digest_regex = Regexp.new(path.sub(extname, "(?:-\\h+)?#{extname}") << '$') + digest_regex =~ actual + end + + failure_message do |actual| + "expected that #{actual} would include an asset path for #{expected}" + end + + failure_message_when_negated do |actual| + "expected that #{actual} would not include an asset path for #{expected}" + end +end diff --git a/spec/support/migration.rb b/spec/support/migration.rb new file mode 100644 index 00000000000..3c359af886d --- /dev/null +++ b/spec/support/migration.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + # The :each scope runs "inside" the example, so this hook ensures the DB is in the + # correct state before any examples' before hooks are called. This prevents a + # problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends + # on background migrations being run inline during test setup) can be broken by + # altering Sidekiq behavior in an unrelated spec like so: + # + # around do |example| + # Sidekiq::Testing.fake! do + # example.run + # end + # end + config.before(:context, :migration) do + schema_migrate_down! + end + + # Each example may call `migrate!`, so we must ensure we are migrated down every time + config.before(:each, :migration) do + use_fake_application_settings + + schema_migrate_down! + end + + config.after(:context, :migration) do + schema_migrate_up! + + Gitlab::CurrentSettings.clear_in_memory_application_settings! + end +end diff --git a/spec/support/pages.rb b/spec/support/pages.rb new file mode 100644 index 00000000000..ad73d5b9ef5 --- /dev/null +++ b/spec/support/pages.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + config.before(:each, :http_pages_enabled) do |_| + allow(Gitlab.config.pages).to receive(:external_http).and_return(['1.1.1.1:80']) + end + + config.before(:each, :https_pages_enabled) do |_| + allow(Gitlab.config.pages).to receive(:external_https).and_return(['1.1.1.1:443']) + end + + config.before(:each, :http_pages_disabled) do |_| + allow(Gitlab.config.pages).to receive(:external_http).and_return(false) + end + + config.before(:each, :https_pages_disabled) do |_| + allow(Gitlab.config.pages).to receive(:external_https).and_return(false) + end +end diff --git a/spec/support/redis.rb b/spec/support/redis.rb new file mode 100644 index 00000000000..8539f202602 --- /dev/null +++ b/spec/support/redis.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + config.after(:each, :redis) do + Sidekiq.redis do |connection| + connection.redis.flushdb + end + end + + config.around(:each, :clean_gitlab_redis_cache) do |example| + redis_cache_cleanup! + + example.run + + redis_cache_cleanup! + end + + config.around(:each, :clean_gitlab_redis_shared_state) do |example| + redis_shared_state_cleanup! + + example.run + + redis_shared_state_cleanup! + end + + config.around(:each, :clean_gitlab_redis_queues) do |example| + redis_queues_cleanup! + + example.run + + redis_queues_cleanup! + end +end diff --git a/spec/support/sidekiq.rb b/spec/support/sidekiq.rb index a6d6d5fc6e1..9fa8df39019 100644 --- a/spec/support/sidekiq.rb +++ b/spec/support/sidekiq.rb @@ -1,30 +1,14 @@ # frozen_string_literal: true RSpec.configure do |config| - config.around(:each, :sidekiq) do |example| - Sidekiq::Worker.clear_all - example.run - Sidekiq::Worker.clear_all - end - - config.after(:each, :sidekiq, :redis) do - Sidekiq.redis do |connection| - connection.redis.flushdb - end - end - # As we'll review the examples with this tag, we should either: # - fix the example to not require Sidekiq inline mode (and remove this tag) # - explicitly keep the inline mode and change the tag for `:sidekiq_inline` instead config.around(:example, :sidekiq_might_not_need_inline) do |example| - Sidekiq::Worker.clear_all Sidekiq::Testing.inline! { example.run } - Sidekiq::Worker.clear_all end config.around(:example, :sidekiq_inline) do |example| - Sidekiq::Worker.clear_all Sidekiq::Testing.inline! { example.run } - Sidekiq::Worker.clear_all end end diff --git a/spec/tasks/gitlab/import_export/import_rake_spec.rb b/spec/tasks/gitlab/import_export/import_rake_spec.rb index b824ede03b2..14e53273a5b 100644 --- a/spec/tasks/gitlab/import_export/import_rake_spec.rb +++ b/spec/tasks/gitlab/import_export/import_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:import_export:import rake task', :sidekiq do +describe 'gitlab:import_export:import rake task' do let(:username) { 'root' } let(:namespace_path) { username } let!(:user) { create(:user, username: username) } diff --git a/spec/tasks/gitlab/storage_rake_spec.rb b/spec/tasks/gitlab/storage_rake_spec.rb index ae11e091000..54a84c73a57 100644 --- a/spec/tasks/gitlab/storage_rake_spec.rb +++ b/spec/tasks/gitlab/storage_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'rake gitlab:storage:*', :sidekiq do +describe 'rake gitlab:storage:*' do before do Rake.application.rake_require 'tasks/gitlab/storage' diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb index c7a4680e18d..89a1fa80943 100644 --- a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb +++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ObjectStorage::MigrateUploadsWorker, :sidekiq do +describe ObjectStorage::MigrateUploadsWorker do shared_context 'sanity_check! fails' do before do expect(described_class).to receive(:sanity_check!).and_raise(described_class::SanityCheckError) diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb index e5be8ce0423..aae6fa02a0c 100644 --- a/spec/workers/background_migration_worker_spec.rb +++ b/spec/workers/background_migration_worker_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state do +describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do let(:worker) { described_class.new } describe '.minimum_interval' do diff --git a/spec/workers/mail_scheduler/notification_service_worker_spec.rb b/spec/workers/mail_scheduler/notification_service_worker_spec.rb index 14a9f0ed8b7..3c023e713ed 100644 --- a/spec/workers/mail_scheduler/notification_service_worker_spec.rb +++ b/spec/workers/mail_scheduler/notification_service_worker_spec.rb @@ -49,7 +49,7 @@ describe MailScheduler::NotificationServiceWorker do end end - describe '.perform_async', :sidekiq do + describe '.perform_async' do around do |example| Sidekiq::Testing.fake! { example.run } end |