diff options
103 files changed, 1406 insertions, 1199 deletions
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 41a96f445a7..4daab8e4c1f 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -493,13 +493,6 @@ changes: *code-backstage-patterns when: on_success -.test-metadata:rules:flaky-examples-check: - rules: - - <<: *if-merge-request - changes: *code-backstage-patterns - when: on_success - - ############## # YAML rules # ############## diff --git a/.gitlab/ci/test-metadata.gitlab-ci.yml b/.gitlab/ci/test-metadata.gitlab-ci.yml index 719e4e821c9..cda6d996bdb 100644 --- a/.gitlab/ci/test-metadata.gitlab-ci.yml +++ b/.gitlab/ci/test-metadata.gitlab-ci.yml @@ -37,22 +37,3 @@ update-tests-metadata: - retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document - source scripts/rspec_helpers.sh - update_tests_metadata - -flaky-examples-check: - extends: - - .default-tags - - .default-retry - - .test-metadata:rules:flaky-examples-check - image: ruby:2.6-alpine - stage: post-test - variables: - NEW_FLAKY_SPECS_REPORT: rspec_flaky/report-new.json - allow_failure: true - artifacts: - expire_in: 30d - paths: - - rspec_flaky/ - script: - - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}' - - scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json - - scripts/flaky_examples/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT diff --git a/.rubocop.yml b/.rubocop.yml index 7977d607d87..c8e4fc6b305 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus: - 'ee/spec/requests/{groups,projects,repositories}/**/*' - 'spec/requests/api/*/**/*.rb' - 'ee/spec/requests/api/*/**/*.rb' - - 'spec/requests/api/[a-p]*.rb' - - 'ee/spec/requests/api/[a-p]*.rb' + - 'spec/requests/api/[a-s]*.rb' + - 'ee/spec/requests/api/[a-s]*.rb' Style/MultilineWhenThen: Enabled: false @@ -374,7 +374,7 @@ group :development, :test do gem 'scss_lint', '~> 0.56.0', require: false gem 'haml_lint', '~> 0.34.0', require: false - gem 'simplecov', '~> 0.16.1', require: false + gem 'simplecov', '~> 0.18.5', require: false gem 'bundler-audit', '~> 0.6.1', require: false gem 'benchmark-ips', '~> 2.3.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 8653375281b..0748cb0e56b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,7 +240,7 @@ GEM diffy (3.3.0) discordrb-webhooks-blackst0ne (3.3.0) rest-client (~> 2.0) - docile (1.3.1) + docile (1.3.2) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) doorkeeper (5.0.2) @@ -1015,11 +1015,10 @@ GEM jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simple_po_parser (1.1.2) - simplecov (0.16.1) + simplecov (0.18.5) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov-html (0.12.2) sixarm_ruby_unaccent (1.2.0) slack-messenger (2.3.3) snowplow-tracker (0.6.1) @@ -1375,7 +1374,7 @@ DEPENDENCIES sidekiq (~> 5.2.7) sidekiq-cron (~> 1.0) simple_po_parser (~> 1.1.2) - simplecov (~> 0.16.1) + simplecov (~> 0.18.5) slack-messenger (~> 2.3.3) snowplow-tracker (~> 0.6.1) spring (~> 2.0.0) diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue index a6d10d37103..a4073133028 100644 --- a/app/assets/javascripts/monitoring/components/dashboard.vue +++ b/app/assets/javascripts/monitoring/components/dashboard.vue @@ -468,6 +468,7 @@ export default { ref="addMetricBtn" v-gl-modal="$options.addMetric.modalId" variant="outline-success" + data-qa-selector="add_metric_button" class="mr-2 mt-1" >{{ $options.addMetric.title }}</gl-button > diff --git a/app/graphql/mutations/concerns/mutations/resolves_group.rb b/app/graphql/mutations/concerns/mutations/resolves_group.rb index 4306ce512f1..d5a040c84e9 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_group.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_group.rb @@ -5,10 +5,10 @@ module Mutations extend ActiveSupport::Concern def resolve_group(full_path:) - resolver.resolve(full_path: full_path) + group_resolver.resolve(full_path: full_path) end - def resolver + def group_resolver Resolvers::GroupResolver.new(object: nil, context: context) end end diff --git a/app/graphql/mutations/concerns/mutations/resolves_issuable.rb b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb new file mode 100644 index 00000000000..4146bf8fdc8 --- /dev/null +++ b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Mutations + module ResolvesIssuable + extend ActiveSupport::Concern + include Mutations::ResolvesProject + + def resolve_issuable(type:, parent_path:, iid:) + parent = resolve_issuable_parent(parent_path) + + issuable_resolver(type, parent, context).resolve(iid: iid.to_s) + end + + def issuable_resolver(type, parent, context) + resolver_class = "Resolvers::#{type.to_s.classify.pluralize}Resolver".constantize + + resolver_class.single.new(object: parent, context: context) + end + + def resolve_issuable_parent(parent_path) + resolve_project(full_path: parent_path) + end + end +end diff --git a/app/graphql/mutations/concerns/mutations/resolves_project.rb b/app/graphql/mutations/concerns/mutations/resolves_project.rb index da9814e88b0..0e91a25b803 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_project.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_project.rb @@ -5,10 +5,10 @@ module Mutations extend ActiveSupport::Concern def resolve_project(full_path:) - resolver.resolve(full_path: full_path) + project_resolver.resolve(full_path: full_path) end - def resolver + def project_resolver Resolvers::ProjectResolver.new(object: nil, context: context) end end diff --git a/app/graphql/mutations/issues/base.rb b/app/graphql/mutations/issues/base.rb index b7fa234a50b..7c545c3eb00 100644 --- a/app/graphql/mutations/issues/base.rb +++ b/app/graphql/mutations/issues/base.rb @@ -3,7 +3,7 @@ module Mutations module Issues class Base < BaseMutation - include Mutations::ResolvesProject + include Mutations::ResolvesIssuable argument :project_path, GraphQL::ID_TYPE, required: true, @@ -23,11 +23,7 @@ module Mutations private def find_object(project_path:, iid:) - project = resolve_project(full_path: project_path) - resolver = Resolvers::IssuesResolver - .single.new(object: project, context: context) - - resolver.resolve(iid: iid) + resolve_issuable(type: :issue, parent_path: project_path, iid: iid) end end end diff --git a/app/graphql/mutations/merge_requests/base.rb b/app/graphql/mutations/merge_requests/base.rb index 28e0cdc8cc7..96228855ace 100644 --- a/app/graphql/mutations/merge_requests/base.rb +++ b/app/graphql/mutations/merge_requests/base.rb @@ -3,7 +3,7 @@ module Mutations module MergeRequests class Base < BaseMutation - include Mutations::ResolvesProject + include Mutations::ResolvesIssuable argument :project_path, GraphQL::ID_TYPE, required: true, @@ -23,11 +23,7 @@ module Mutations private def find_object(project_path:, iid:) - project = resolve_project(full_path: project_path) - resolver = Resolvers::MergeRequestsResolver - .single.new(object: project, context: context) - - resolver.resolve(iid: iid) + resolve_issuable(type: :merge_request, parent_path: project_path, iid: iid) end end end diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index bdb0a881b08..b611f700d21 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -3,18 +3,23 @@ module FormHelper prepend_if_ee('::EE::FormHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule - def form_errors(model, type: 'form') + def form_errors(model, type: 'form', truncate: []) return unless model.errors.any? headline = n_('The %{type} contains the following error:', 'The %{type} contains the following errors:', model.errors.count) % { type: type } + truncate = Array.wrap(truncate) content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:h4, headline) << content_tag(:ul) do - model.errors.full_messages - .map { |msg| content_tag(:li, msg) } - .join - .html_safe + messages = model.errors.map do |attribute, message| + message = model.errors.full_message(attribute, message) + message = content_tag(:span, message, class: 'str-truncated-100') if truncate.include?(attribute) + + content_tag(:li, message) + end + + messages.join.html_safe end end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 26beb77a025..c5db42a40ac 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -333,11 +333,15 @@ class WikiPage *dirnames, title = @attributes[:title].split('/') if title.bytesize > MAX_TITLE_BYTES - errors.add(:title, _("exceeds the limit of %{bytes} bytes for page titles") % { bytes: MAX_TITLE_BYTES }) + errors.add(:title, _("exceeds the limit of %{bytes} bytes") % { bytes: MAX_TITLE_BYTES }) end - if dirnames.any? { |d| d.bytesize > MAX_DIRECTORY_BYTES } - errors.add(:title, _("exceeds the limit of %{bytes} bytes for directory names") % { bytes: MAX_DIRECTORY_BYTES }) + invalid_dirnames = dirnames.select { |d| d.bytesize > MAX_DIRECTORY_BYTES } + invalid_dirnames.each do |dirname| + errors.add(:title, _('exceeds the limit of %{bytes} bytes for directory name "%{dirname}"') % { + bytes: MAX_DIRECTORY_BYTES, + dirname: dirname + }) end end end diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml index 438d390389c..c66799a1598 100644 --- a/app/views/projects/wikis/_form.html.haml +++ b/app/views/projects/wikis/_form.html.haml @@ -4,7 +4,7 @@ = form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post, html: { class: form_classes }, data: { uploads_path: uploads_path } do |f| - = form_errors(@page) + = form_errors(@page, truncate: :title) - if @page.persisted? = f.hidden_field :last_commit_sha, value: @page.last_commit_sha diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 0b7add65d94..259b2efc49f 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -6,1267 +6,1267 @@ - :name: auto_devops:auto_devops_disable :feature_category: :auto_devops :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: auto_merge:auto_merge_process :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 3 :idempotent: - :name: chaos:chaos_cpu_spin :feature_category: :chaos_engineering :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: chaos:chaos_db_spin :feature_category: :chaos_engineering :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: chaos:chaos_kill :feature_category: :chaos_engineering :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: chaos:chaos_leak_mem :feature_category: :chaos_engineering :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: chaos:chaos_sleep :feature_category: :chaos_engineering :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: container_repository:cleanup_container_repository :feature_category: :container_registry :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: container_repository:delete_container_repository :feature_category: :container_registry :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:admin_email :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:ci_archive_traces_cron :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:container_expiration_policy :feature_category: :container_registry :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:environments_auto_stop_cron :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:expire_build_artifacts :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:gitlab_usage_ping :feature_category: :collection :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:import_export_project_cleanup :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:issue_due_scheduler :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:namespaces_prune_aggregation_schedules :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:pages_domain_removal_cron :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:pages_domain_ssl_renewal_cron :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:pages_domain_verification_cron :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:personal_access_tokens_expiring :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:pipeline_schedule :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:prune_old_events :feature_category: :users :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:prune_web_hook_logs :feature_category: :integrations :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:remove_expired_group_links :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:remove_expired_members :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:remove_unreferenced_lfs_objects :feature_category: :git_lfs :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:repository_archive_cache :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:repository_check_dispatch :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:requests_profiles :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:schedule_migrate_external_diffs :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:stuck_ci_jobs :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:stuck_import_jobs :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: cronjob:stuck_merge_jobs :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: cronjob:trending_projects :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: deployment:deployments_finished :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 3 :idempotent: - :name: deployment:deployments_forward_deployment :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 3 :idempotent: - :name: deployment:deployments_success :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 3 :idempotent: - :name: gcp_cluster:cluster_configure :feature_category: :kubernetes_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_configure_istio :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_install_app :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_patch_app :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_project_configure :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_provision :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_upgrade_app :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:cluster_wait_for_app_installation :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: gcp_cluster:cluster_wait_for_ingress_ip_address :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_applications_activate_service :feature_category: :kubernetes_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_applications_deactivate_service :feature_category: :kubernetes_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_applications_uninstall :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_applications_wait_for_uninstall_app :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: gcp_cluster:clusters_cleanup_app :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_cleanup_project_namespace :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:clusters_cleanup_service_account :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gcp_cluster:wait_for_cluster_creation :feature_category: :kubernetes_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_import_diff_note :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_import_issue :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_import_lfs_object :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_import_note :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_import_pull_request :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_refresh_import_jid :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_finish_import :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_base_data :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_issues_and_diff_notes :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_lfs_objects :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_notes :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_pull_requests :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_importer:github_import_stage_import_repository :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: hashed_storage:hashed_storage_migrator :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: hashed_storage:hashed_storage_project_migrate :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: hashed_storage:hashed_storage_project_rollback :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: hashed_storage:hashed_storage_rollbacker :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: incident_management:incident_management_process_alert :feature_category: :incident_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: mail_scheduler:mail_scheduler_issue_due :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: mail_scheduler:mail_scheduler_notification_service :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 2 :idempotent: - :name: notifications:new_release :feature_category: :release_orchestration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: object_pool:object_pool_create :feature_category: :gitaly :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: object_pool:object_pool_destroy :feature_category: :gitaly :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: object_pool:object_pool_join :feature_category: :gitaly :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 1 :idempotent: - :name: object_pool:object_pool_schedule_join :feature_category: :gitaly :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: object_storage:object_storage_background_move :feature_category: :not_owned :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: object_storage:object_storage_migrate_uploads :feature_category: :not_owned :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: pipeline_background:archive_trace :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: pipeline_background:ci_build_trace_chunk_flush :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: pipeline_cache:expire_job_cache :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 3 :idempotent: true - :name: pipeline_cache:expire_pipeline_cache :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 3 :idempotent: - :name: pipeline_creation:create_pipeline :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 4 :idempotent: - :name: pipeline_creation:run_pipeline_schedule :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 4 :idempotent: - :name: pipeline_default:build_coverage :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 3 :idempotent: - :name: pipeline_default:build_trace_sections :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 3 :idempotent: - :name: pipeline_default:ci_create_cross_project_pipeline :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 3 :idempotent: - :name: pipeline_default:ci_pipeline_bridge_status :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 3 :idempotent: - :name: pipeline_default:pipeline_metrics :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 3 :idempotent: - :name: pipeline_default:pipeline_notification :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 3 :idempotent: - :name: pipeline_default:pipeline_update_ci_ref_status :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 3 :idempotent: - :name: pipeline_hooks:build_hooks :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 2 :idempotent: - :name: pipeline_hooks:pipeline_hooks :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 2 :idempotent: - :name: pipeline_processing:build_finished :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 5 :idempotent: - :name: pipeline_processing:build_queue :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 5 :idempotent: - :name: pipeline_processing:build_success :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:ci_build_prepare :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:ci_build_schedule :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 5 :idempotent: - :name: pipeline_processing:ci_resource_groups_assign_resource_from_resource_group :feature_category: :continuous_delivery :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:pipeline_process :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:pipeline_success :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:pipeline_update :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:stage_update :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: pipeline_processing:update_head_pipeline_for_merge_request :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 5 :idempotent: - :name: repository_check:repository_check_batch :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_check:repository_check_clear :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_check:repository_check_single_repository :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: todos_destroyer:todos_destroyer_confidential_issue :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: todos_destroyer:todos_destroyer_entity_leave :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: todos_destroyer:todos_destroyer_group_private :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: todos_destroyer:todos_destroyer_private_features :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: todos_destroyer:todos_destroyer_project_private :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: update_namespace_statistics:namespaces_root_statistics :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: update_namespace_statistics:namespaces_schedule_aggregation :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: authorized_projects :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 2 :idempotent: - :name: background_migration :feature_category: :not_owned :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: chat_notification :feature_category: :chatops :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 2 :idempotent: - :name: create_commit_signature :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: create_evidence :feature_category: :release_governance :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: create_note_diff_file :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: default :feature_category: :has_external_dependencies: - :latency_sensitive: + :urgency: :resource_boundary: :weight: 1 :idempotent: - :name: delete_diff_files :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: delete_merged_branches :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: delete_stored_files :feature_category: :not_owned :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: delete_user :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: detect_repository_languages :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: email_receiver :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 2 :idempotent: - :name: emails_on_push :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 2 :idempotent: - :name: error_tracking_issue_link :feature_category: :error_tracking :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: expire_build_instance_artifacts :feature_category: :continuous_integration :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: file_hook :feature_category: :integrations :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: git_garbage_collect :feature_category: :gitaly :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: github_import_advance_stage :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: gitlab_shell :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 2 :idempotent: - :name: group_destroy :feature_category: :subgroups :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: group_export :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: group_import :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: import_issues_csv :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :cpu :weight: 2 :idempotent: - :name: invalid_gpg_signature_update :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: irker :feature_category: :integrations :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: mailers :feature_category: :has_external_dependencies: - :latency_sensitive: + :urgency: :resource_boundary: :weight: 2 :idempotent: - :name: merge :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 5 :idempotent: - :name: merge_request_mergeability_check :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: migrate_external_diffs :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: namespaceless_project_destroy :feature_category: :authentication_and_authorization :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: new_issue :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 2 :idempotent: - :name: new_merge_request :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 2 :idempotent: - :name: new_note :feature_category: :issue_tracking :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 2 :idempotent: - :name: pages :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: pages_domain_ssl_renewal :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: pages_domain_verification :feature_category: :pages :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: phabricator_import_import_tasks :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: post_receive :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 5 :idempotent: - :name: process_commit :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 3 :idempotent: - :name: project_cache :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :unknown :weight: 1 :idempotent: - :name: project_daily_statistics :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: project_destroy :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: project_export :feature_category: :importers :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :memory :weight: 1 :idempotent: - :name: project_service :feature_category: :integrations :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: propagate_service_template :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: reactive_caching :feature_category: :not_owned :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 1 :idempotent: - :name: rebase :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: remote_mirror_notification :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: repository_cleanup :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_fork :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_import :feature_category: :importers :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_remove_remote :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: repository_update_remote_mirror :feature_category: :source_code_management :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: self_monitoring_project_create :feature_category: :metrics :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: self_monitoring_project_delete :feature_category: :metrics :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 2 :idempotent: - :name: system_hook_push :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: update_external_pull_requests :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 3 :idempotent: - :name: update_merge_requests :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: true + :urgency: :high :resource_boundary: :cpu :weight: 3 :idempotent: - :name: update_project_statistics :feature_category: :source_code_management :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: upload_checksum :feature_category: :geo_replication :has_external_dependencies: - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: - :name: web_hook :feature_category: :integrations :has_external_dependencies: true - :latency_sensitive: + :urgency: :default :resource_boundary: :unknown :weight: 1 :idempotent: diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb index cd7ce386433..17537cdaa26 100644 --- a/app/workers/authorized_projects_worker.rb +++ b/app/workers/authorized_projects_worker.rb @@ -5,7 +5,7 @@ class AuthorizedProjectsWorker # rubocop:disable Scalability/IdempotentWorker prepend WaitableWorker feature_category :authentication_and_authorization - latency_sensitive_worker! + urgency :high weight 2 # This is a workaround for a Ruby 2.3.7 bug. rspec-mocks cannot restore the diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb index 0e69aa07cc1..b6ef9ab4710 100644 --- a/app/workers/build_finished_worker.rb +++ b/app/workers/build_finished_worker.rb @@ -5,7 +5,7 @@ class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_processing - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/build_hooks_worker.rb b/app/workers/build_hooks_worker.rb index 2662e991773..9693d3eb57f 100644 --- a/app/workers/build_hooks_worker.rb +++ b/app/workers/build_hooks_worker.rb @@ -6,7 +6,7 @@ class BuildHooksWorker # rubocop:disable Scalability/IdempotentWorker queue_namespace :pipeline_hooks feature_category :continuous_integration - latency_sensitive_worker! + urgency :high # rubocop: disable CodeReuse/ActiveRecord def perform(build_id) diff --git a/app/workers/build_queue_worker.rb b/app/workers/build_queue_worker.rb index 16d347a0e5c..b71afbbeb8f 100644 --- a/app/workers/build_queue_worker.rb +++ b/app/workers/build_queue_worker.rb @@ -6,7 +6,7 @@ class BuildQueueWorker # rubocop:disable Scalability/IdempotentWorker queue_namespace :pipeline_processing feature_category :continuous_integration - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/build_success_worker.rb b/app/workers/build_success_worker.rb index cb670b5bca7..e4a2dd500cc 100644 --- a/app/workers/build_success_worker.rb +++ b/app/workers/build_success_worker.rb @@ -5,7 +5,7 @@ class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_processing - latency_sensitive_worker! + urgency :high # rubocop: disable CodeReuse/ActiveRecord def perform(build_id) diff --git a/app/workers/chat_notification_worker.rb b/app/workers/chat_notification_worker.rb index 78d4206ec1a..058ac024f8a 100644 --- a/app/workers/chat_notification_worker.rb +++ b/app/workers/chat_notification_worker.rb @@ -7,7 +7,7 @@ class ChatNotificationWorker # rubocop:disable Scalability/IdempotentWorker sidekiq_options retry: false feature_category :chatops - latency_sensitive_worker! + urgency :high weight 2 # TODO: break this into multiple jobs diff --git a/app/workers/ci/pipeline_bridge_status_worker.rb b/app/workers/ci/pipeline_bridge_status_worker.rb index e4e9d8480c2..3f92f4561e0 100644 --- a/app/workers/ci/pipeline_bridge_status_worker.rb +++ b/app/workers/ci/pipeline_bridge_status_worker.rb @@ -5,7 +5,7 @@ module Ci include ::ApplicationWorker include ::PipelineQueue - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu def perform(pipeline_id) diff --git a/app/workers/concerns/worker_attributes.rb b/app/workers/concerns/worker_attributes.rb index 55feba673c4..216f73b58e2 100644 --- a/app/workers/concerns/worker_attributes.rb +++ b/app/workers/concerns/worker_attributes.rb @@ -4,9 +4,12 @@ module WorkerAttributes extend ActiveSupport::Concern # Resource boundaries that workers can declare through the - # `worker_resource_boundary` attribute + # `resource_boundary` attribute VALID_RESOURCE_BOUNDARIES = [:memory, :cpu, :unknown].freeze + # Urgencies that workers can declare through the `urgencies` attribute + VALID_URGENCIES = [:high, :default, :none].freeze + NAMESPACE_WEIGHTS = { auto_devops: 2, auto_merge: 3, @@ -47,21 +50,22 @@ module WorkerAttributes get_worker_attribute(:feature_category) == :not_owned end - # This should be set for jobs that need to be run immediately, or, if - # they are delayed, risk creating inconsistencies in the application - # that could being perceived by the user as incorrect behavior - # (ie, a bug) - # See doc/development/sidekiq_style_guide.md#Latency-Sensitive-Jobs + # This should be set to :high for jobs that need to be run + # immediately, or, if they are delayed, risk creating + # inconsistencies in the application that could being perceived by + # the user as incorrect behavior (ie, a bug) + # + # See + # doc/development/sidekiq_style_guide.md#urgency # for details - def latency_sensitive_worker! - worker_attributes[:latency_sensitive] = true + def urgency(urgency) + raise "Invalid urgency: #{urgency}" unless VALID_URGENCIES.include?(urgency) + + worker_attributes[:urgency] = urgency end - # Returns a truthy value if the worker is latency sensitive. - # See doc/development/sidekiq_style_guide.md#Latency-Sensitive-Jobs - # for details - def latency_sensitive_worker? - worker_attributes[:latency_sensitive] + def get_urgency + worker_attributes[:urgency] || :default end # Set this attribute on a job when it will call to services outside of the diff --git a/app/workers/create_pipeline_worker.rb b/app/workers/create_pipeline_worker.rb index ac00fcc5d57..54698518e4f 100644 --- a/app/workers/create_pipeline_worker.rb +++ b/app/workers/create_pipeline_worker.rb @@ -6,7 +6,7 @@ class CreatePipelineWorker # rubocop:disable Scalability/IdempotentWorker queue_namespace :pipeline_creation feature_category :continuous_integration - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu def perform(project_id, user_id, ref, source, params = {}) diff --git a/app/workers/email_receiver_worker.rb b/app/workers/email_receiver_worker.rb index 37398b18aef..fcb88982c0b 100644 --- a/app/workers/email_receiver_worker.rb +++ b/app/workers/email_receiver_worker.rb @@ -4,7 +4,7 @@ class EmailReceiverWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :issue_tracking - latency_sensitive_worker! + urgency :high weight 2 def perform(raw) diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb index 2c546bc3c20..cc114acf7e9 100644 --- a/app/workers/emails_on_push_worker.rb +++ b/app/workers/emails_on_push_worker.rb @@ -6,7 +6,7 @@ class EmailsOnPushWorker # rubocop:disable Scalability/IdempotentWorker attr_reader :email, :skip_premailer feature_category :source_code_management - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 2 diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb index 1cd5fa5d1c5..ce27fed7fb1 100644 --- a/app/workers/expire_job_cache_worker.rb +++ b/app/workers/expire_job_cache_worker.rb @@ -5,7 +5,7 @@ class ExpireJobCacheWorker include PipelineQueue queue_namespace :pipeline_cache - latency_sensitive_worker! + urgency :high idempotent! # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb index d92141c70cc..1d2708cdb44 100644 --- a/app/workers/expire_pipeline_cache_worker.rb +++ b/app/workers/expire_pipeline_cache_worker.rb @@ -5,7 +5,7 @@ class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_cache - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/gitlab_shell_worker.rb b/app/workers/gitlab_shell_worker.rb index f9b5a7d99ed..ed08069d2bc 100644 --- a/app/workers/gitlab_shell_worker.rb +++ b/app/workers/gitlab_shell_worker.rb @@ -5,7 +5,7 @@ class GitlabShellWorker # rubocop:disable Scalability/IdempotentWorker include Gitlab::ShellAdapter feature_category :source_code_management - latency_sensitive_worker! + urgency :high weight 2 def perform(action, *arg) diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index a7b926e143f..cc5fe884aec 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -4,7 +4,7 @@ class MergeWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :source_code_management - latency_sensitive_worker! + urgency :high weight 5 def perform(merge_request_id, current_user_id, params) diff --git a/app/workers/new_issue_worker.rb b/app/workers/new_issue_worker.rb index ded5104c708..e0e28767f8d 100644 --- a/app/workers/new_issue_worker.rb +++ b/app/workers/new_issue_worker.rb @@ -5,7 +5,7 @@ class NewIssueWorker # rubocop:disable Scalability/IdempotentWorker include NewIssuable feature_category :issue_tracking - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 2 diff --git a/app/workers/new_merge_request_worker.rb b/app/workers/new_merge_request_worker.rb index 3b101435f7a..10a79841df9 100644 --- a/app/workers/new_merge_request_worker.rb +++ b/app/workers/new_merge_request_worker.rb @@ -5,7 +5,7 @@ class NewMergeRequestWorker # rubocop:disable Scalability/IdempotentWorker include NewIssuable feature_category :source_code_management - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 2 diff --git a/app/workers/new_note_worker.rb b/app/workers/new_note_worker.rb index af1cef432eb..8ead87a9230 100644 --- a/app/workers/new_note_worker.rb +++ b/app/workers/new_note_worker.rb @@ -4,7 +4,7 @@ class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :issue_tracking - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 2 diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb index 3fa0c5ab9af..85ecdd02fb5 100644 --- a/app/workers/pipeline_hooks_worker.rb +++ b/app/workers/pipeline_hooks_worker.rb @@ -5,7 +5,7 @@ class PipelineHooksWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_hooks - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/pipeline_metrics_worker.rb b/app/workers/pipeline_metrics_worker.rb index 65a5a94ed8a..1eb9b4ce089 100644 --- a/app/workers/pipeline_metrics_worker.rb +++ b/app/workers/pipeline_metrics_worker.rb @@ -4,7 +4,7 @@ class PipelineMetricsWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker include PipelineQueue - latency_sensitive_worker! + urgency :high # rubocop: disable CodeReuse/ActiveRecord def perform(pipeline_id) diff --git a/app/workers/pipeline_notification_worker.rb b/app/workers/pipeline_notification_worker.rb index 72663fa19ae..3336383adf7 100644 --- a/app/workers/pipeline_notification_worker.rb +++ b/app/workers/pipeline_notification_worker.rb @@ -4,7 +4,7 @@ class PipelineNotificationWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker include PipelineQueue - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb index 2f8ab0d6202..66a661dde71 100644 --- a/app/workers/pipeline_process_worker.rb +++ b/app/workers/pipeline_process_worker.rb @@ -6,7 +6,7 @@ class PipelineProcessWorker # rubocop:disable Scalability/IdempotentWorker queue_namespace :pipeline_processing feature_category :continuous_integration - latency_sensitive_worker! + urgency :high # rubocop: disable CodeReuse/ActiveRecord def perform(pipeline_id, build_ids = nil) diff --git a/app/workers/pipeline_success_worker.rb b/app/workers/pipeline_success_worker.rb index 3b4ab461ae7..d84612c52d1 100644 --- a/app/workers/pipeline_success_worker.rb +++ b/app/workers/pipeline_success_worker.rb @@ -5,7 +5,7 @@ class PipelineSuccessWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_processing - latency_sensitive_worker! + urgency :high def perform(pipeline_id) # no-op diff --git a/app/workers/pipeline_update_ci_ref_status_worker.rb b/app/workers/pipeline_update_ci_ref_status_worker.rb index 3d6a0d30e9c..96e14e126de 100644 --- a/app/workers/pipeline_update_ci_ref_status_worker.rb +++ b/app/workers/pipeline_update_ci_ref_status_worker.rb @@ -4,7 +4,7 @@ class PipelineUpdateCiRefStatusWorker # rubocop:disable Scalability/IdempotentWo include ApplicationWorker include PipelineQueue - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu def perform(pipeline_id) diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb index b170781202a..7f667057af6 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -5,7 +5,7 @@ class PipelineUpdateWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_processing - latency_sensitive_worker! + urgency :high def perform(pipeline_id) Ci::Pipeline.find_by_id(pipeline_id)&.update_legacy_status diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index f0fd3c9a808..d0eb188cc42 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -4,7 +4,7 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :source_code_management - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 5 diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index d604ac12e8a..4039ad45899 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -11,7 +11,7 @@ class ProcessCommitWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :source_code_management - latency_sensitive_worker! + urgency :high weight 3 # project_id - The ID of the project this commit belongs to. diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index fc79a988c8b..573f903f4e0 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -4,7 +4,7 @@ class ProjectCacheWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker - latency_sensitive_worker! + urgency :high LEASE_TIMEOUT = 15.minutes.to_i diff --git a/app/workers/reactive_caching_worker.rb b/app/workers/reactive_caching_worker.rb index bcaeaec5709..716b1de2bf5 100644 --- a/app/workers/reactive_caching_worker.rb +++ b/app/workers/reactive_caching_worker.rb @@ -6,11 +6,11 @@ class ReactiveCachingWorker # rubocop:disable Scalability/IdempotentWorker feature_category_not_owned! # TODO: The reactive caching worker should be split into - # two different workers, one for latency_sensitive jobs without external dependencies - # and another worker without latency_sensitivity, but with external dependencies + # two different workers, one for high urgency jobs without external dependencies + # and another worker without high urgency, but with external dependencies # https://gitlab.com/gitlab-com/gl-infra/scalability/issues/34 # This worker should also have `worker_has_external_dependencies!` enabled - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu def perform(class_name, id, *args) diff --git a/app/workers/stage_update_worker.rb b/app/workers/stage_update_worker.rb index a5097d61927..aface8288e3 100644 --- a/app/workers/stage_update_worker.rb +++ b/app/workers/stage_update_worker.rb @@ -5,7 +5,7 @@ class StageUpdateWorker # rubocop:disable Scalability/IdempotentWorker include PipelineQueue queue_namespace :pipeline_processing - latency_sensitive_worker! + urgency :high def perform(stage_id) Ci::Stage.find_by_id(stage_id)&.update_legacy_status diff --git a/app/workers/update_head_pipeline_for_merge_request_worker.rb b/app/workers/update_head_pipeline_for_merge_request_worker.rb index 47f0d1e0545..69698ba81bd 100644 --- a/app/workers/update_head_pipeline_for_merge_request_worker.rb +++ b/app/workers/update_head_pipeline_for_merge_request_worker.rb @@ -6,7 +6,7 @@ class UpdateHeadPipelineForMergeRequestWorker # rubocop:disable Scalability/Idem queue_namespace :pipeline_processing feature_category :continuous_integration - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu def perform(merge_request_id) diff --git a/app/workers/update_merge_requests_worker.rb b/app/workers/update_merge_requests_worker.rb index 195b455f0aa..4c2a85d6642 100644 --- a/app/workers/update_merge_requests_worker.rb +++ b/app/workers/update_merge_requests_worker.rb @@ -4,7 +4,7 @@ class UpdateMergeRequestsWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker feature_category :source_code_management - latency_sensitive_worker! + urgency :high worker_resource_boundary :cpu weight 3 diff --git a/changelogs/unreleased/cluster-apps-0-9-0.yml b/changelogs/unreleased/cluster-apps-0-9-0.yml new file mode 100644 index 00000000000..cba68cc19b5 --- /dev/null +++ b/changelogs/unreleased/cluster-apps-0-9-0.yml @@ -0,0 +1,5 @@ +--- +title: Update cluster-applications to v0.9.0 +merge_request: 26242 +author: +type: added diff --git a/changelogs/unreleased/tweak-wiki-title-validation-message.yml b/changelogs/unreleased/tweak-wiki-title-validation-message.yml new file mode 100644 index 00000000000..05e2c57fcff --- /dev/null +++ b/changelogs/unreleased/tweak-wiki-title-validation-message.yml @@ -0,0 +1,5 @@ +--- +title: Include invalid directories in wiki title message +merge_request: 25376 +author: +type: changed diff --git a/doc/administration/operations/extra_sidekiq_processes.md b/doc/administration/operations/extra_sidekiq_processes.md index d70e9d1baa5..3ad411f6f5a 100644 --- a/doc/administration/operations/extra_sidekiq_processes.md +++ b/doc/administration/operations/extra_sidekiq_processes.md @@ -115,10 +115,10 @@ following attributes: `source_code_management` category. - `has_external_dependencies` - whether or not the queue connects to external services. For example, all importers have this set to `true`. -- `latency_sensitive` - whether or not the queue is particularly sensitive to - latency, which also means that its jobs should run quickly. For example, the - `authorized_projects` queue is used to refresh user permissions, and is - latency sensitive. +- `urgency` - how important it is that this queue's jobs run + quickly. Can be `high`, `default`, or `none`. For example, the + `authorized_projects` queue is used to refresh user permissions, and + is high urgency. - `name` - the queue name. The other attributes are typically more useful as they are more general, but this is available in case a particular queue needs to be selected. @@ -126,9 +126,9 @@ following attributes: `unknown`. For example, the `project_export` queue is memory bound as it has to load data in memory before saving it for export. -Both `has_external_dependencies` and `latency_sensitive` are boolean attributes: -only the exact string `true` is considered true, and everything else is -considered false. +`has_external_dependencies` is a boolean attribute: only the exact +string `true` is considered true, and everything else is considered +false. ### Available operators @@ -162,10 +162,10 @@ In `/etc/gitlab/gitlab.rb`: sidekiq_cluster['enable'] = true sidekiq_cluster['experimental_queue_selector'] = true sidekiq_cluster['queue_groups'] = [ - # Run all non-CPU-bound queues that are latency sensitive - 'resource_boundary!=cpu&latency_sensitive=true', - # Run all continuous integration and pages queues that are not latency sensitive - 'feature_category=continuous_integration,pages&latency_sensitive=false' + # Run all non-CPU-bound queues that are high urgency + 'resource_boundary!=cpu&urgency=high, + # Run all continuous integration and pages queues that are not high urgency + 'feature_category=continuous_integration,pages&urgency!=high ] ``` diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql index 8d6fc859ca2..75d94f58605 100644 --- a/doc/api/graphql/reference/gitlab_schema.graphql +++ b/doc/api/graphql/reference/gitlab_schema.graphql @@ -1939,11 +1939,6 @@ type Epic implements Noteable { hasIssues: Boolean! """ - Current health status. Available only when feature flag save_issuable_health_status is enabled. - """ - healthStatus: HealthStatus - - """ ID of the epic """ id: ID! @@ -7813,11 +7808,6 @@ input UpdateEpicInput { groupPath: ID! """ - The desired health status - """ - healthStatus: HealthStatus - - """ The iid of the epic to mutate """ iid: ID! diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json index 4f2cbe81781..9434c15b681 100644 --- a/doc/api/graphql/reference/gitlab_schema.json +++ b/doc/api/graphql/reference/gitlab_schema.json @@ -24544,16 +24544,6 @@ "defaultValue": null }, { - "name": "healthStatus", - "description": "The desired health status", - "type": { - "kind": "ENUM", - "name": "HealthStatus", - "ofType": null - }, - "defaultValue": null - }, - { "name": "clientMutationId", "description": "A unique identifier for the client performing the mutation.", "type": { diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 1a9be3f496b..9d1d95ff2fb 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -307,7 +307,6 @@ Represents an epic. | `group` | Group! | Group to which the epic belongs | | `hasChildren` | Boolean! | Indicates if the epic has children | | `hasIssues` | Boolean! | Indicates if the epic has direct issues | -| `healthStatus` | HealthStatus | Current health status. Available only when feature flag save_issuable_health_status is enabled. | | `id` | ID! | ID of the epic | | `iid` | ID! | Internal ID of the epic | | `parent` | Epic | Parent epic of the epic | diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 255ae3f7c13..7fbaf5ca0b8 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -2090,9 +2090,8 @@ job: > [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/20390) in GitLab 11.2. Requires GitLab Runner 11.2 and above. -The `reports` keyword is used for collecting test reports from jobs and -exposing them in GitLab's UI (merge requests, pipeline views). Read how to use -this with [JUnit reports](#artifactsreportsjunit). +The `reports` keyword is used for collecting test reports, code quality reports, and security reports from jobs. +It also exposes these reports in GitLab's UI (merge requests, pipeline views, and security dashboards). NOTE: **Note:** The test reports are collected regardless of the job results (success or failure). diff --git a/doc/development/licensing.md b/doc/development/licensing.md index 2dc77b2eec8..a716db6b407 100644 --- a/doc/development/licensing.md +++ b/doc/development/licensing.md @@ -46,8 +46,8 @@ More detailed information on how the gem and its commands work is available in t Libraries with the following licenses are acceptable for use: -- [The MIT License](https://choosealicense.com/licenses/mit/) (the MIT Expat License specifically): The MIT License requires that the license itself is included with all copies of the source. It is a permissive (non-copyleft) license as defined by the Open Source Initiative. -- [LGPL](https://choosealicense.com/licenses/lgpl-3.0/) (version 2, version 3): GPL constraints regarding modification and redistribution under the same license are not required of projects using an LGPL library, only upon modification of the LGPL-licensed library itself. +- [MIT License](https://choosealicense.com/licenses/mit/) (the MIT Expat License specifically): The MIT License requires that the license itself is included with all copies of the source. It is a permissive (non-copyleft) license as defined by the Open Source Initiative. +- [GNU Lesser General Public License (GNU LGPL)](https://choosealicense.com/licenses/lgpl-3.0/) (version 2, version 3): GPL constraints regarding modification and redistribution under the same license are not required of projects using an LGPL library, only upon modification of the LGPL-licensed library itself. - [Apache 2.0 License](https://choosealicense.com/licenses/apache-2.0/): A permissive license that also provides an express grant of patent rights from contributors to users. - [Ruby 1.8 License][ruby-1.8]: Dual-licensed under either itself or the GPLv2, defer to the Ruby License itself. Acceptable because of point 3b: "You may distribute the software in object code or binary form, provided that you do at least ONE of the following: b) accompany the distribution with the machine-readable source of the software." - [Ruby 1.9 License][ruby-1.9]: Dual-licensed under either itself or the BSD 2-Clause License, defer to BSD 2-Clause. diff --git a/doc/development/sidekiq_style_guide.md b/doc/development/sidekiq_style_guide.md index e15daab0fdb..89a05f91a9e 100644 --- a/doc/development/sidekiq_style_guide.md +++ b/doc/development/sidekiq_style_guide.md @@ -121,7 +121,30 @@ NOTE: **Note:** Note that a cop will fail if the worker class is not marked as idempotent. Consider skipping the cop if you're not confident your job can safely run multiple times. -## Latency Sensitive Jobs +## Job urgency + +Jobs can have an `urgency` attribute set, which can be `:high`, +`:default`, or `:none`. These have the below targets: + +| **Urgency** | **Queue Scheduling Target** | **Execution Latency Requirement** | +|-------------|-----------------------------|------------------------------------| +| `:high` | 100 milliseconds | p50 of 1 second, p99 of 10 seconds | +| `:default` | 1 minute | Maximum run time of 1 hour | +| `:none` | None | Maximum run time of 1 hour | + +To set a job's urgency, use the `urgency` class method: + +```ruby +class HighUrgencyWorker + include ApplicationWorker + + urgency :high + + # ... +end +``` + +### Latency sensitive jobs If a large number of background jobs get scheduled at once, queueing of jobs may occur while jobs wait for a worker node to be become available. This is normal @@ -140,7 +163,7 @@ of these jobs include: When these jobs are delayed, the user may perceive the delay as a bug: for example, they may push a branch and then attempt to create a merge request for that branch, but be told in the UI that the branch does not exist. We deem these -jobs to be `latency_sensitive`. +jobs to be `urgency :high`. Extra effort is made to ensure that these jobs are started within a very short period of time after being scheduled. However, in order to ensure throughput, @@ -150,31 +173,11 @@ these jobs also have very strict execution duration requirements: 1. 99% of jobs should complete within 10 seconds. If a worker cannot meet these expectations, then it cannot be treated as a -`latency_sensitive` worker: consider redesigning the worker, or splitting the -work between two different workers, one with `latency_sensitive` code that -executes quickly, and the other with non-`latency_sensitive`, which has no +`urgency :high` worker: consider redesigning the worker, or splitting the +work between two different workers, one with `urgency :high` code that +executes quickly, and the other with `urgency :default`, which has no execution latency requirements (but also has lower scheduling targets). -This can be summed up in the following table: - -| **Latency Sensitivity** | **Queue Scheduling Target** | **Execution Latency Requirement** | -|-------------------------|-----------------------------|-------------------------------------| -| Not `latency_sensitive` | 1 minute | Maximum run time of 1 hour | -| `latency_sensitive` | 100 milliseconds | p50 of 1 second, p99 of 10 seconds | - -To mark a worker as being `latency_sensitive`, use the -`latency_sensitive_worker!` attribute, as shown in this example: - -```ruby -class LatencySensitiveWorker - include ApplicationWorker - - latency_sensitive_worker! - - # ... -end -``` - ## Jobs with External Dependencies Most background jobs in the GitLab application communicate with other GitLab @@ -194,7 +197,7 @@ the background processing cluster in several ways: therefore we cannot guarantee the execution latencies on these jobs. Since we cannot guarantee execution latency, we cannot ensure throughput and therefore, in high-traffic environments, we need to ensure that jobs with - external dependencies are separated from `latency_sensitive` jobs, to ensure + external dependencies are separated from high urgency jobs, to ensure throughput on those queues. 1. Errors in jobs with external dependencies have higher alerting thresholds as there is a likelihood that the cause of the error is external. @@ -212,7 +215,7 @@ class ExternalDependencyWorker end ``` -NOTE: **Note:** Note that a job cannot be both latency sensitive and have +NOTE: **Note:** Note that a job cannot be both high urgency and have external dependencies. ## CPU-bound and Memory-bound Workers @@ -246,14 +249,14 @@ bespoke low concurrency, high memory fleet. Note that memory-bound workers create heavy GC workloads, with pauses of 10-50ms. This will have an impact on the latency requirements for the -worker. For this reason, `memory` bound, `latency_sensitive` jobs are not +worker. For this reason, `memory` bound, `urgency :high` jobs are not permitted and will fail CI. In general, `memory` bound workers are discouraged, and alternative approaches to processing the work should be considered. -If a worker needs large amounts of both memory and CPU time, it should be marked as -memory-bound, due to the above restrction on latency-sensitive memory-bound -workers. +If a worker needs large amounts of both memory and CPU time, it should +be marked as memory-bound, due to the above restrction on high urgency +memory-bound workers. ## Declaring a Job as CPU-bound diff --git a/doc/development/testing_guide/flaky_tests.md b/doc/development/testing_guide/flaky_tests.md index f39151cfa59..ef8676ddf32 100644 --- a/doc/development/testing_guide/flaky_tests.md +++ b/doc/development/testing_guide/flaky_tests.md @@ -44,9 +44,8 @@ On our CI, we use [rspec-retry] to automatically retry a failing example a few times (see [`spec/spec_helper.rb`] for the precise retries count). We also use a home-made `RspecFlaky::Listener` listener which records flaky -examples in a JSON report file on `master` (`retrieve-tests-metadata` and `update-tests-metadata` jobs), and warns when a new flaky example -is detected in any other branch (`flaky-examples-check` job). In the future, the -`flaky-examples-check` job will not be allowed to fail. +examples in a JSON report file on `master` (`retrieve-tests-metadata` and +`update-tests-metadata` jobs). This was originally implemented in: <https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13021>. diff --git a/doc/user/group/saml_sso/index.md b/doc/user/group/saml_sso/index.md index b09dba573f2..8aad15671e1 100644 --- a/doc/user/group/saml_sso/index.md +++ b/doc/user/group/saml_sso/index.md @@ -73,9 +73,13 @@ Without group-managed accounts, users can link their SAML identity with any exis When this option is enabled: - All existing and new users in the group will be required to log in via the SSO URL associated with the group. -- On successfully authenticating, GitLab will prompt the user to create a new, dedicated account using the email address received from the configured identity provider. - After the group-managed account has been created, group activity will require the use of this user account. +Upon successful authentication, GitLab prompts the user with options, based on the email address received from the configured identity provider: + +- To create a unique account with the newly received email address. +- If the received email address matches one of the user's verified GitLab email addresses, the option to convert the existing account to a group-managed account. ([Introduced in GitLab 12.9](https://gitlab.com/gitlab-org/gitlab/issues/13481).) + Since use of the group-managed account requires the use of SSO, users of group-managed accounts will lose access to these accounts when they are no longer able to authenticate with the connected identity provider. In the case of an offboarded employee who has been removed from your identity provider: - The user will be unable to access the group (their credentials will no longer work on the identity provider when prompted to SSO). diff --git a/doc/user/incident_management/index.md b/doc/user/incident_management/index.md index c644c5801df..880083bf815 100644 --- a/doc/user/incident_management/index.md +++ b/doc/user/incident_management/index.md @@ -65,6 +65,11 @@ alert is resolved. Metrics can be embedded anywhere where GitLab Markdown is used, for example, descriptions and comments on issues and merge requests. +This can be useful for when you're sharing metrics, such as for discussing +an incident or performance issues, so you can output the dashboard directly +into any issue, merge request, epic, or any other Markdown text field in GitLab +by simply [copying and pasting the link to the metrics dashboard](../project/integrations/prometheus.md#embedding-gitlab-managed-kubernetes-metrics). + TIP: **Tip:** Both GitLab-hosted and Grafana metrics can also be [embedded in issue templates](../project/integrations/prometheus.md#embedding-metrics-in-issue-templates). @@ -73,6 +78,32 @@ Both GitLab-hosted and Grafana metrics can also be Learn how to embed [GitLab hosted metric charts](../project/integrations/prometheus.md#embedding-metric-charts-within-gitlab-flavored-markdown). +#### Context menu + +From each of the embedded metrics panels, you can access more details +about the data you are viewing from a context menu. + +You can access the context menu by clicking the **{ellipsis_v}** **More actions** +dropdown box above the upper right corner of the panel: + +The options are: + +- [View logs](#view-logs-ultimate) **(ULTIMATE)** +- [Download CSV](#download-csv) + +##### View logs **(ULTIMATE)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/201846) in GitLab Ultimate 12.8. + +This can be useful if you are triaging an application incident and need to +[explore logs](../project/integrations/prometheus.md#view-pod-logs-ultimate) +from across your application. It also helps you to understand +what is affecting your application's performance and quickly resolve any problems. + +##### Download CSV + +Data from embedded charts can be [downloaded as CSV](../project/integrations/prometheus.md#downloading-data-as-csv). + ### Grafana metrics Learn how to embed [Grafana hosted metric charts](../project/integrations/prometheus.md#embedding-grafana-charts). diff --git a/doc/user/project/integrations/img/embedded_metrics_markdown_v12_8.png b/doc/user/project/integrations/img/embedded_metrics_markdown_v12_8.png Binary files differnew file mode 100644 index 00000000000..ffd34705464 --- /dev/null +++ b/doc/user/project/integrations/img/embedded_metrics_markdown_v12_8.png diff --git a/doc/user/project/integrations/img/embedded_metrics_rendered_v12_8.png b/doc/user/project/integrations/img/embedded_metrics_rendered_v12_8.png Binary files differnew file mode 100644 index 00000000000..b024daaaa8e --- /dev/null +++ b/doc/user/project/integrations/img/embedded_metrics_rendered_v12_8.png diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md index 2f1be1c2257..bbe2f88795e 100644 --- a/doc/user/project/integrations/prometheus.md +++ b/doc/user/project/integrations/prometheus.md @@ -561,7 +561,9 @@ The options are: > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/122013) in GitLab 12.8. -If you have [Kubernetes Pod Logs](../clusters/kubernetes_pod_logs.md) enabled, you can navigate from the charts in the dashboard to view Pod Logs by clicking on the context menu in the upper-right corner. +If you have [Pod Logs](../clusters/kubernetes_pod_logs.md) enabled, +you can navigate from the charts in the dashboard to view Pod Logs by +clicking on the context menu in the upper-right corner. If you use the **Timeline zoom** function at the bottom of the chart, logs will narrow down to the time range you selected. @@ -677,10 +679,19 @@ Prometheus server. It is possible to display metrics charts within [GitLab Flavored Markdown](../../markdown.md#gitlab-flavored-markdown-gfm). The maximum number of embeds allowed in a GitLab Flavored Markdown field is 100. +This can be useful if you are sharing an application incident or performance +metrics to others and want to have relevant information directly available. + NOTE: **Note:** Requires [Kubernetes](prometheus_library/kubernetes.md) metrics. -To display a metric chart, include a link of the form `https://<root_url>/<project>/-/environments/<environment_id>/metrics`. +To display metric charts, include a link of the form `https://<root_url>/<project>/-/environments/<environment_id>/metrics`: + +![Embedded Metrics Markdown](img/embedded_metrics_markdown_v12_8.png) + +GitLab unfurls the link as an embedded metrics panel: + +![Embedded Metrics Rendered](img/embedded_metrics_rendered_v12_8.png) A single chart may also be embedded. You can generate a link to the chart via the dropdown located on the right side of the chart: diff --git a/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml b/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml index 73ae63c3092..ef77bbf5626 100644 --- a/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Managed-Cluster-Applications.gitlab-ci.yml @@ -1,6 +1,6 @@ apply: stage: deploy - image: "registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications:v0.8.0" + image: "registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications:v0.9.0" environment: name: production variables: @@ -11,6 +11,7 @@ apply: SENTRY_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/sentry/values.yaml GITLAB_RUNNER_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/gitlab-runner/values.yaml CILIUM_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/cilium/values.yaml + CILIUM_HUBBLE_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/cilium/hubble-values.yaml JUPYTERHUB_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/jupyterhub/values.yaml PROMETHEUS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/prometheus/values.yaml ELASTIC_STACK_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/elastic-stack/values.yaml diff --git a/lib/gitlab/sidekiq_config/cli_methods.rb b/lib/gitlab/sidekiq_config/cli_methods.rb index c95ba6faf1e..c49432f0fc6 100644 --- a/lib/gitlab/sidekiq_config/cli_methods.rb +++ b/lib/gitlab/sidekiq_config/cli_methods.rb @@ -26,9 +26,9 @@ module Gitlab QUERY_PREDICATES = { feature_category: :to_sym, has_external_dependencies: lambda { |value| value == 'true' }, - latency_sensitive: lambda { |value| value == 'true' }, name: :to_s, - resource_boundary: :to_sym + resource_boundary: :to_sym, + urgency: :to_sym }.freeze QueryError = Class.new(StandardError) diff --git a/lib/gitlab/sidekiq_config/dummy_worker.rb b/lib/gitlab/sidekiq_config/dummy_worker.rb index c2c8354b662..bd205c81931 100644 --- a/lib/gitlab/sidekiq_config/dummy_worker.rb +++ b/lib/gitlab/sidekiq_config/dummy_worker.rb @@ -9,7 +9,7 @@ module Gitlab ATTRIBUTE_METHODS = { feature_category: :get_feature_category, has_external_dependencies: :worker_has_external_dependencies?, - latency_sensitive: :latency_sensitive_worker?, + urgency: :get_urgency, resource_boundary: :get_worker_resource_boundary, idempotent: :idempotent?, weight: :get_weight diff --git a/lib/gitlab/sidekiq_config/worker.rb b/lib/gitlab/sidekiq_config/worker.rb index 4046ef54383..ec7a82f6459 100644 --- a/lib/gitlab/sidekiq_config/worker.rb +++ b/lib/gitlab/sidekiq_config/worker.rb @@ -7,8 +7,8 @@ module Gitlab attr_reader :klass delegate :feature_category_not_owned?, :get_feature_category, - :get_weight, :get_worker_resource_boundary, :idempotent?, - :latency_sensitive_worker?, :queue, :queue_namespace, + :get_urgency, :get_weight, :get_worker_resource_boundary, + :idempotent?, :queue, :queue_namespace, :worker_has_external_dependencies?, to: :klass @@ -49,7 +49,7 @@ module Gitlab name: queue, feature_category: get_feature_category, has_external_dependencies: worker_has_external_dependencies?, - latency_sensitive: latency_sensitive_worker?, + urgency: get_urgency, resource_boundary: get_worker_resource_boundary, weight: get_weight, idempotent: idempotent? diff --git a/lib/gitlab/sidekiq_logging/structured_logger.rb b/lib/gitlab/sidekiq_logging/structured_logger.rb index b45014d283f..1c36e4a4a5a 100644 --- a/lib/gitlab/sidekiq_logging/structured_logger.rb +++ b/lib/gitlab/sidekiq_logging/structured_logger.rb @@ -85,7 +85,7 @@ module Gitlab job['pid'] = ::Process.pid job.delete('args') unless ENV['SIDEKIQ_LOG_ARGUMENTS'] - job['args'] = Gitlab::Utils::LogLimitedArray.log_limited_array(job['args']) if job['args'] + job['args'] = Gitlab::Utils::LogLimitedArray.log_limited_array(job['args'].map(&:to_s)) if job['args'] job end diff --git a/lib/gitlab/sidekiq_middleware/metrics.rb b/lib/gitlab/sidekiq_middleware/metrics.rb index fbc34357323..693e35f2500 100644 --- a/lib/gitlab/sidekiq_middleware/metrics.rb +++ b/lib/gitlab/sidekiq_middleware/metrics.rb @@ -9,10 +9,10 @@ module Gitlab private def create_labels(worker_class, queue) - labels = { queue: queue.to_s, latency_sensitive: FALSE_LABEL, external_dependencies: FALSE_LABEL, feature_category: "", boundary: "" } + labels = { queue: queue.to_s, urgency: "", external_dependencies: FALSE_LABEL, feature_category: "", boundary: "" } return labels unless worker_class && worker_class.include?(WorkerAttributes) - labels[:latency_sensitive] = bool_as_label(worker_class.latency_sensitive_worker?) + labels[:urgency] = worker_class.get_urgency.to_s labels[:external_dependencies] = bool_as_label(worker_class.worker_has_external_dependencies?) feature_category = worker_class.get_feature_category diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 77337ddf9ea..42302cf8c0b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1682,6 +1682,9 @@ msgstr "" msgid "Alternate support URL for help page and help dropdown" msgstr "" +msgid "Alternatively, you can convert your account to a managed account by the %{group_name} group." +msgstr "" + msgid "Amazon EKS" msgstr "" @@ -8036,6 +8039,9 @@ msgstr "" msgid "Existing shares" msgstr "" +msgid "Existing sign in methods may be removed" +msgstr "" + msgid "Expand" msgstr "" @@ -20625,6 +20631,9 @@ msgstr "" msgid "Track your project with Audit Events." msgstr "" +msgid "Transfer ownership" +msgstr "" + msgid "Transfer project" msgstr "" @@ -22294,6 +22303,9 @@ msgstr "" msgid "You" msgstr "" +msgid "You are about to transfer the control of your account to %{group_name} group. This action is NOT reversible, you won't be able to access any of your groups and projects outside of %{group_name} once this transfer is complete." +msgstr "" + msgid "You are an admin, which means granting access to <strong>%{client_name}</strong> will allow them to interact with GitLab as an admin as well. Proceed with caution." msgstr "" @@ -22600,6 +22612,9 @@ msgstr "" msgid "You tried to fork %{link_to_the_project} but it failed for the following reason:" msgstr "" +msgid "You will be removed from existing projects/groups" +msgstr "" + msgid "You will lose all changes you've made to this file. This action cannot be undone." msgstr "" @@ -23230,10 +23245,10 @@ msgstr "" msgid "estimateCommand|%{slash_command} will update the estimated time with the latest command." msgstr "" -msgid "exceeds the limit of %{bytes} bytes for directory names" +msgid "exceeds the limit of %{bytes} bytes" msgstr "" -msgid "exceeds the limit of %{bytes} bytes for page titles" +msgid "exceeds the limit of %{bytes} bytes for directory name \"%{dirname}\"" msgstr "" msgid "expired on %{milestone_due_date}" diff --git a/package.json b/package.json index d001afae755..2d1905ab120 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "private": true, "scripts": { "check-dependencies": "scripts/frontend/check_dependencies.sh", + "block-dependencies": "node scripts/frontend/block_dependencies.js", "clean": "rm -rf public/assets tmp/cache/*-loader", "dev-server": "NODE_OPTIONS=\"--max-old-space-size=3584\" nodemon -w 'config/webpack.config.js' --exec 'webpack-dev-server --config config/webpack.config.js'", "eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives --ext .js,.vue .", @@ -54,7 +55,6 @@ "babel-loader": "^8.0.6", "babel-plugin-lodash": "^3.3.4", "bootstrap": "4.3.1", - "bootstrap-vue": "2.1.0", "brace-expansion": "^1.1.8", "cache-loader": "^4.1.0", "chart.js": "2.7.2", @@ -202,6 +202,9 @@ "yarn-check-webpack-plugin": "^1.2.0", "yarn-deduplicate": "^1.1.1" }, + "blockedDependencies": { + "bootstrap-vue": "https://docs.gitlab.com/ee/development/fe_guide/dependencies.md#bootstrapvue" + }, "resolutions": { "vue-jest/ts-jest": "24.0.0", "monaco-editor": "0.18.1" @@ -296,7 +296,9 @@ module QA autoload :Show, 'qa/page/project/operations/kubernetes/show' end - autoload :Metrics, 'qa/page/project/operations/metrics' + module Metrics + autoload :Show, 'qa/page/project/operations/metrics/show' + end end module Wiki diff --git a/qa/qa/fixtures/monitored_auto_devops/.gitlab-ci.yml b/qa/qa/fixtures/monitored_auto_devops/.gitlab-ci.yml index a65ae5aa1d9..d8ca7b591ed 100644 --- a/qa/qa/fixtures/monitored_auto_devops/.gitlab-ci.yml +++ b/qa/qa/fixtures/monitored_auto_devops/.gitlab-ci.yml @@ -7,7 +7,7 @@ image: alpine:latest variables: # AUTO_DEVOPS_DOMAIN is the application deployment domain and should be set as a variable at the group or project level. - AUTO_DEVOPS_DOMAIN: my-fake-domain.com + AUTO_DEVOPS_DOMAIN: $AUTO_DEVOPS_DOMAIN POSTGRES_USER: user POSTGRES_PASSWORD: testing-password diff --git a/qa/qa/page/project/operations/metrics.rb b/qa/qa/page/project/operations/metrics.rb deleted file mode 100644 index 710cb68ed41..00000000000 --- a/qa/qa/page/project/operations/metrics.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module QA - module Page - module Project - module Operations - class Metrics < Page::Base - EXPECTED_TITLE = 'Memory Usage (Total)' - LOADING_MESSAGE = 'Waiting for performance data' - - view 'app/assets/javascripts/monitoring/components/dashboard.vue' do - element :prometheus_graphs - end - - view 'app/assets/javascripts/monitoring/components/panel_type.vue' do - element :prometheus_graph_widgets - element :prometheus_widgets_dropdown - element :alert_widget_menu_item - end - - def wait_for_metrics - wait_for_data - return if has_metrics? - - wait_until(max_duration: 180) do - wait_for_data - has_metrics? - end - end - - def wait_for_data - wait_until(reload: false) { !has_text?(LOADING_MESSAGE) } if has_text?(LOADING_MESSAGE) - end - - def has_metrics? - within_element :prometheus_graphs do - has_text?(EXPECTED_TITLE) - end - end - end - end - end - end -end - -QA::Page::Project::Operations::Metrics.prepend_if_ee('QA::EE::Page::Project::Operations::Metrics') diff --git a/qa/qa/page/project/operations/metrics/show.rb b/qa/qa/page/project/operations/metrics/show.rb new file mode 100644 index 00000000000..c94c1f6590f --- /dev/null +++ b/qa/qa/page/project/operations/metrics/show.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module Operations + module Metrics + class Show < Page::Base + EXPECTED_TITLE = 'Memory Usage (Total)' + LOADING_MESSAGE = 'Waiting for performance data' + + view 'app/assets/javascripts/monitoring/components/dashboard.vue' do + element :prometheus_graphs + end + + view 'app/assets/javascripts/monitoring/components/panel_type.vue' do + element :prometheus_graph_widgets + element :prometheus_widgets_dropdown + element :alert_widget_menu_item + end + + def wait_for_metrics + wait_for_data + return if has_metrics? + + wait_until(max_duration: 180) do + wait_for_data + has_metrics? + end + end + + def has_metrics? + within_element :prometheus_graphs do + has_text?(EXPECTED_TITLE) + end + end + + private + + def wait_for_data + wait_until(reload: false) { !has_text?(LOADING_MESSAGE) } if has_text?(LOADING_MESSAGE) + end + end + end + end + end + end +end + +QA::Page::Project::Operations::Metrics::Show.prepend_if_ee('QA::EE::Page::Project::Operations::Metrics::Show') diff --git a/scripts/frontend/block_dependencies.js b/scripts/frontend/block_dependencies.js new file mode 100644 index 00000000000..c9257c9f72b --- /dev/null +++ b/scripts/frontend/block_dependencies.js @@ -0,0 +1,21 @@ +const path = require('path'); +const packageJson = require(path.join(process.cwd(), 'package.json')); +const blockedDependencies = packageJson.blockedDependencies || {}; +const dependencies = packageJson.dependencies; +const devDependencies = packageJson.devDependencies; +const blockedDependenciesNames = Object.keys(blockedDependencies); +const blockedDependenciesFound = blockedDependenciesNames.filter( + blockedDependency => dependencies[blockedDependency] || devDependencies[blockedDependency], +); + +if (blockedDependenciesFound.length) { + console.log('The following package.json dependencies are not allowed:'); + + blockedDependenciesFound.forEach(blockedDependency => { + const infoLink = blockedDependencies[blockedDependency]; + + console.log(`- ${blockedDependency}: See ${infoLink} for more information.`); + }); + + process.exit(-1); +} diff --git a/scripts/static-analysis b/scripts/static-analysis index 251462fad33..ede29b85b8d 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -45,6 +45,7 @@ def jobs_to_run(node_index, node_total) %w[yarn run eslint], %w[yarn run stylelint], %w[yarn run prettier-all], + %w[yarn run block-dependencies], %w[bundle exec rubocop --parallel], %w[scripts/lint-conflicts.sh], %w[scripts/lint-rugged], diff --git a/spec/frontend/helpers/dom_shims/image_element_properties.js b/spec/frontend/helpers/dom_shims/image_element_properties.js new file mode 100644 index 00000000000..525246e6ade --- /dev/null +++ b/spec/frontend/helpers/dom_shims/image_element_properties.js @@ -0,0 +1,12 @@ +Object.defineProperty(global.HTMLImageElement.prototype, 'src', { + get() { + return this.$_jest_src; + }, + set(val) { + this.$_jest_src = val; + + if (this.onload) { + this.onload(); + } + }, +}); diff --git a/spec/frontend/helpers/dom_shims/index.js b/spec/frontend/helpers/dom_shims/index.js index 1b73f0e2ef5..855b707a4cf 100644 --- a/spec/frontend/helpers/dom_shims/index.js +++ b/spec/frontend/helpers/dom_shims/index.js @@ -4,3 +4,4 @@ import './inner_text'; import './window_scroll_to'; import './scroll_by'; import './size_properties'; +import './image_element_properties'; diff --git a/spec/frontend/vue_mr_widget/mock_data.js b/spec/frontend/vue_mr_widget/mock_data.js new file mode 100644 index 00000000000..d11756d712a --- /dev/null +++ b/spec/frontend/vue_mr_widget/mock_data.js @@ -0,0 +1,318 @@ +import { SUCCESS } from '~/vue_merge_request_widget/components/deployment/constants'; + +export default { + id: 132, + iid: 22, + assignee_id: null, + author_id: 1, + description: '', + lock_version: null, + milestone_id: null, + position: 0, + state: 'merged', + title: 'Update README.md', + updated_by_id: null, + created_at: '2017-04-07T12:27:26.718Z', + updated_at: '2017-04-07T15:39:25.852Z', + time_estimate: 0, + total_time_spent: 0, + human_access: 'Maintainer', + human_time_estimate: null, + human_total_time_spent: null, + in_progress_merge_commit_sha: null, + merge_commit_sha: '53027d060246c8f47e4a9310fb332aa52f221775', + short_merge_commit_sha: '53027d06', + merge_error: null, + merge_params: { + force_remove_source_branch: null, + }, + merge_status: 'can_be_merged', + merge_user_id: null, + pipelines_empty_svg_path: '/path/to/svg', + source_branch: 'daaaa', + source_branch_link: 'daaaa', + source_project_id: 19, + source_project_full_path: '/group1/project1', + target_branch: 'master', + target_project_id: 19, + target_project_full_path: '/group2/project2', + merge_request_add_ci_config_path: '/group2/project2/new/pipeline', + metrics: { + merged_by: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', + }, + merged_at: '2017-04-07T15:39:25.696Z', + closed_by: null, + closed_at: null, + }, + author: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', + }, + merge_user: null, + diff_head_sha: '104096c51715e12e7ae41f9333e9fa35b73f385d', + diff_head_commit_short_id: '104096c5', + default_merge_commit_message: + "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", + pipeline: { + id: 172, + user: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', + }, + active: false, + coverage: '92.16', + path: '/root/acets-app/pipelines/172', + details: { + status: { + icon: 'status_success', + favicon: 'favicon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/acets-app/pipelines/172', + }, + duration: null, + finished_at: '2017-04-07T14:00:14.256Z', + stages: [ + { + name: 'build', + title: 'build: failed', + status: { + icon: 'status_failed', + favicon: 'favicon_status_failed', + text: 'failed', + label: 'failed', + group: 'failed', + has_details: true, + details_path: '/root/acets-app/pipelines/172#build', + }, + path: '/root/acets-app/pipelines/172#build', + dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=build', + }, + { + name: 'review', + title: 'review: skipped', + status: { + icon: 'status_skipped', + favicon: 'favicon_status_skipped', + text: 'skipped', + label: 'skipped', + group: 'skipped', + has_details: true, + details_path: '/root/acets-app/pipelines/172#review', + }, + path: '/root/acets-app/pipelines/172#review', + dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=review', + }, + ], + artifacts: [], + manual_actions: [ + { + name: 'stop_review', + path: '/root/acets-app/builds/1427/play', + playable: false, + }, + ], + }, + flags: { + latest: false, + triggered: false, + stuck: false, + yaml_errors: false, + retryable: true, + cancelable: false, + merge_request_pipeline: false, + detached_merge_request_pipeline: true, + }, + ref: { + name: 'daaaa', + path: '/root/acets-app/tree/daaaa', + tag: false, + branch: true, + }, + merge_request: { + iid: 1, + path: '/root/detached-merge-request-pipelines/-/merge_requests/1', + title: 'Update README.md', + source_branch: 'feature-1', + source_branch_path: '/root/detached-merge-request-pipelines/branches/feature-1', + target_branch: 'master', + target_branch_path: '/root/detached-merge-request-pipelines/branches/master', + }, + commit: { + id: '104096c51715e12e7ae41f9333e9fa35b73f385d', + short_id: '104096c5', + title: 'Update README.md', + created_at: '2017-04-07T15:27:18.000+03:00', + parent_ids: ['2396536178668d8930c29d904e53bd4d06228b32'], + message: 'Update README.md', + author_name: 'Administrator', + author_email: 'admin@example.com', + authored_date: '2017-04-07T15:27:18.000+03:00', + committer_name: 'Administrator', + committer_email: 'admin@example.com', + committed_date: '2017-04-07T15:27:18.000+03:00', + author: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', + }, + author_gravatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + commit_url: + 'http://localhost:3000/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', + commit_path: '/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', + }, + retry_path: '/root/acets-app/pipelines/172/retry', + created_at: '2017-04-07T12:27:19.520Z', + updated_at: '2017-04-07T15:28:44.800Z', + }, + pipelineCoverageDelta: '15.25', + work_in_progress: false, + source_branch_exists: false, + mergeable_discussions_state: true, + conflicts_can_be_resolved_in_ui: false, + branch_missing: true, + commits_count: 1, + has_conflicts: false, + can_be_merged: true, + has_ci: true, + ci_status: 'success', + pipeline_status_path: '/root/acets-app/-/merge_requests/22/pipeline_status', + issues_links: { + closing: '', + mentioned_but_not_closing: '', + }, + current_user: { + can_resolve_conflicts: true, + can_remove_source_branch: false, + can_revert_on_current_merge_request: true, + can_cherry_pick_on_current_merge_request: true, + }, + target_branch_path: '/root/acets-app/branches/master', + source_branch_path: '/root/acets-app/branches/daaaa', + conflict_resolution_ui_path: '/root/acets-app/-/merge_requests/22/conflicts', + remove_wip_path: '/root/acets-app/-/merge_requests/22/remove_wip', + cancel_auto_merge_path: '/root/acets-app/-/merge_requests/22/cancel_auto_merge', + create_issue_to_resolve_discussions_path: + '/root/acets-app/-/issues/new?merge_request_to_resolve_discussions_of=22', + merge_path: '/root/acets-app/-/merge_requests/22/merge', + cherry_pick_in_fork_path: + '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+revert+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', + revert_in_fork_path: + '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+cherry-pick+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', + email_patches_path: '/root/acets-app/-/merge_requests/22.patch', + plain_diff_path: '/root/acets-app/-/merge_requests/22.diff', + merge_request_basic_path: '/root/acets-app/-/merge_requests/22.json?serializer=basic', + merge_request_widget_path: '/root/acets-app/-/merge_requests/22/widget.json', + merge_request_cached_widget_path: '/cached.json', + merge_check_path: '/root/acets-app/-/merge_requests/22/merge_check', + ci_environments_status_url: '/root/acets-app/-/merge_requests/22/ci_environments_status', + project_archived: false, + default_merge_commit_message_with_description: + "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", + default_squash_commit_message: 'Test squash commit message', + diverged_commits_count: 0, + only_allow_merge_if_pipeline_succeeds: false, + commit_change_content_path: '/root/acets-app/-/merge_requests/22/commit_change_content', + merge_commit_path: + 'http://localhost:3000/root/acets-app/commit/53027d060246c8f47e4a9310fb332aa52f221775', + troubleshooting_docs_path: 'help', + merge_request_pipelines_docs_path: '/help/ci/merge_request_pipelines/index.md', + merge_train_when_pipeline_succeeds_docs_path: + '/help/ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/#startadd-to-merge-train-when-pipeline-succeeds', + squash: true, + visual_review_app_available: true, + merge_trains_enabled: true, + merge_trains_count: 3, + merge_train_index: 1, +}; + +export const mockStore = { + pipeline: { + id: 0, + details: { + status: { + details_path: '/root/review-app-tester/pipelines/66', + favicon: + '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2. png', + group: 'success-with-warnings', + has_details: true, + icon: 'status_warning', + illustration: null, + label: 'passed with warnings', + text: 'passed', + tooltip: 'passed', + }, + }, + flags: {}, + ref: {}, + }, + mergePipeline: { + id: 1, + details: { + status: { + details_path: '/root/review-app-tester/pipelines/66', + favicon: + '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2. png', + group: 'success-with-warnings', + has_details: true, + icon: 'status_warning', + illustration: null, + label: 'passed with warnings', + text: 'passed', + tooltip: 'passed', + }, + }, + flags: {}, + ref: {}, + }, + targetBranch: 'target-branch', + sourceBranch: 'source-branch', + sourceBranchLink: 'source-branch-link', + deployments: [ + { + id: 0, + name: 'bogus', + external_url: 'https://fake.com', + external_url_formatted: 'https://fake.com', + status: SUCCESS, + }, + { + id: 1, + name: 'bogus-docs', + external_url: 'https://fake.com', + external_url_formatted: 'https://fake.com', + status: SUCCESS, + }, + ], + postMergeDeployments: [ + { id: 0, name: 'prod', status: SUCCESS }, + { id: 1, name: 'prod-docs', status: SUCCESS }, + ], + troubleshootingDocsPath: 'troubleshooting-docs-path', + ciStatus: 'ci-status', + hasCI: true, + exposedArtifactsPath: 'exposed_artifacts.json', +}; diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js index 4237bdd80be..5edf41b1ec6 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js @@ -1,16 +1,18 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; -import waitForPromises from 'spec/helpers/wait_for_promises'; +import mountComponent from 'helpers/vue_mount_component_helper'; import axios from '~/lib/utils/axios_utils'; import mrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue'; import eventHub from '~/vue_merge_request_widget/event_hub'; import notify from '~/lib/utils/notify'; +import SmartInterval from '~/smart_interval'; import { stateKey } from '~/vue_merge_request_widget/stores/state_maps'; import mockData from './mock_data'; import { faviconDataUrl, overlayDataUrl } from '../lib/utils/mock_data'; import { SUCCESS } from '~/vue_merge_request_widget/components/deployment/constants'; +jest.mock('~/smart_interval'); + const returnPromise = data => new Promise(resolve => { resolve({ @@ -26,7 +28,6 @@ describe('mrWidgetOptions', () => { const COLLABORATION_MESSAGE = 'Allows commits from members who can merge to the target branch'; beforeEach(() => { - jasmine.clock().install(); // Prevent component mounting delete mrWidgetOptions.el; @@ -41,9 +42,7 @@ describe('mrWidgetOptions', () => { }); afterEach(() => { - jasmine.clock().uninstall(); mock.restore(); - vm.$destroy(); vm = null; @@ -59,11 +58,13 @@ describe('mrWidgetOptions', () => { vm = mountComponent(MrWidgetOptions, { mrData: { ...mockData }, }); + + return axios.waitForAll(); }; describe('default', () => { beforeEach(() => { - createComponent(); + return createComponent(); }); describe('data', () => { @@ -259,9 +260,9 @@ describe('mrWidgetOptions', () => { describe('methods', () => { describe('checkStatus', () => { it('should tell service to check status', () => { - spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); - spyOn(vm.mr, 'setData'); - spyOn(vm, 'handleNotification'); + jest.spyOn(vm.service, 'checkStatus').mockReturnValue(returnPromise(mockData)); + jest.spyOn(vm.mr, 'setData').mockImplementation(() => {}); + jest.spyOn(vm, 'handleNotification').mockImplementation(() => {}); let isCbExecuted = false; const cb = () => { @@ -281,33 +282,33 @@ describe('mrWidgetOptions', () => { describe('initPolling', () => { it('should call SmartInterval', () => { - spyOn(vm, 'checkStatus').and.returnValue(Promise.resolve()); vm.initPolling(); - expect(vm.checkStatus).not.toHaveBeenCalled(); - - jasmine.clock().tick(10000); - - expect(vm.pollingInterval).toBeDefined(); - expect(vm.checkStatus).toHaveBeenCalled(); + expect(SmartInterval).toHaveBeenCalledWith( + expect.objectContaining({ + callback: vm.checkStatus, + }), + ); }); }); describe('initDeploymentsPolling', () => { it('should call SmartInterval', () => { - spyOn(vm, 'fetchDeployments').and.returnValue(Promise.resolve()); vm.initDeploymentsPolling(); - expect(vm.deploymentsInterval).toBeDefined(); - expect(vm.fetchDeployments).toHaveBeenCalled(); + expect(SmartInterval).toHaveBeenCalledWith( + expect.objectContaining({ + callback: vm.fetchPreMergeDeployments, + }), + ); }); }); describe('fetchDeployments', () => { it('should fetch deployments', () => { - spyOn(vm.service, 'fetchDeployments').and.returnValue( - returnPromise([{ id: 1, status: SUCCESS }]), - ); + jest + .spyOn(vm.service, 'fetchDeployments') + .mockReturnValue(returnPromise([{ id: 1, status: SUCCESS }])); vm.fetchPreMergeDeployments(); @@ -321,9 +322,9 @@ describe('mrWidgetOptions', () => { describe('fetchActionsContent', () => { it('should fetch content of Cherry Pick and Revert modals', () => { - spyOn(vm.service, 'fetchMergeActionsContent').and.returnValue( - returnPromise('hello world'), - ); + jest + .spyOn(vm.service, 'fetchMergeActionsContent') + .mockReturnValue(returnPromise('hello world')); vm.fetchActionsContent(); @@ -335,59 +336,48 @@ describe('mrWidgetOptions', () => { }); describe('bindEventHubListeners', () => { - it('should bind eventHub listeners', () => { - spyOn(vm, 'checkStatus').and.returnValue(() => {}); - spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); - spyOn(vm, 'fetchActionsContent'); - spyOn(vm.mr, 'setData'); - spyOn(vm, 'resumePolling'); - spyOn(vm, 'stopPolling'); - spyOn(eventHub, '$on').and.callThrough(); - - return waitForPromises().then(() => { - eventHub.$emit('SetBranchRemoveFlag', ['flag']); - - expect(vm.mr.isRemovingSourceBranch).toEqual('flag'); - - eventHub.$emit('FailedToMerge'); + it.each` + event | method | methodArgs + ${'MRWidgetUpdateRequested'} | ${'checkStatus'} | ${x => [x]} + ${'MRWidgetRebaseSuccess'} | ${'checkStatus'} | ${x => [x, true]} + ${'FetchActionsContent'} | ${'fetchActionsContent'} | ${() => []} + ${'EnablePolling'} | ${'resumePolling'} | ${() => []} + ${'DisablePolling'} | ${'stopPolling'} | ${() => []} + `('should bind to $event', ({ event, method, methodArgs }) => { + jest.spyOn(vm, method).mockImplementation(); - expect(vm.mr.state).toEqual('failedToMerge'); + const eventArg = {}; + eventHub.$emit(event, eventArg); - eventHub.$emit('UpdateWidgetData', mockData); - - expect(vm.mr.setData).toHaveBeenCalledWith(mockData); - - eventHub.$emit('EnablePolling'); - - expect(vm.resumePolling).toHaveBeenCalled(); + expect(vm[method]).toHaveBeenCalledWith(...methodArgs(eventArg)); + }); - eventHub.$emit('DisablePolling'); + it('should bind to SetBranchRemoveFlag', () => { + expect(vm.mr.isRemovingSourceBranch).toBe(false); - expect(vm.stopPolling).toHaveBeenCalled(); + eventHub.$emit('SetBranchRemoveFlag', [true]); - const listenersWithServiceRequest = { - MRWidgetUpdateRequested: true, - FetchActionsContent: true, - }; + expect(vm.mr.isRemovingSourceBranch).toBe(true); + }); - const allArgs = eventHub.$on.calls.allArgs(); - allArgs.forEach(params => { - const eventName = params[0]; - const callback = params[1]; + it('should bind to FailedToMerge', () => { + vm.mr.state = ''; + vm.mr.mergeError = ''; - if (listenersWithServiceRequest[eventName]) { - listenersWithServiceRequest[eventName] = callback; - } - }); + const mergeError = 'Something bad happened!'; + eventHub.$emit('FailedToMerge', mergeError); - listenersWithServiceRequest.MRWidgetUpdateRequested(); + expect(vm.mr.state).toBe('failedToMerge'); + expect(vm.mr.mergeError).toBe(mergeError); + }); - expect(vm.checkStatus).toHaveBeenCalled(); + it('should bind to UpdateWidgetData', () => { + jest.spyOn(vm.mr, 'setData').mockImplementation(); - listenersWithServiceRequest.FetchActionsContent(); + const data = { ...mockData }; + eventHub.$emit('UpdateWidgetData', data); - expect(vm.fetchActionsContent).toHaveBeenCalled(); - }); + expect(vm.mr.setData).toHaveBeenCalledWith(data); }); }); @@ -419,8 +409,8 @@ describe('mrWidgetOptions', () => { expect(faviconElement.getAttribute('href')).not.toEqual(null); expect(faviconElement.getAttribute('href')).not.toEqual(overlayDataUrl); expect(faviconElement.getAttribute('href')).not.toEqual(faviconDataUrl); - done(); }) + .then(done) .catch(done.fail); }); @@ -443,7 +433,7 @@ describe('mrWidgetOptions', () => { }; beforeEach(() => { - spyOn(notify, 'notifyMe'); + jest.spyOn(notify, 'notifyMe').mockImplementation(() => {}); vm.mr.ciStatus = 'failed'; vm.mr.gitlabLogo = 'logo.png'; @@ -478,25 +468,23 @@ describe('mrWidgetOptions', () => { }); describe('resumePolling', () => { - it('should call stopTimer on pollingInterval', () => - waitForPromises().then(() => { - spyOn(vm.pollingInterval, 'resume'); + it('should call stopTimer on pollingInterval', () => { + jest.spyOn(vm.pollingInterval, 'resume').mockImplementation(() => {}); - vm.resumePolling(); + vm.resumePolling(); - expect(vm.pollingInterval.resume).toHaveBeenCalled(); - })); + expect(vm.pollingInterval.resume).toHaveBeenCalled(); + }); }); describe('stopPolling', () => { - it('should call stopTimer on pollingInterval', () => - waitForPromises().then(() => { - spyOn(vm.pollingInterval, 'stopTimer'); + it('should call stopTimer on pollingInterval', () => { + jest.spyOn(vm.pollingInterval, 'stopTimer').mockImplementation(() => {}); - vm.stopPolling(); + vm.stopPolling(); - expect(vm.pollingInterval.stopTimer).toHaveBeenCalled(); - })); + expect(vm.pollingInterval.stopTimer).toHaveBeenCalled(); + }); }); }); @@ -814,8 +802,12 @@ describe('mrWidgetOptions', () => { describe('given suggestPipeline feature flag is enabled', () => { beforeEach(() => { + // This is needed because some grandchildren Bootstrap components throw warnings + // https://gitlab.com/gitlab-org/gitlab/issues/208458 + jest.spyOn(console, 'warn').mockImplementation(); + gon.features = { suggestPipeline: true }; - createComponent(); + return createComponent(); }); it('should suggest pipelines when none exist', () => { diff --git a/spec/graphql/mutations/concerns/mutations/resolves_issuable_spec.rb b/spec/graphql/mutations/concerns/mutations/resolves_issuable_spec.rb new file mode 100644 index 00000000000..064ad90f707 --- /dev/null +++ b/spec/graphql/mutations/concerns/mutations/resolves_issuable_spec.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Mutations::ResolvesIssuable do + let(:mutation_class) do + Class.new(Mutations::BaseMutation) do + include Mutations::ResolvesIssuable + end + end + + let(:project) { create(:project) } + let(:user) { create(:user) } + let(:context) { { current_user: user } } + let(:mutation) { mutation_class.new(object: nil, context: context) } + + shared_examples 'resolving an issuable' do |type| + context 'when user has access' do + let(:source) { type == :merge_request ? 'source_project' : 'project' } + let(:issuable) { create(type, author: user, "#{source}" => project) } + + subject { mutation.resolve_issuable(type: type, parent_path: project.full_path, iid: issuable.iid) } + + before do + project.add_developer(user) + end + + it 'resolves issuable by iid' do + result = type == :merge_request ? subject.sync : subject + expect(result).to eq(issuable) + end + + it 'uses the correct Resolver to resolve issuable' do + resolver_class = "Resolvers::#{type.to_s.classify.pluralize}Resolver".constantize + resolved_project = mutation.resolve_project(full_path: project.full_path) + + allow(mutation).to receive(:resolve_project) + .with(full_path: project.full_path) + .and_return(resolved_project) + + expect(resolver_class).to receive(:new) + .with(object: resolved_project, context: context) + .and_call_original + + subject + end + + it 'uses the ResolvesProject to resolve project' do + expect(Resolvers::ProjectResolver).to receive(:new) + .with(object: nil, context: context) + .and_call_original + + subject + end + + it 'returns nil if issuable is not found' do + result = mutation.resolve_issuable(type: type, parent_path: project.full_path, iid: "100") + result = type == :merge_request ? result.sync : result + + expect(result).to be_nil + end + end + end + + context 'with issues' do + it_behaves_like 'resolving an issuable', :issue + end + + context 'with merge requests' do + it_behaves_like 'resolving an issuable', :merge_request + end +end diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index 68aa0137cd5..6698d8970e7 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -39,6 +39,25 @@ describe FormHelper do end end + it 'renders messages truncated if requested' do + model = double(errors: errors_stub('Error 1', 'Error 2')) + model.errors.add(:title, 'is truncated') + model.errors.add(:base, 'Error 3') + + expect(model.class).to receive(:human_attribute_name) do |attribute| + attribute.to_s.capitalize + end + + errors = helper.form_errors(model, truncate: :title) + + aggregate_failures do + expect(errors).to include('<li>Error 1</li>') + expect(errors).to include('<li>Error 2</li>') + expect(errors).to include('<li><span class="str-truncated-100">Title is truncated</span></li>') + expect(errors).to include('<li>Error 3</li>') + end + end + def errors_stub(*messages) ActiveModel::Errors.new(double).tap do |errors| messages.each { |msg| errors.add(:base, msg) } diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index d11756d712a..7783fcb6f93 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -1,318 +1,2 @@ -import { SUCCESS } from '~/vue_merge_request_widget/components/deployment/constants'; - -export default { - id: 132, - iid: 22, - assignee_id: null, - author_id: 1, - description: '', - lock_version: null, - milestone_id: null, - position: 0, - state: 'merged', - title: 'Update README.md', - updated_by_id: null, - created_at: '2017-04-07T12:27:26.718Z', - updated_at: '2017-04-07T15:39:25.852Z', - time_estimate: 0, - total_time_spent: 0, - human_access: 'Maintainer', - human_time_estimate: null, - human_total_time_spent: null, - in_progress_merge_commit_sha: null, - merge_commit_sha: '53027d060246c8f47e4a9310fb332aa52f221775', - short_merge_commit_sha: '53027d06', - merge_error: null, - merge_params: { - force_remove_source_branch: null, - }, - merge_status: 'can_be_merged', - merge_user_id: null, - pipelines_empty_svg_path: '/path/to/svg', - source_branch: 'daaaa', - source_branch_link: 'daaaa', - source_project_id: 19, - source_project_full_path: '/group1/project1', - target_branch: 'master', - target_project_id: 19, - target_project_full_path: '/group2/project2', - merge_request_add_ci_config_path: '/group2/project2/new/pipeline', - metrics: { - merged_by: { - name: 'Administrator', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - web_url: 'http://localhost:3000/root', - }, - merged_at: '2017-04-07T15:39:25.696Z', - closed_by: null, - closed_at: null, - }, - author: { - name: 'Administrator', - username: 'root', - id: 1, - state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - web_url: 'http://localhost:3000/root', - }, - merge_user: null, - diff_head_sha: '104096c51715e12e7ae41f9333e9fa35b73f385d', - diff_head_commit_short_id: '104096c5', - default_merge_commit_message: - "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", - pipeline: { - id: 172, - user: { - name: 'Administrator', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - web_url: 'http://localhost:3000/root', - }, - active: false, - coverage: '92.16', - path: '/root/acets-app/pipelines/172', - details: { - status: { - icon: 'status_success', - favicon: 'favicon_status_success', - text: 'passed', - label: 'passed', - group: 'success', - has_details: true, - details_path: '/root/acets-app/pipelines/172', - }, - duration: null, - finished_at: '2017-04-07T14:00:14.256Z', - stages: [ - { - name: 'build', - title: 'build: failed', - status: { - icon: 'status_failed', - favicon: 'favicon_status_failed', - text: 'failed', - label: 'failed', - group: 'failed', - has_details: true, - details_path: '/root/acets-app/pipelines/172#build', - }, - path: '/root/acets-app/pipelines/172#build', - dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=build', - }, - { - name: 'review', - title: 'review: skipped', - status: { - icon: 'status_skipped', - favicon: 'favicon_status_skipped', - text: 'skipped', - label: 'skipped', - group: 'skipped', - has_details: true, - details_path: '/root/acets-app/pipelines/172#review', - }, - path: '/root/acets-app/pipelines/172#review', - dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=review', - }, - ], - artifacts: [], - manual_actions: [ - { - name: 'stop_review', - path: '/root/acets-app/builds/1427/play', - playable: false, - }, - ], - }, - flags: { - latest: false, - triggered: false, - stuck: false, - yaml_errors: false, - retryable: true, - cancelable: false, - merge_request_pipeline: false, - detached_merge_request_pipeline: true, - }, - ref: { - name: 'daaaa', - path: '/root/acets-app/tree/daaaa', - tag: false, - branch: true, - }, - merge_request: { - iid: 1, - path: '/root/detached-merge-request-pipelines/-/merge_requests/1', - title: 'Update README.md', - source_branch: 'feature-1', - source_branch_path: '/root/detached-merge-request-pipelines/branches/feature-1', - target_branch: 'master', - target_branch_path: '/root/detached-merge-request-pipelines/branches/master', - }, - commit: { - id: '104096c51715e12e7ae41f9333e9fa35b73f385d', - short_id: '104096c5', - title: 'Update README.md', - created_at: '2017-04-07T15:27:18.000+03:00', - parent_ids: ['2396536178668d8930c29d904e53bd4d06228b32'], - message: 'Update README.md', - author_name: 'Administrator', - author_email: 'admin@example.com', - authored_date: '2017-04-07T15:27:18.000+03:00', - committer_name: 'Administrator', - committer_email: 'admin@example.com', - committed_date: '2017-04-07T15:27:18.000+03:00', - author: { - name: 'Administrator', - username: 'root', - id: 1, - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - web_url: 'http://localhost:3000/root', - }, - author_gravatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - commit_url: - 'http://localhost:3000/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', - commit_path: '/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', - }, - retry_path: '/root/acets-app/pipelines/172/retry', - created_at: '2017-04-07T12:27:19.520Z', - updated_at: '2017-04-07T15:28:44.800Z', - }, - pipelineCoverageDelta: '15.25', - work_in_progress: false, - source_branch_exists: false, - mergeable_discussions_state: true, - conflicts_can_be_resolved_in_ui: false, - branch_missing: true, - commits_count: 1, - has_conflicts: false, - can_be_merged: true, - has_ci: true, - ci_status: 'success', - pipeline_status_path: '/root/acets-app/-/merge_requests/22/pipeline_status', - issues_links: { - closing: '', - mentioned_but_not_closing: '', - }, - current_user: { - can_resolve_conflicts: true, - can_remove_source_branch: false, - can_revert_on_current_merge_request: true, - can_cherry_pick_on_current_merge_request: true, - }, - target_branch_path: '/root/acets-app/branches/master', - source_branch_path: '/root/acets-app/branches/daaaa', - conflict_resolution_ui_path: '/root/acets-app/-/merge_requests/22/conflicts', - remove_wip_path: '/root/acets-app/-/merge_requests/22/remove_wip', - cancel_auto_merge_path: '/root/acets-app/-/merge_requests/22/cancel_auto_merge', - create_issue_to_resolve_discussions_path: - '/root/acets-app/-/issues/new?merge_request_to_resolve_discussions_of=22', - merge_path: '/root/acets-app/-/merge_requests/22/merge', - cherry_pick_in_fork_path: - '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+revert+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', - revert_in_fork_path: - '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+cherry-pick+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', - email_patches_path: '/root/acets-app/-/merge_requests/22.patch', - plain_diff_path: '/root/acets-app/-/merge_requests/22.diff', - merge_request_basic_path: '/root/acets-app/-/merge_requests/22.json?serializer=basic', - merge_request_widget_path: '/root/acets-app/-/merge_requests/22/widget.json', - merge_request_cached_widget_path: '/cached.json', - merge_check_path: '/root/acets-app/-/merge_requests/22/merge_check', - ci_environments_status_url: '/root/acets-app/-/merge_requests/22/ci_environments_status', - project_archived: false, - default_merge_commit_message_with_description: - "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", - default_squash_commit_message: 'Test squash commit message', - diverged_commits_count: 0, - only_allow_merge_if_pipeline_succeeds: false, - commit_change_content_path: '/root/acets-app/-/merge_requests/22/commit_change_content', - merge_commit_path: - 'http://localhost:3000/root/acets-app/commit/53027d060246c8f47e4a9310fb332aa52f221775', - troubleshooting_docs_path: 'help', - merge_request_pipelines_docs_path: '/help/ci/merge_request_pipelines/index.md', - merge_train_when_pipeline_succeeds_docs_path: - '/help/ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/#startadd-to-merge-train-when-pipeline-succeeds', - squash: true, - visual_review_app_available: true, - merge_trains_enabled: true, - merge_trains_count: 3, - merge_train_index: 1, -}; - -export const mockStore = { - pipeline: { - id: 0, - details: { - status: { - details_path: '/root/review-app-tester/pipelines/66', - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2. png', - group: 'success-with-warnings', - has_details: true, - icon: 'status_warning', - illustration: null, - label: 'passed with warnings', - text: 'passed', - tooltip: 'passed', - }, - }, - flags: {}, - ref: {}, - }, - mergePipeline: { - id: 1, - details: { - status: { - details_path: '/root/review-app-tester/pipelines/66', - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2. png', - group: 'success-with-warnings', - has_details: true, - icon: 'status_warning', - illustration: null, - label: 'passed with warnings', - text: 'passed', - tooltip: 'passed', - }, - }, - flags: {}, - ref: {}, - }, - targetBranch: 'target-branch', - sourceBranch: 'source-branch', - sourceBranchLink: 'source-branch-link', - deployments: [ - { - id: 0, - name: 'bogus', - external_url: 'https://fake.com', - external_url_formatted: 'https://fake.com', - status: SUCCESS, - }, - { - id: 1, - name: 'bogus-docs', - external_url: 'https://fake.com', - external_url_formatted: 'https://fake.com', - status: SUCCESS, - }, - ], - postMergeDeployments: [ - { id: 0, name: 'prod', status: SUCCESS }, - { id: 1, name: 'prod-docs', status: SUCCESS }, - ], - troubleshootingDocsPath: 'troubleshooting-docs-path', - ciStatus: 'ci-status', - hasCI: true, - exposedArtifactsPath: 'exposed_artifacts.json', -}; +export { default } from '../../frontend/vue_mr_widget/mock_data'; +export * from '../../frontend/vue_mr_widget/mock_data'; diff --git a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb index 4ba5726732c..8b93ef86eba 100644 --- a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb +++ b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb @@ -124,28 +124,28 @@ describe Gitlab::SidekiqConfig::CliMethods do name: 'a', feature_category: :category_a, has_external_dependencies: false, - latency_sensitive: false, + urgency: :default, resource_boundary: :cpu }, { name: 'a:2', feature_category: :category_a, has_external_dependencies: false, - latency_sensitive: true, + urgency: :high, resource_boundary: :none }, { name: 'b', feature_category: :category_b, has_external_dependencies: true, - latency_sensitive: true, + urgency: :high, resource_boundary: :memory }, { name: 'c', feature_category: :category_c, has_external_dependencies: false, - latency_sensitive: false, + urgency: :none, resource_boundary: :memory } ] @@ -166,12 +166,12 @@ describe Gitlab::SidekiqConfig::CliMethods do 'has_external_dependencies=true|has_external_dependencies=false' | %w(a a:2 b c) 'has_external_dependencies!=true' | %w(a a:2 c) - # latency_sensitive - 'latency_sensitive=true' | %w(a:2 b) - 'latency_sensitive=false' | %w(a c) - 'latency_sensitive=true,false' | %w(a a:2 b c) - 'latency_sensitive=true|latency_sensitive=false' | %w(a a:2 b c) - 'latency_sensitive!=true' | %w(a c) + # urgency + 'urgency=high' | %w(a:2 b) + 'urgency=default' | %w(a) + 'urgency=high,default,none' | %w(a a:2 b c) + 'urgency=default|urgency=none' | %w(a c) + 'urgency!=high' | %w(a c) # name 'name=a' | %w(a) @@ -186,8 +186,8 @@ describe Gitlab::SidekiqConfig::CliMethods do 'resource_boundary!=memory,cpu' | %w(a:2) # combinations - 'feature_category=category_a&latency_sensitive=true' | %w(a:2) - 'feature_category=category_a&latency_sensitive=true|feature_category=category_c' | %w(a:2 c) + 'feature_category=category_a&urgency=high' | %w(a:2) + 'feature_category=category_a&urgency=high|feature_category=category_c' | %w(a:2 c) end with_them do diff --git a/spec/lib/gitlab/sidekiq_config/worker_spec.rb b/spec/lib/gitlab/sidekiq_config/worker_spec.rb index fcdce8f9432..71fafbf0656 100644 --- a/spec/lib/gitlab/sidekiq_config/worker_spec.rb +++ b/spec/lib/gitlab/sidekiq_config/worker_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::SidekiqConfig::Worker do get_feature_category: attributes[:feature_category], get_weight: attributes[:weight], get_worker_resource_boundary: attributes[:resource_boundary], - latency_sensitive_worker?: attributes[:latency_sensitive], + get_urgency: attributes[:urgency], worker_has_external_dependencies?: attributes[:has_external_dependencies], idempotent?: attributes[:idempotent] ) @@ -47,7 +47,7 @@ describe Gitlab::SidekiqConfig::Worker do describe 'delegations' do [ :feature_category_not_owned?, :get_feature_category, :get_weight, - :get_worker_resource_boundary, :latency_sensitive_worker?, :queue, + :get_worker_resource_boundary, :get_urgency, :queue, :queue_namespace, :worker_has_external_dependencies? ].each do |meth| it "delegates #{meth} to the worker class" do @@ -88,7 +88,7 @@ describe Gitlab::SidekiqConfig::Worker do attributes_a = { feature_category: :source_code_management, has_external_dependencies: false, - latency_sensitive: false, + urgency: :default, resource_boundary: :memory, weight: 2, idempotent: true @@ -97,7 +97,7 @@ describe Gitlab::SidekiqConfig::Worker do attributes_b = { feature_category: :not_owned, has_external_dependencies: true, - latency_sensitive: true, + urgency: :high, resource_boundary: :unknown, weight: 3, idempotent: false diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb index f294d7f7fcd..bd04d30f85f 100644 --- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do let(:job) do { "class" => "TestWorker", - "args" => [1234, 'hello'], + "args" => [1234, 'hello', { 'key' => 'value' }], "retry" => false, "queue" => "cronjob:test_queue", "queue_namespace" => "cronjob", @@ -30,6 +30,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do let(:clock_thread_cputime_end) { 1.333333799 } let(:start_payload) do job.except('error_backtrace', 'error_class', 'error_message').merge( + 'args' => %w(1234 hello {"key"=>"value"}), 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start', 'job_status' => 'start', 'pid' => Process.pid, @@ -99,13 +100,27 @@ describe Gitlab::SidekiqLogging::StructuredLogger do end end + it 'does not modify the job' do + Timecop.freeze(timestamp) do + job_copy = job.deep_dup + + allow(logger).to receive(:info) + allow(subject).to receive(:log_job_start).and_call_original + allow(subject).to receive(:log_job_done).and_call_original + + subject.call(job, 'test_queue') do + expect(job).to eq(job_copy) + end + end + end + context 'when the job args are bigger than the maximum allowed' do it 'keeps args from the front until they exceed the limit' do Timecop.freeze(timestamp) do half_limit = Gitlab::Utils::LogLimitedArray::MAXIMUM_ARRAY_LENGTH / 2 job['args'] = [1, 2, 'a' * half_limit, 'b' * half_limit, 3] - expected_args = job['args'].take(3) + ['...'] + expected_args = job['args'].take(3).map(&:to_s) + ['...'] expect(logger).to receive(:info).with(start_payload.merge('args' => expected_args)).ordered expect(logger).to receive(:info).with(end_payload.merge('args' => expected_args)).ordered diff --git a/spec/lib/gitlab/sidekiq_middleware/client_metrics_spec.rb b/spec/lib/gitlab/sidekiq_middleware/client_metrics_spec.rb index daee2c0bbd0..689c7e40727 100644 --- a/spec/lib/gitlab/sidekiq_middleware/client_metrics_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/client_metrics_spec.rb @@ -9,7 +9,7 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do let(:queue) { :test } let(:worker_class) { worker.class } let(:job) { {} } - let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", latency_sensitive: "no" } } + let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", urgency: "default" } } shared_examples "a metrics client middleware" do context "with mocked prometheus" do @@ -46,17 +46,17 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do it_behaves_like "a metrics client middleware" do let(:worker) { TestNonAttributedWorker.new } - let(:labels) { default_labels } + let(:labels) { default_labels.merge(urgency: "") } end end context "when workers are attributed" do - def create_attributed_worker_class(latency_sensitive, external_dependencies, resource_boundary, category) + def create_attributed_worker_class(urgency, external_dependencies, resource_boundary, category) klass = Class.new do include Sidekiq::Worker include WorkerAttributes - latency_sensitive_worker! if latency_sensitive + urgency urgency if urgency worker_has_external_dependencies! if external_dependencies worker_resource_boundary resource_boundary unless resource_boundary == :unknown feature_category category unless category.nil? @@ -64,17 +64,24 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do stub_const("TestAttributedWorker", klass) end - let(:latency_sensitive) { false } + let(:urgency) { nil } let(:external_dependencies) { false } let(:resource_boundary) { :unknown } let(:feature_category) { nil } - let(:worker_class) { create_attributed_worker_class(latency_sensitive, external_dependencies, resource_boundary, feature_category) } + let(:worker_class) { create_attributed_worker_class(urgency, external_dependencies, resource_boundary, feature_category) } let(:worker) { worker_class.new } - context "latency sensitive" do + context "high urgency" do it_behaves_like "a metrics client middleware" do - let(:latency_sensitive) { true } - let(:labels) { default_labels.merge(latency_sensitive: "yes") } + let(:urgency) { :high } + let(:labels) { default_labels.merge(urgency: "high") } + end + end + + context "no urgency" do + it_behaves_like "a metrics client middleware" do + let(:urgency) { :none } + let(:labels) { default_labels.merge(urgency: "none") } end end @@ -108,11 +115,11 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do context "combined" do it_behaves_like "a metrics client middleware" do - let(:latency_sensitive) { true } + let(:urgency) { :high } let(:external_dependencies) { true } let(:resource_boundary) { :cpu } let(:feature_category) { :authentication } - let(:labels) { default_labels.merge(latency_sensitive: "yes", external_dependencies: "yes", boundary: "cpu", feature_category: "authentication") } + let(:labels) { default_labels.merge(urgency: "high", external_dependencies: "yes", boundary: "cpu", feature_category: "authentication") } end end end diff --git a/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb b/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb index 65a961b34f8..47442f4ee86 100644 --- a/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::SidekiqMiddleware::ServerMetrics do let(:job) { {} } let(:job_status) { :done } let(:labels_with_job_status) { labels.merge(job_status: job_status.to_s) } - let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", latency_sensitive: "no" } } + let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", urgency: "default" } } shared_examples "a metrics middleware" do context "with mocked prometheus" do @@ -130,34 +130,34 @@ describe Gitlab::SidekiqMiddleware::ServerMetrics do include Sidekiq::Worker end let(:worker) { TestNonAttributedWorker.new } - let(:labels) { default_labels } + let(:labels) { default_labels.merge(urgency: "") } it_behaves_like "a metrics middleware" end context "when workers are attributed" do - def create_attributed_worker_class(latency_sensitive, external_dependencies, resource_boundary, category) + def create_attributed_worker_class(urgency, external_dependencies, resource_boundary, category) Class.new do include Sidekiq::Worker include WorkerAttributes - latency_sensitive_worker! if latency_sensitive + urgency urgency if urgency worker_has_external_dependencies! if external_dependencies worker_resource_boundary resource_boundary unless resource_boundary == :unknown feature_category category unless category.nil? end end - let(:latency_sensitive) { false } + let(:urgency) { nil } let(:external_dependencies) { false } let(:resource_boundary) { :unknown } let(:feature_category) { nil } - let(:worker_class) { create_attributed_worker_class(latency_sensitive, external_dependencies, resource_boundary, feature_category) } + let(:worker_class) { create_attributed_worker_class(urgency, external_dependencies, resource_boundary, feature_category) } let(:worker) { worker_class.new } - context "latency sensitive" do - let(:latency_sensitive) { true } - let(:labels) { default_labels.merge(latency_sensitive: "yes") } + context "high urgency" do + let(:urgency) { :high } + let(:labels) { default_labels.merge(urgency: "high") } it_behaves_like "a metrics middleware" end @@ -191,11 +191,11 @@ describe Gitlab::SidekiqMiddleware::ServerMetrics do end context "combined" do - let(:latency_sensitive) { true } + let(:urgency) { :none } let(:external_dependencies) { true } let(:resource_boundary) { :cpu } let(:feature_category) { :authentication } - let(:labels) { default_labels.merge(latency_sensitive: "yes", external_dependencies: "yes", boundary: "cpu", feature_category: "authentication") } + let(:labels) { default_labels.merge(urgency: "none", external_dependencies: "yes", boundary: "cpu", feature_category: "authentication") } it_behaves_like "a metrics middleware" end diff --git a/spec/models/concerns/avatarable_spec.rb b/spec/models/concerns/avatarable_spec.rb index 100953549ea..96e867dbc97 100644 --- a/spec/models/concerns/avatarable_spec.rb +++ b/spec/models/concerns/avatarable_spec.rb @@ -15,7 +15,7 @@ describe Avatarable do end describe '#update' do - let(:validator) { project._validators[:avatar].detect { |v| v.is_a?(FileSizeValidator) } } + let(:validator) { project.class.validators_on(:avatar).find { |v| v.is_a?(FileSizeValidator) } } context 'when avatar changed' do it 'validates the file size' do diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index be5479cfc11..8ed7abc968b 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -192,16 +192,17 @@ describe WikiPage do expect(subject).not_to be_valid expect(subject.errors[:title]).to contain_exactly( - "exceeds the limit of #{max_title} bytes for page titles" + "exceeds the limit of #{max_title} bytes" ) end it 'rejects directories exceeding the limit' do - subject.title = invalid_directory + '/foo' + subject.title = "#{invalid_directory}/#{invalid_directory}2/foo" expect(subject).not_to be_valid expect(subject.errors[:title]).to contain_exactly( - "exceeds the limit of #{max_directory} bytes for directory names" + "exceeds the limit of #{max_directory} bytes for directory name \"#{invalid_directory}\"", + "exceeds the limit of #{max_directory} bytes for directory name \"#{invalid_directory}2\"" ) end @@ -210,8 +211,8 @@ describe WikiPage do expect(subject).not_to be_valid expect(subject.errors[:title]).to contain_exactly( - "exceeds the limit of #{max_title} bytes for page titles", - "exceeds the limit of #{max_directory} bytes for directory names" + "exceeds the limit of #{max_title} bytes", + "exceeds the limit of #{max_directory} bytes for directory name \"#{invalid_directory}\"" ) end end diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index b1a65ded9ef..97dc3899d3f 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -19,7 +19,7 @@ describe API::Repositories do it 'returns the repository tree' do get api(route, current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -108,7 +108,7 @@ describe API::Repositories do it 'returns blob attributes as json' do get api(route, current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['size']).to eq(111) expect(json_response['encoding']).to eq("base64") expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") @@ -167,7 +167,7 @@ describe API::Repositories do get api(route, current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" end @@ -231,7 +231,7 @@ describe API::Repositories do it 'returns the repository archive' do get api(route, current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) type, params = workhorse_send_data @@ -242,7 +242,7 @@ describe API::Repositories do it 'returns the repository archive archive.zip' do get api("/projects/#{project.id}/repository/archive.zip", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) type, params = workhorse_send_data @@ -253,7 +253,7 @@ describe API::Repositories do it 'returns the repository archive archive.tar.bz2' do get api("/projects/#{project.id}/repository/archive.tar.bz2", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) type, params = workhorse_send_data @@ -314,7 +314,7 @@ describe API::Repositories do }).and_call_original get api(route, current_user), params: { from: 'master', to: 'feature' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -325,7 +325,7 @@ describe API::Repositories do }).and_call_original get api(route, current_user), params: { from: 'master', to: 'feature', straight: false } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -336,7 +336,7 @@ describe API::Repositories do }).and_call_original get api(route, current_user), params: { from: 'master', to: 'feature', straight: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -344,7 +344,7 @@ describe API::Repositories do it "compares tags" do get api(route, current_user), params: { from: 'v1.0.0', to: 'v1.1.0' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -352,7 +352,7 @@ describe API::Repositories do it "compares commits" do get api(route, current_user), params: { from: sample_commit.id, to: sample_commit.parent_id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey @@ -361,7 +361,7 @@ describe API::Repositories do it "compares commits in reverse order" do get api(route, current_user), params: { from: sample_commit.parent_id, to: sample_commit.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -369,7 +369,7 @@ describe API::Repositories do it "compares same refs" do get api(route, current_user), params: { from: 'master', to: 'master' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy @@ -380,7 +380,7 @@ describe API::Repositories do get api(route, current_user), params: { from: 'master', to: 'feature' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present expect(json_response['diffs'].first['diff']).to be_empty @@ -389,13 +389,13 @@ describe API::Repositories do it "returns a 404 when from ref is unknown" do get api(route, current_user), params: { from: 'unknown_ref', to: 'master' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns a 404 when to ref is unknown" do get api(route, current_user), params: { from: 'master', to: 'unknown_ref' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -433,7 +433,7 @@ describe API::Repositories do it 'returns valid data' do get api(route, current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -450,7 +450,7 @@ describe API::Repositories do it 'returns the repository contribuors sorted by commits desc' do get api(route, current_user), params: { order_by: 'commits', sort: 'desc' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('contributors') expect(json_response.first['commits']).to be > json_response.last['commits'] end @@ -460,7 +460,7 @@ describe API::Repositories do it 'returns the repository contribuors sorted by name asc case insensitive' do get api(route, current_user), params: { order_by: 'name', sort: 'asc' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('contributors') expect(json_response.first['name'].downcase).to be < json_response.last['name'].downcase end diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index e9657c903e9..e76ab8d409b 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -22,7 +22,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 400 error' do post api('/runners') - expect(response).to have_gitlab_http_status 400 + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -30,7 +30,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 403 error' do post api('/runners'), params: { token: 'invalid' } - expect(response).to have_gitlab_http_status 403 + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -40,7 +40,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do runner = Ci::Runner.first - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(runner.id) expect(json_response['token']).to eq(runner.token) expect(runner.run_untagged).to be true @@ -55,7 +55,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'creates project runner' do post api('/runners'), params: { token: project.runners_token } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(project.runners.size).to eq(1) runner = Ci::Runner.first expect(runner.token).not_to eq(registration_token) @@ -70,7 +70,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'creates a group runner' do post api('/runners'), params: { token: group.runners_token } - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(group.runners.reload.size).to eq(1) runner = Ci::Runner.first expect(runner.token).not_to eq(registration_token) @@ -87,7 +87,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do description: 'server.hostname' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.description).to eq('server.hostname') end end @@ -99,7 +99,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do tag_list: 'tag1, tag2' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2)) end end @@ -113,7 +113,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do tag_list: ['tag'] } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.run_untagged).to be false expect(Ci::Runner.first.tag_list.sort).to eq(['tag']) end @@ -126,7 +126,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do run_untagged: false } - expect(response).to have_gitlab_http_status 400 + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to include( 'tags_list' => ['can not be empty when runner is not allowed to pick untagged jobs']) end @@ -140,7 +140,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do locked: true } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.locked).to be true end end @@ -153,7 +153,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do active: true } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.active).to be true end end @@ -165,7 +165,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do active: false } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.active).to be false end end @@ -179,7 +179,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do access_level: 'ref_protected' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.ref_protected?).to be true end end @@ -191,7 +191,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do access_level: 'not_protected' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.ref_protected?).to be false end end @@ -204,7 +204,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do maximum_timeout: 9000 } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.maximum_timeout).to eq(9000) end @@ -215,7 +215,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do maximum_timeout: '' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.maximum_timeout).to be_nil end end @@ -231,7 +231,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do info: { param => value } } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value) end end @@ -242,7 +242,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do params: { token: registration_token }, headers: { 'X-Forwarded-For' => '123.111.123.111' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(Ci::Runner.first.ip_address).to eq('123.111.123.111') end end @@ -252,7 +252,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 400 error' do delete api('/runners') - expect(response).to have_gitlab_http_status 400 + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -260,7 +260,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 403 error' do delete api('/runners'), params: { token: 'invalid' } - expect(response).to have_gitlab_http_status 403 + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -270,7 +270,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'deletes Runner' do delete api('/runners'), params: { token: runner.token } - expect(response).to have_gitlab_http_status 204 + expect(response).to have_gitlab_http_status(:no_content) expect(Ci::Runner.count).to eq(0) end @@ -296,7 +296,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 403 error' do post api('/runners/verify'), params: { token: 'invalid-token' } - expect(response).to have_gitlab_http_status 403 + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -304,7 +304,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'verifies Runner credentials' do post api('/runners/verify'), params: { token: runner.token } - expect(response).to have_gitlab_http_status 200 + expect(response).to have_gitlab_http_status(:ok) end end end @@ -361,7 +361,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when runner sends version in User-Agent' do context 'for stable version' do it 'gives 204 and set X-GitLab-Last-Update' do - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.header).to have_key('X-GitLab-Last-Update') end end @@ -370,7 +370,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:last_update) { runner.ensure_runner_queue_value } it 'gives 204 and set the same X-GitLab-Last-Update' do - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.header['X-GitLab-Last-Update']).to eq(last_update) end end @@ -380,7 +380,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:new_update) { runner.tick_runner_queue } it 'gives 204 and set a new X-GitLab-Last-Update' do - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.header['X-GitLab-Last-Update']).to eq(new_update) end end @@ -388,19 +388,19 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when beta version is sent' do let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' } - it { expect(response).to have_gitlab_http_status(204) } + it { expect(response).to have_gitlab_http_status(:no_content) } end context 'when pre-9-0 version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' } - it { expect(response).to have_gitlab_http_status(204) } + it { expect(response).to have_gitlab_http_status(:no_content) } end context 'when pre-9-0 beta version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' } - it { expect(response).to have_gitlab_http_status(204) } + it { expect(response).to have_gitlab_http_status(:no_content) } end end end @@ -409,7 +409,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 400 error' do post api('/jobs/request') - expect(response).to have_gitlab_http_status 400 + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -417,7 +417,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 403 error' do post api('/jobs/request'), params: { token: 'invalid' } - expect(response).to have_gitlab_http_status 403 + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -429,7 +429,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns 204 error' do request_job - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.header['X-GitLab-Last-Update']).to eq(update_value) end end @@ -516,7 +516,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'picks a job' do request_job info: { platform: :darwin } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(response.headers).not_to have_key('X-GitLab-Last-Update') expect(runner.reload.platform).to eq('darwin') expect(json_response['id']).to eq(job.id) @@ -541,7 +541,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do request_job info: { platform: :darwin } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(job.id) end @@ -551,7 +551,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'sets branch as ref_type' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['ref_type']).to eq('tag') end @@ -563,7 +563,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'specifies refspecs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['refspecs']).to include("+refs/tags/#{job.ref}:refs/tags/#{job.ref}") end end @@ -576,7 +576,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'specifies refspecs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['refspecs']) .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') end @@ -592,7 +592,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'gives 204' do request_job(job_age: job_age) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end end @@ -602,7 +602,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'picks a job' do request_job(job_age: job_age) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end end @@ -611,7 +611,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'sets tag as ref_type' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['ref_type']).to eq('branch') end @@ -623,7 +623,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'specifies refspecs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['refspecs']).to include("+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}") end end @@ -636,7 +636,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'specifies refspecs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['refspecs']) .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') end @@ -651,7 +651,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'sets branch as ref_type' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['ref_type']).to eq('branch') end @@ -663,7 +663,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns the overwritten git depth for merge request refspecs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['git_info']['depth']).to eq(1) end end @@ -680,7 +680,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it "updates provided Runner's parameter" do request_job info: { param => value } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(runner.reload.read_attribute(param.to_sym)).to eq(value) end end @@ -691,7 +691,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do params: { token: runner.token }, headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(runner.reload.ip_address).to eq('123.222.123.222') end @@ -700,7 +700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do params: { token: runner.token }, headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222, 127.0.0.1' } - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) expect(runner.reload.ip_address).to eq('123.222.123.222') end @@ -713,7 +713,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns a conflict' do request_job - expect(response).to have_gitlab_http_status(409) + expect(response).to have_gitlab_http_status(:conflict) expect(response.headers).not_to have_key('X-GitLab-Last-Update') end end @@ -731,7 +731,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns dependent jobs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(2) expect(json_response['dependencies']).to include( @@ -751,7 +751,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns dependent jobs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies']).to include( @@ -777,7 +777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns dependent jobs' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token) @@ -801,7 +801,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns an empty array' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['id']).to eq(empty_dependencies_job.id) expect(json_response['dependencies'].count).to eq(0) end @@ -820,7 +820,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'picks job' do request_job - expect(response).to have_gitlab_http_status 201 + expect(response).to have_gitlab_http_status(:created) end end @@ -854,7 +854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns variables for triggers' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['variables']).to include(*expected_variables) end end @@ -919,7 +919,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'contains info about timeout taken from project' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['runner_info']).to include({ 'timeout' => 1234 }) end @@ -929,7 +929,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'contains info about timeout overridden by runner' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['runner_info']).to include({ 'timeout' => 1000 }) end end @@ -940,7 +940,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'contains info about timeout not overridden by runner' do request_job - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['runner_info']).to include({ 'timeout' => 1234 }) end end @@ -965,7 +965,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns the image ports' do request_job - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(json_response).to include( 'id' => job.id, 'image' => a_hash_including('name' => 'ruby', 'ports' => [{ 'number' => 80, 'protocol' => 'http', 'name' => 'default_port' }]), @@ -989,7 +989,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns the service ports' do request_job - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(json_response).to include( 'id' => job.id, 'image' => a_hash_including('name' => 'ruby'), @@ -1089,7 +1089,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do update_job(state: 'success', trace: 'BUILD TRACE UPDATED') job.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(job.trace.raw).to eq 'BUILD TRACE UPDATED' expect(job.job_artifacts_trace.open.read).to eq 'BUILD TRACE UPDATED' end @@ -1133,7 +1133,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'responds with forbidden' do update_job - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -1147,7 +1147,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do update_job(state: 'success', trace: 'BUILD TRACE UPDATED') job.reload - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.header['Job-Status']).to eq 'failed' expect(job.trace.raw).to eq 'Job failed' expect(job).to be_failed @@ -1461,7 +1461,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'succeeds' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path) expect(json_response['RemoteObject']).to be_nil @@ -1481,7 +1481,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'succeeds' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response).not_to have_key('TempPath') expect(json_response['RemoteObject']).to have_key('ID') @@ -1509,7 +1509,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'fails to post' do authorize_artifacts_with_token_in_params(filesize: sample_max_size.megabytes.to_i) - expect(response).to have_gitlab_http_status(413) + expect(response).to have_gitlab_http_status(:payload_too_large) end end @@ -1557,7 +1557,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'authorizes posting artifacts to running job' do authorize_artifacts_with_token_in_headers - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).not_to be_nil end @@ -1567,7 +1567,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do authorize_artifacts_with_token_in_headers(filesize: 100) - expect(response).to have_gitlab_http_status(413) + expect(response).to have_gitlab_http_status(:payload_too_large) end end @@ -1575,7 +1575,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'fails to authorize artifacts posting' do authorize_artifacts(token: job.project.runners_token) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -1591,7 +1591,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'responds with forbidden' do authorize_artifacts(token: 'invalid', filesize: 100 ) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -1632,14 +1632,14 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'responds with forbidden' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end context 'when job is running' do shared_examples 'successful artifacts upload' do it 'updates successfully' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end @@ -1678,7 +1678,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:remote_id) { 'invalid id' } it 'responds with bad request' do - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(json_response['message']).to eq("Missing file") end end @@ -1689,7 +1689,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'responds with forbidden' do upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token)) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -1700,7 +1700,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_gitlab_http_status(413) + expect(response).to have_gitlab_http_status(:payload_too_large) end end @@ -1708,7 +1708,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'fails to post artifacts without file' do post api("/jobs/#{job.id}/artifacts"), params: {}, headers: headers_with_token - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -1716,7 +1716,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'fails to post artifacts without GitLab-Workhorse' do post api("/jobs/#{job.id}/artifacts"), params: { token: job.token }, headers: {} - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -1750,7 +1750,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:expire_in) { '7 days' } it 'updates when specified' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now) end end @@ -1759,7 +1759,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:expire_in) { nil } it 'ignores if not specified' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.artifacts_expire_at).to be_nil end @@ -1768,7 +1768,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:default_artifacts_expire_in) { '5 days' } it 'sets to application default' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now) end end @@ -1777,7 +1777,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:default_artifacts_expire_in) { '0' } it 'does not set expire_in' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.artifacts_expire_at).to be_nil end end @@ -1812,7 +1812,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'stores artifacts and artifacts metadata' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(stored_artifacts_file.filename).to eq(artifacts.original_filename) expect(stored_metadata_file.filename).to eq(metadata.original_filename) expect(stored_artifacts_size).to eq(artifacts.size) @@ -1827,7 +1827,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'is expected to respond with bad request' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'does not store metadata' do @@ -1843,7 +1843,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'stores junit test report' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.job_artifacts_archive).not_to be_nil end end @@ -1854,7 +1854,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns an error' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(job.reload.job_artifacts_archive).to be_nil end end @@ -1868,7 +1868,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'stores junit test report' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.job_artifacts_junit).not_to be_nil end end @@ -1880,7 +1880,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns an error' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(job.reload.job_artifacts_junit).to be_nil end end @@ -1894,7 +1894,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'stores metrics_referee data' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.job_artifacts_metrics_referee).not_to be_nil end end @@ -1906,7 +1906,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns an error' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(job.reload.job_artifacts_metrics_referee).to be_nil end end @@ -1920,7 +1920,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'stores network_referee data' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(job.reload.job_artifacts_network_referee).not_to be_nil end end @@ -1932,7 +1932,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'returns an error' do upload_artifacts(file_upload, headers_with_token, params) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(job.reload.job_artifacts_network_referee).to be_nil end end @@ -2013,7 +2013,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it' "fails to post artifacts for outside of tmp path"' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -2055,7 +2055,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'download artifacts' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.headers.to_h).to include download_headers end end @@ -2070,7 +2070,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'uses workhorse send-url' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.headers.to_h).to include( 'Gitlab-Workhorse-Send-Data' => /send-url:/) end @@ -2082,7 +2082,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'receive redirect for downloading artifacts' do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response.headers).to include('Location') end end @@ -2097,7 +2097,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end it 'responds with forbidden' do - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -2106,7 +2106,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it 'responds with not found' do download_artifact - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index c54487a68fe..70094ef4388 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -32,7 +32,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -51,7 +51,7 @@ describe API::Runners do get api('/runners?scope=paused', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -61,7 +61,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -76,7 +76,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api('/runners?type=bogus', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -92,7 +92,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api('/runners?status=bogus', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -111,7 +111,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -122,7 +122,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners/all', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -141,7 +141,7 @@ describe API::Runners do get api('/runners/all?scope=shared', admin) shared = json_response.all? { |r| r['is_shared'] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response[0]).to have_key('ip_address') @@ -151,7 +151,7 @@ describe API::Runners do it 'filters runners by scope' do get api('/runners/all?scope=specific', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -163,7 +163,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners/all?scope=unknown', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -178,7 +178,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api('/runners/all?type=bogus', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -194,7 +194,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api('/runners/all?status=bogus', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -213,7 +213,7 @@ describe API::Runners do it 'does not return runners list' do get api('/runners/all', user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -222,7 +222,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -233,7 +233,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(shared_runner.description) expect(json_response['maximum_timeout']).to be_nil end @@ -247,7 +247,7 @@ describe API::Runners do expect do delete api("/runners/#{unused_project_runner.id}", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end end @@ -255,7 +255,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{project_runner.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(project_runner.description) end @@ -269,7 +269,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do get api('/runners/0', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -278,7 +278,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{project_runner.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(project_runner.description) end end @@ -287,7 +287,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(shared_runner.description) end end @@ -297,7 +297,7 @@ describe API::Runners do it "does not return project runner's details" do get api("/runners/#{project_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -305,7 +305,7 @@ describe API::Runners do it "does not return project runner's details" do get api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -318,7 +318,7 @@ describe API::Runners do description = shared_runner.description update_runner(shared_runner.id, admin, description: "#{description}_updated") - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.description).to eq("#{description}_updated") end @@ -326,14 +326,14 @@ describe API::Runners do active = shared_runner.active update_runner(shared_runner.id, admin, active: !active) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.active).to eq(!active) end it 'runner tag list' do update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.tag_list).to include('ruby2.1', 'pgsql', 'mysql') end @@ -342,28 +342,28 @@ describe API::Runners do update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) update_runner(shared_runner.id, admin, run_untagged: 'false') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.run_untagged?).to be(false) end it 'runner unlocked flag' do update_runner(shared_runner.id, admin, locked: 'true') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.locked?).to be(true) end it 'runner access level' do update_runner(shared_runner.id, admin, access_level: 'ref_protected') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.ref_protected?).to be_truthy end it 'runner maximum timeout' do update_runner(shared_runner.id, admin, maximum_timeout: 1234) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.maximum_timeout).to eq(1234) end @@ -371,7 +371,7 @@ describe API::Runners do put api("/runners/#{shared_runner.id}", admin) shared_runner.reload - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -390,7 +390,7 @@ describe API::Runners do maximum_timeout: 1234) shared_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.description).to eq("#{description}_updated") expect(shared_runner.active).to eq(!active) expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') @@ -411,7 +411,7 @@ describe API::Runners do update_runner(project_runner.id, admin, description: 'test') project_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(project_runner.description).to eq('test') expect(project_runner.description).not_to eq(description) expect(project_runner.ensure_runner_queue_value) @@ -422,7 +422,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do update_runner(0, admin, description: 'test') - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end def update_runner(id, user, args) @@ -435,7 +435,7 @@ describe API::Runners do it 'does not update runner' do put api("/runners/#{shared_runner.id}", user), params: { description: 'test' } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -443,7 +443,7 @@ describe API::Runners do it 'does not update project runner without access to it' do put api("/runners/#{project_runner.id}", user2), params: { description: 'test' } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'updates project runner with access to it' do @@ -451,7 +451,7 @@ describe API::Runners do put api("/runners/#{project_runner.id}", admin), params: { description: 'test' } project_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(project_runner.description).to eq('test') expect(project_runner.description).not_to eq(description) end @@ -462,7 +462,7 @@ describe API::Runners do it 'does not delete project runner' do put api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -474,7 +474,7 @@ describe API::Runners do expect do delete api("/runners/#{shared_runner.id}", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.instance_type.count }.by(-1) end @@ -488,7 +488,7 @@ describe API::Runners do expect do delete api("/runners/#{project_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end end @@ -496,7 +496,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do delete api('/runners/0', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -504,40 +504,40 @@ describe API::Runners do context 'when runner is shared' do it 'does not delete runner' do delete api("/runners/#{shared_runner.id}", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete api("/runners/#{project_runner.id}", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not delete project runner with more than one associated project' do delete api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'deletes project runner for one owned project' do expect do delete api("/runners/#{project_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end it 'does not delete group runner with maintainer access' do delete api("/runners/#{group_runner.id}", group_maintainer) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'deletes group runner with owner access' do expect do delete api("/runners/#{group_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.group_type.count }.by(-1) end @@ -551,7 +551,7 @@ describe API::Runners do it 'does not delete project runner' do delete api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -569,7 +569,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{shared_runner.id}/jobs", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -581,7 +581,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{project_runner.id}/jobs", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -593,7 +593,7 @@ describe API::Runners do it 'return filtered jobs' do get api("/runners/#{project_runner.id}/jobs?status=failed", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -607,7 +607,7 @@ describe API::Runners do it 'return jobs in descending order' do get api("/runners/#{project_runner.id}/jobs?order_by=id", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -620,7 +620,7 @@ describe API::Runners do it 'return jobs sorted in ascending order' do get api("/runners/#{project_runner.id}/jobs?order_by=id&sort=asc", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -634,7 +634,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?status=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -642,7 +642,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?order_by=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -650,7 +650,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?sort=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -659,7 +659,7 @@ describe API::Runners do it 'returns 404' do get api('/runners/0/jobs', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -670,7 +670,7 @@ describe API::Runners do it 'returns 403' do get api("/runners/#{shared_runner.id}/jobs", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -678,7 +678,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{project_runner.id}/jobs", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -690,7 +690,7 @@ describe API::Runners do it 'return filtered jobs' do get api("/runners/#{project_runner.id}/jobs?status=failed", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -703,7 +703,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?status=non-existing", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -712,7 +712,7 @@ describe API::Runners do it 'returns 404' do get api('/runners/0/jobs', user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -721,7 +721,7 @@ describe API::Runners do it 'does not return jobs' do get api("/runners/#{project_runner.id}/jobs", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -729,7 +729,7 @@ describe API::Runners do it 'does not return jobs' do get api("/runners/#{project_runner.id}/jobs") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -739,7 +739,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners/all', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -756,7 +756,7 @@ describe API::Runners do it 'filters runners by scope' do get api("/projects/#{project.id}/runners?scope=specific", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -767,7 +767,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api("/projects/#{project.id}/runners?scope=unknown", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -782,7 +782,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api("/projects/#{project.id}/runners?type=bogus", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -798,7 +798,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api("/projects/#{project.id}/runners?status=bogus", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -817,7 +817,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -825,7 +825,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -838,14 +838,14 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(+1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'avoids changes when enabling already enabled runner' do expect do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id } end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'does not enable locked runner' do @@ -855,19 +855,19 @@ describe API::Runners do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not enable shared runner' do post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not enable group runner' do post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end context 'user is admin' do @@ -878,7 +878,7 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id } end.to change { project.runners.count }.by(+1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end @@ -888,14 +888,14 @@ describe API::Runners do end.to change { project.runners.count }.by(1) expect(shared_runner.reload).not_to be_instance_type - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end it 'raises an error when no runner_id param is provided' do post api("/projects/#{project.id}/runners", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -905,7 +905,7 @@ describe API::Runners do it 'does not enable runner without access to' do post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -913,7 +913,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -921,7 +921,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -933,7 +933,7 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { project.runners.count }.by(-1) end @@ -947,14 +947,14 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{project_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end it 'returns 404 is runner is not found' do delete api("/projects/#{project.id}/runners/0", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -962,7 +962,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{project_runner.id}", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -970,7 +970,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{project_runner.id}") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index 04794b2ba58..6ff5fbd7925 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -9,7 +9,7 @@ describe API::Search do let_it_be(:repo_project) { create(:project, :public, :repository, group: group) } shared_examples 'response is correct' do |schema:, size: 1| - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response).to match_response_schema(schema) } it { expect(response).to include_limited_pagination_headers } it { expect(json_response.size).to eq(size) } @@ -20,7 +20,7 @@ describe API::Search do it 'returns 401 error' do get api('/search'), params: { scope: 'projects', search: 'awesome' } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -28,7 +28,7 @@ describe API::Search do it 'returns 400 error' do get api('/search', user), params: { scope: 'unsupported', search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -36,7 +36,7 @@ describe API::Search do it 'returns 400 error' do get api('/search', user), params: { search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -115,7 +115,7 @@ describe API::Search do end it 'returns 400 error' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -147,7 +147,7 @@ describe API::Search do it 'returns 401 error' do get api("/groups/#{group.id}/search"), params: { scope: 'projects', search: 'awesome' } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -155,7 +155,7 @@ describe API::Search do it 'returns 400 error' do get api("/groups/#{group.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -163,7 +163,7 @@ describe API::Search do it 'returns 400 error' do get api("/groups/#{group.id}/search", user), params: { search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -171,7 +171,7 @@ describe API::Search do it 'returns 404 error' do get api('/groups/0/search', user), params: { scope: 'issues', search: 'awesome' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -181,7 +181,7 @@ describe API::Search do get api("/groups/#{private_group.id}/search", user), params: { scope: 'issues', search: 'awesome' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -254,7 +254,7 @@ describe API::Search do end it 'returns 400 error' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -277,7 +277,7 @@ describe API::Search do it 'returns 401 error' do get api("/projects/#{project.id}/search"), params: { scope: 'issues', search: 'awesome' } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -285,7 +285,7 @@ describe API::Search do it 'returns 400 error' do get api("/projects/#{project.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -293,7 +293,7 @@ describe API::Search do it 'returns 400 error' do get api("/projects/#{project.id}/search", user), params: { search: 'awesome' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -301,7 +301,7 @@ describe API::Search do it 'returns 404 error' do get api('/projects/0/search', user), params: { scope: 'issues', search: 'awesome' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -311,7 +311,7 @@ describe API::Search do get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -383,7 +383,7 @@ describe API::Search do end it 'returns 400 error' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -436,7 +436,7 @@ describe API::Search do it 'by filename' do get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.size).to eq(2) expect(json_response.first['path']).to eq('PROCESS.md') expect(json_response.first['filename']).to eq('PROCESS.md') @@ -445,21 +445,21 @@ describe API::Search do it 'by path' do get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon path:markdown' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.size).to eq(8) end it 'by extension' do get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon extension:md' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.size).to eq(11) end it 'by ref' do get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'This file is used in tests for ci_environments_status', ref: 'pages-deploy' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.size).to eq(1) end end diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 323164f26f0..906ffce25bf 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -14,14 +14,14 @@ describe API::Services do it 'returns authentication error when unauthenticated' do get api("/projects/#{project.id}/services") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it "returns error when authenticated but user is not a project owner" do project.add_developer(user2) get api("/projects/#{project.id}/services", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end context 'project with services' do @@ -32,7 +32,7 @@ describe API::Services do get api("/projects/#{project.id}/services", user) aggregate_failures 'expect successful response with all active services' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Array expect(json_response.count).to eq(1) expect(json_response.first['slug']).to eq('emails-on-push') @@ -49,7 +49,7 @@ describe API::Services do it "updates #{service} settings" do put api("/projects/#{project.id}/services/#{dashed_service}", user), params: service_attrs - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) current_service = project.services.first events = current_service.event_names.empty? ? ["foo"].freeze : current_service.event_names @@ -61,7 +61,7 @@ describe API::Services do put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['slug']).to eq(dashed_service) events.each do |event| next if event == "foo" @@ -103,7 +103,7 @@ describe API::Services do it "deletes #{service}" do delete api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) project.send(service_method).reload expect(project.send(service_method).activated?).to be_falsey end @@ -117,13 +117,13 @@ describe API::Services do it 'returns authentication error when unauthenticated' do get api("/projects/#{project.id}/services/#{dashed_service}") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it "returns all properties of service #{service}" do get api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['properties'].keys).to match_array(service_instance.api_field_names) end @@ -131,7 +131,7 @@ describe API::Services do project.add_developer(user2) get api("/projects/#{project.id}/services/#{dashed_service}", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -144,7 +144,7 @@ describe API::Services do it 'returns a not found message' do post api("/projects/#{project.id}/services/idonotexist/trigger") - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["error"]).to eq("404 Not Found") end end @@ -163,7 +163,7 @@ describe API::Services do it 'when the service is inactive' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -178,7 +178,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -186,7 +186,7 @@ describe API::Services do it 'returns a generic 404' do post api("/projects/404/services/#{service_name}/trigger"), params: params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["message"]).to eq("404 Service Not Found") end end @@ -206,7 +206,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['response_type']).to eq("ephemeral") end end @@ -228,7 +228,7 @@ describe API::Services do it 'accepts a username for update' do put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(username: 'new_username') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['properties']['username']).to eq('new_username') end end @@ -253,14 +253,14 @@ describe API::Services do it 'accepts branches_to_be_notified for update' do put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(branches_to_be_notified: 'all') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['properties']['branches_to_be_notified']).to eq('all') end it 'accepts notify_only_broken_pipelines for update' do put api("/projects/#{project.id}/services/#{service_name}", user), params: params.merge(notify_only_broken_pipelines: true) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['properties']['notify_only_broken_pipelines']).to eq(true) end end diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index 1a6bd4e6c0d..4a8b8f70dff 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -11,7 +11,7 @@ describe API::Settings, 'Settings' do it "returns application settings" do get api("/application/settings", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled_for_web']).to be_truthy @@ -91,7 +91,7 @@ describe API::Settings, 'Settings' do snippet_size_limit: 5 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['default_ci_config_path']).to eq('debian/salsa-ci.yml') expect(json_response['default_projects_limit']).to eq(3) expect(json_response['default_project_creation']).to eq(::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) @@ -132,7 +132,7 @@ describe API::Settings, 'Settings' do put api("/application/settings", admin), params: { performance_bar_allowed_group_id: group.full_path } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['performance_bar_allowed_group_id']).to eq(group.id) end @@ -143,7 +143,7 @@ describe API::Settings, 'Settings' do performance_bar_allowed_group_id: group.full_path } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['performance_bar_allowed_group_id']).to be_nil end @@ -151,7 +151,7 @@ describe API::Settings, 'Settings' do put api("/application/settings", admin), params: { allow_local_requests_from_hooks_and_services: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['allow_local_requests_from_hooks_and_services']).to eq(true) end @@ -173,7 +173,7 @@ describe API::Settings, 'Settings' do it 'includes the attributes in the API' do get api("/application/settings", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) attribute_names.each do |attribute| expect(json_response.keys).to include(attribute) end @@ -182,7 +182,7 @@ describe API::Settings, 'Settings' do it 'allows updating the settings' do put api("/application/settings", admin), params: settings - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) settings.each do |attribute, value| expect(ApplicationSetting.current.public_send(attribute)).to eq(value) end @@ -205,7 +205,7 @@ describe API::Settings, 'Settings' do it "includes the attributes in the API" do get api("/application/settings", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) attribute_names.each do |attribute| expect(json_response.keys).to include(attribute) end @@ -214,7 +214,7 @@ describe API::Settings, 'Settings' do it "allows updating the settings" do put api("/application/settings", admin), params: settings - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) settings.each do |attribute, value| expect(ApplicationSetting.current.public_send(attribute)).to eq(value) end @@ -224,7 +224,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), params: { snowplow_enabled: true } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response["error"]).to eq("snowplow_collector_hostname is missing") end @@ -233,7 +233,7 @@ describe API::Settings, 'Settings' do snowplow_collector_hostname: nil }) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) message = json_response["message"] expect(message["snowplow_collector_hostname"]).to include("can't be blank") end @@ -257,7 +257,7 @@ describe API::Settings, 'Settings' do it 'includes attributes in the API' do get api("/application/settings", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) exposed_attributes.each do |attribute| expect(json_response.keys).to include(attribute) end @@ -266,7 +266,7 @@ describe API::Settings, 'Settings' do it 'does not include sensitive attributes in the API' do get api("/application/settings", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) sensitive_attributes.each do |attribute| expect(json_response.keys).not_to include(attribute) end @@ -275,7 +275,7 @@ describe API::Settings, 'Settings' do it 'allows updating the settings' do put api("/application/settings", admin), params: settings - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) settings.each do |attribute, value| expect(ApplicationSetting.current.public_send(attribute)).to eq(value) end @@ -287,7 +287,7 @@ describe API::Settings, 'Settings' do it 'does not update the settings' do put api("/application/settings", admin), params: settings - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to include('eks_account_id is missing') expect(json_response['error']).to include('eks_access_key_id is missing') expect(json_response['error']).to include('eks_secret_access_key is missing') @@ -299,7 +299,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), params: { plantuml_enabled: true } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to eq('plantuml_url is missing') end end @@ -314,7 +314,7 @@ describe API::Settings, 'Settings' do asset_proxy_whitelist: ['example.com', '*.example.com'] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['asset_proxy_enabled']).to be(true) expect(json_response['asset_proxy_url']).to eq('http://assets.example.com') expect(json_response['asset_proxy_secret_key']).to be_nil @@ -327,7 +327,7 @@ describe API::Settings, 'Settings' do asset_proxy_whitelist: 'example.com, *.example.com' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['asset_proxy_whitelist']).to eq(['example.com', '*.example.com', 'localhost']) end end @@ -340,7 +340,7 @@ describe API::Settings, 'Settings' do domain_blacklist: [] } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) message = json_response["message"] expect(message["domain_blacklist"]).to eq(["Domain blacklist cannot be empty if Blacklist is enabled."]) end @@ -352,7 +352,7 @@ describe API::Settings, 'Settings' do domain_blacklist: ['domain1.com', 'domain2.com'] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['domain_blacklist_enabled']).to be(true) expect(json_response['domain_blacklist']).to eq(['domain1.com', 'domain2.com']) end @@ -364,7 +364,7 @@ describe API::Settings, 'Settings' do domain_blacklist: 'domain3.com, *.domain4.com' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['domain_blacklist_enabled']).to be(true) expect(json_response['domain_blacklist']).to eq(['domain3.com', '*.domain4.com']) end @@ -374,7 +374,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), params: { sourcegraph_enabled: true } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to eq('sourcegraph_url is missing') end end diff --git a/spec/requests/api/sidekiq_metrics_spec.rb b/spec/requests/api/sidekiq_metrics_spec.rb index 438b1475c54..705ae29d5d8 100644 --- a/spec/requests/api/sidekiq_metrics_spec.rb +++ b/spec/requests/api/sidekiq_metrics_spec.rb @@ -9,21 +9,21 @@ describe API::SidekiqMetrics do it 'defines the `queue_metrics` endpoint' do get api('/sidekiq/queue_metrics', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_a Hash end it 'defines the `process_metrics` endpoint' do get api('/sidekiq/process_metrics', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['processes']).to be_an Array end it 'defines the `job_stats` endpoint' do get api('/sidekiq/job_stats', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_a Hash expect(json_response['jobs']).to be_a Hash expect(json_response['jobs'].keys) @@ -34,7 +34,7 @@ describe API::SidekiqMetrics do it 'defines the `compound_metrics` endpoint' do get api('/sidekiq/compound_metrics', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_a Hash expect(json_response['queues']).to be_a Hash expect(json_response['processes']).to be_an Array diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index cb2a0adc092..d399c2b3f1c 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -13,7 +13,7 @@ describe API::Snippets do get api("/snippets/", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( @@ -30,7 +30,7 @@ describe API::Snippets do get api("/snippets/", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(0) @@ -41,7 +41,7 @@ describe API::Snippets do get api("/snippets/") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it 'does not return snippets related to a project with disable feature visibility' do @@ -73,7 +73,7 @@ describe API::Snippets do it 'returns all snippets with public visibility from all users' do get api("/snippets/public", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( @@ -95,13 +95,13 @@ describe API::Snippets do it 'requires authentication' do get api("/snippets/#{snippet.id}", nil) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it 'returns raw text' do get api("/snippets/#{snippet.id}/raw", author) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -117,14 +117,14 @@ describe API::Snippets do get api("/snippets/#{snippet.id}/raw", author) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'hides private snippets from ordinary users' do get api("/snippets/#{snippet.id}/raw", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'shows internal snippets to ordinary users' do @@ -132,7 +132,7 @@ describe API::Snippets do get api("/snippets/#{internal_snippet.id}/raw", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -145,13 +145,13 @@ describe API::Snippets do it 'requires authentication' do get api("/snippets/#{private_snippet.id}", nil) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it 'returns snippet json' do get api("/snippets/#{private_snippet.id}", author) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['title']).to eq(private_snippet.title) expect(json_response['description']).to eq(private_snippet.description) @@ -162,19 +162,19 @@ describe API::Snippets do it 'shows private snippets to an admin' do get api("/snippets/#{private_snippet.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'hides private snippets from an ordinary user' do get api("/snippets/#{private_snippet.id}", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'shows internal snippets to an ordinary user' do get api("/snippets/#{internal_snippet.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns 404 for invalid snippet id' do @@ -182,7 +182,7 @@ describe API::Snippets do get api("/snippets/#{private_snippet.id}", admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -208,7 +208,7 @@ describe API::Snippets do subject end.to change { PersonalSnippet.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['title']).to eq(params[:title]) expect(json_response['description']).to eq(params[:description]) expect(json_response['file_name']).to eq(params[:file_name]) @@ -259,7 +259,7 @@ describe API::Snippets do post api("/snippets/", user), params: params - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end context 'when the snippet is spam' do @@ -285,7 +285,7 @@ describe API::Snippets do expect { create_snippet(visibility: 'public') } .not_to change { Snippet.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -311,7 +311,7 @@ describe API::Snippets do put api("/snippets/#{snippet.id}", user), params: { content: new_content, description: new_description, visibility: 'internal' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -334,21 +334,21 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do put api("/snippets/1234", user), params: { title: 'foo' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do put api("/snippets/#{snippet.id}", other_user), params: { title: 'fubar' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put api("/snippets/1234", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end context 'when the snippet is spam' do @@ -378,7 +378,7 @@ describe API::Snippets do expect { update_snippet(title: 'Foo') } .not_to change { snippet.reload.title } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -410,14 +410,14 @@ describe API::Snippets do expect do delete api("/snippets/#{public_snippet.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { PersonalSnippet.count }.by(-1) end it 'returns 404 for invalid snippet id' do delete api("/snippets/1234", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 Snippet Not Found') end @@ -434,7 +434,7 @@ describe API::Snippets do it 'exposes known attributes' do get api("/snippets/#{snippet.id}/user_agent_detail", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -443,7 +443,7 @@ describe API::Snippets do it "returns unauthorized for non-admin users" do get api("/snippets/#{snippet.id}/user_agent_detail", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end diff --git a/spec/requests/api/statistics_spec.rb b/spec/requests/api/statistics_spec.rb index 91fc4d4c123..f03c1e9ca64 100644 --- a/spec/requests/api/statistics_spec.rb +++ b/spec/requests/api/statistics_spec.rb @@ -25,7 +25,7 @@ describe API::Statistics, 'Statistics' do it "returns authentication error" do get api(path, nil) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -35,7 +35,7 @@ describe API::Statistics, 'Statistics' do it "returns forbidden error" do get api(path, user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -45,7 +45,7 @@ describe API::Statistics, 'Statistics' do it 'matches the response schema' do get api(path, admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('statistics') end diff --git a/spec/requests/api/submodules_spec.rb b/spec/requests/api/submodules_spec.rb index 064392fb185..2604dc18005 100644 --- a/spec/requests/api/submodules_spec.rb +++ b/spec/requests/api/submodules_spec.rb @@ -33,7 +33,7 @@ describe API::Submodules do it 'returns 401' do put api(route(submodule)), params: params - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -41,7 +41,7 @@ describe API::Submodules do it 'returns 403' do put api(route(submodule), guest), params: params - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -49,19 +49,19 @@ describe API::Submodules do it 'returns 400 if params is missing' do put api(route(submodule), user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns 400 if branch is missing' do put api(route(submodule), user), params: params.except(:branch) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns 400 if commit_sha is missing' do put api(route(submodule), user), params: params.except(:commit_sha) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns the commit' do @@ -69,7 +69,7 @@ describe API::Submodules do put api(route(submodule), user), params: params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['message']).to eq commit_message expect(json_response['author_name']).to eq user.name expect(json_response['committer_name']).to eq user.name @@ -89,7 +89,7 @@ describe API::Submodules do put api(route(encoded_submodule), user), params: params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq project.repository.commit(branch).id expect(project.repository.blob_at(branch, submodule).id).to eq commit_sha end diff --git a/spec/requests/api/suggestions_spec.rb b/spec/requests/api/suggestions_spec.rb index 5b07e598b8d..df3f72e3447 100644 --- a/spec/requests/api/suggestions_spec.rb +++ b/spec/requests/api/suggestions_spec.rb @@ -40,7 +40,7 @@ describe API::Suggestions do put api(url, user), params: { id: suggestion.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response) .to include('id', 'from_line', 'to_line', 'appliable', 'applied', 'from_content', 'to_content') @@ -57,7 +57,7 @@ describe API::Suggestions do put api(url, user), params: { id: suggestion.id } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response).to eq({ 'message' => 'Suggestion is not appliable' }) end end @@ -74,7 +74,7 @@ describe API::Suggestions do put api(url, user), params: { id: suggestion.id } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(json_response).to eq({ 'message' => '403 Forbidden' }) end end diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index 79790b1e999..50015d2e2c3 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -18,7 +18,7 @@ describe API::SystemHooks do it "returns authentication error" do get api("/hooks") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -26,7 +26,7 @@ describe API::SystemHooks do it "returns forbidden error" do get api("/hooks", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -34,7 +34,7 @@ describe API::SystemHooks do it "returns an array of hooks" do get api("/hooks", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['url']).to eq(hook.url) @@ -56,13 +56,13 @@ describe API::SystemHooks do it "responds with 400 if url not given" do post api("/hooks", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "responds with 400 if url is invalid" do post api("/hooks", admin), params: { url: 'hp://mep.mep' } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "does not create new hook without url" do @@ -76,7 +76,7 @@ describe API::SystemHooks do post api('/hooks', admin), params: { url: 'http://mep.mep' } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['enable_ssl_verification']).to be true expect(json_response['push_events']).to be false expect(json_response['tag_push_events']).to be false @@ -95,7 +95,7 @@ describe API::SystemHooks do merge_requests_events: true } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['enable_ssl_verification']).to be false expect(json_response['push_events']).to be true expect(json_response['tag_push_events']).to be true @@ -106,13 +106,13 @@ describe API::SystemHooks do describe "GET /hooks/:id" do it "returns hook by id" do get api("/hooks/#{hook.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['event_name']).to eq('project_create') end it "returns 404 on failure" do get api("/hooks/404", admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -121,14 +121,14 @@ describe API::SystemHooks do expect do delete api("/hooks/#{hook.id}", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { SystemHook.count }.by(-1) end it 'returns 404 if the system hook does not exist' do delete api('/hooks/12345', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index f3ee1dc8435..d6e867ee407 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -71,30 +71,30 @@ describe 'Every Sidekiq worker' do # concurrency, so that each job can consume a large amounts of memory. For this reason, on # GitLab.com, when a large number of memory-bound jobs arrive at once, we let them queue up # rather than scaling the hardware to meet the SLO. For this reason, memory-bound, - # latency-sensitive jobs are explicitly discouraged and disabled. - it 'is (exclusively) memory-bound or latency-sentitive, not both', :aggregate_failures do - latency_sensitive_workers = workers_without_defaults - .select(&:latency_sensitive_worker?) + # high urgency jobs are explicitly discouraged and disabled. + it 'is (exclusively) memory-bound or high urgency, not both', :aggregate_failures do + high_urgency_workers = workers_without_defaults + .select { |worker| worker.get_urgency == :high } - latency_sensitive_workers.each do |worker| - expect(worker.get_worker_resource_boundary).not_to eq(:memory), "#{worker.inspect} cannot be both memory-bound and latency sensitive" + high_urgency_workers.each do |worker| + expect(worker.get_worker_resource_boundary).not_to eq(:memory), "#{worker.inspect} cannot be both memory-bound and high urgency" end end - # In high traffic installations, such as GitLab.com, `latency_sensitive` workers run in a - # dedicated fleet. In order to ensure short queue times, `latency_sensitive` jobs have strict + # In high traffic installations, such as GitLab.com, `urgency :high` workers run in a + # dedicated fleet. In order to ensure short queue times, `urgency :high` jobs have strict # SLOs in order to ensure throughput. However, when a worker depends on an external service, # such as a user's k8s cluster or a third-party internet service, we cannot guarantee latency, # and therefore throughput. An outage to an 3rd party service could therefore impact throughput - # on other latency_sensitive jobs, leading to degradation through the GitLab application. - # Please see doc/development/sidekiq_style_guide.md#Jobs-with-External-Dependencies for more + # on other high urgency jobs, leading to degradation through the GitLab application. + # Please see doc/development/sidekiq_style_guide.md#jobs-with-external-dependencies for more # details. - it 'has (exclusively) external dependencies or is latency-sentitive, not both', :aggregate_failures do - latency_sensitive_workers = workers_without_defaults - .select(&:latency_sensitive_worker?) + it 'has (exclusively) external dependencies or is high urgency, not both', :aggregate_failures do + high_urgency_workers = workers_without_defaults + .select { |worker| worker.get_urgency == :high } - latency_sensitive_workers.each do |worker| - expect(worker.worker_has_external_dependencies?).to be_falsey, "#{worker.inspect} cannot have both external dependencies and be latency sensitive" + high_urgency_workers.each do |worker| + expect(worker.worker_has_external_dependencies?).to be_falsey, "#{worker.inspect} cannot have both external dependencies and be high urgency" end end end |