Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 12:08:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 12:08:30 +0300
commit5ccb67600c63549774a28811d177dd673e6dd4d0 (patch)
treec8af595d48607c660564fd89d77b47c3384501af
parent6a201406143969f12cb9e4687a79ce9316420152 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue15
-rw-r--r--app/assets/javascripts/issues/show/components/incidents/timeline_events_tab.vue1
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/models/work_items/widgets/hierarchy.rb4
-rw-r--r--app/services/projects/update_pages_service.rb138
-rw-r--r--app/views/projects/_files.html.haml2
-rw-r--r--config/feature_flags/development/incident_timeline.yml2
-rw-r--r--config/feature_flags/development/log_response_length.yml8
-rw-r--r--doc/administration/monitoring/prometheus/gitlab_metrics.md1
-rw-r--r--lib/api/api.rb3
-rw-r--r--lib/gitlab/grape_logging/loggers/response_logger.rb19
-rw-r--r--lib/gitlab/i18n.rb2
-rw-r--r--lib/gitlab/lograge/custom_options.rb6
-rw-r--r--lib/gitlab/pages/deployment_update.rb111
-rw-r--r--lib/gitlab/sidekiq_middleware/server_metrics.rb5
-rw-r--r--lib/tasks/gems.rake4
-rw-r--r--qa/qa/fixtures/software_licenses/GFDL-1.2-only397
-rw-r--r--qa/qa/fixtures/software_licenses/bsd-3-clause11
-rw-r--r--qa/qa/page/project/show.rb7
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/license_detecton_spec.rb45
-rw-r--r--spec/controllers/application_controller_spec.rb22
-rw-r--r--spec/frontend/issues/show/components/incidents/timeline_events_form_spec.js31
-rw-r--r--spec/frontend/issues/show/components/incidents/timeline_events_tab_spec.js9
-rw-r--r--spec/lib/gitlab/grape_logging/loggers/response_logger_spec.rb31
-rw-r--r--spec/lib/gitlab/lograge/custom_options_spec.rb17
-rw-r--r--spec/lib/gitlab/pages/deployment_update_spec.rb140
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb10
-rw-r--r--spec/models/environment_spec.rb8
-rw-r--r--spec/models/work_items/widgets/hierarchy_spec.rb35
-rw-r--r--spec/services/projects/update_pages_service_spec.rb44
-rw-r--r--spec/support/shared_contexts/lib/gitlab/sidekiq_middleware/server_metrics_shared_context.rb2
-rw-r--r--vendor/gems/error_tracking_open_api/Gemfile9
-rw-r--r--vendor/gems/error_tracking_open_api/README.md2
33 files changed, 972 insertions, 173 deletions
diff --git a/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue b/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue
index ccebf3ea7cf..36ec6362a22 100644
--- a/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue
+++ b/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue
@@ -58,6 +58,12 @@ export default {
};
},
methods: {
+ clear() {
+ const utcShiftedDate = getUtcShiftedDateNow();
+ this.currentDate = utcShiftedDate;
+ this.currentHour = utcShiftedDate.getHours();
+ this.currentMinute = utcShiftedDate.getMinutes();
+ },
hideIncidentTimelineEventForm() {
this.$emit('hide-incident-timeline-event-form');
},
@@ -154,16 +160,17 @@ export default {
>
<gl-icon name="comment" class="note-icon" />
</div>
- <form class="gl-flex-grow-1" :class="{ 'gl-border-t': hasTimelineEvents }">
+ <form class="gl-flex-grow-1 gl-border-gray-50" :class="{ 'gl-border-t': hasTimelineEvents }">
<div
class="gl-display-flex gl-flex-direction-column gl-sm-flex-direction-row datetime-picker"
>
- <gl-form-group :label="__('Date')" class="gl-mt-3 gl-mr-3">
+ <gl-form-group :label="__('Date')" class="gl-mt-5 gl-mr-5">
<gl-datepicker id="incident-date" #default="{ formattedDate }" v-model="currentDate">
<gl-form-input
id="incident-date"
ref="datepicker"
v-model="datepickerTextInput"
+ data-testid="input-datepicker"
class="gl-datepicker-input gl-pr-7!"
:value="formattedDate"
:placeholder="__('YYYY-MM-DD')"
@@ -171,7 +178,7 @@ export default {
/>
</gl-datepicker>
</gl-form-group>
- <div class="gl-display-flex gl-mt-3">
+ <div class="gl-display-flex gl-mt-5">
<gl-form-group :label="__('Time')">
<div class="gl-display-flex">
<label label-for="timeline-input-hours" class="sr-only"></label>
@@ -201,7 +208,7 @@ export default {
</div>
</div>
<div class="common-note-form">
- <gl-form-group :label="$options.i18n.areaLabel">
+ <gl-form-group class="gl-mb-3" :label="$options.i18n.areaLabel">
<markdown-field
:can-attach-file="false"
:add-spacing-classes="false"
diff --git a/app/assets/javascripts/issues/show/components/incidents/timeline_events_tab.vue b/app/assets/javascripts/issues/show/components/incidents/timeline_events_tab.vue
index 78ee994aba8..e1946ef4d07 100644
--- a/app/assets/javascripts/issues/show/components/incidents/timeline_events_tab.vue
+++ b/app/assets/javascripts/issues/show/components/incidents/timeline_events_tab.vue
@@ -61,6 +61,7 @@ export default {
this.isEventFormVisible = false;
},
async showEventForm() {
+ this.$refs.eventForm.clear();
this.isEventFormVisible = true;
await this.$nextTick();
this.$refs.eventForm.focusDate();
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 30760d472a4..71d9910b4b8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -179,6 +179,10 @@ class ApplicationController < ActionController::Base
payload[:queue_duration_s] = request.env[::Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY]
+ if Feature.enabled?(:log_response_length)
+ payload[:response_bytes] = response.body_parts.sum(&:bytesize)
+ end
+
store_cloudflare_headers!(payload, request)
end
diff --git a/app/models/work_items/widgets/hierarchy.rb b/app/models/work_items/widgets/hierarchy.rb
index e4367bc8ff1..930aced8ace 100644
--- a/app/models/work_items/widgets/hierarchy.rb
+++ b/app/models/work_items/widgets/hierarchy.rb
@@ -4,13 +4,13 @@ module WorkItems
module Widgets
class Hierarchy < Base
def parent
- return unless Feature.enabled?(:work_items, work_item.project)
+ return unless work_item.project.work_items_feature_flag_enabled?
work_item.work_item_parent
end
def children
- return WorkItem.none unless Feature.enabled?(:work_items, work_item.project)
+ return WorkItem.none unless work_item.project.work_items_feature_flag_enabled?
work_item.work_item_children
end
diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb
index 217c492bd72..dd1c2b94e18 100644
--- a/app/services/projects/update_pages_service.rb
+++ b/app/services/projects/update_pages_service.rb
@@ -2,21 +2,17 @@
module Projects
class UpdatePagesService < BaseService
- InvalidStateError = Class.new(StandardError)
- WrongUploadedDeploymentSizeError = Class.new(StandardError)
- BLOCK_SIZE = 32.kilobytes
- PUBLIC_DIR = 'public'
-
# old deployment can be cached by pages daemon
# so we need to give pages daemon some time update cache
# 10 minutes is enough, but 30 feels safer
OLD_DEPLOYMENTS_DESTRUCTION_DELAY = 30.minutes.freeze
- attr_reader :build
+ attr_reader :build, :deployment_update
def initialize(project, build)
@project = project
@build = build
+ @deployment_update = ::Gitlab::Pages::DeploymentUpdate.new(project, build)
end
def execute
@@ -29,20 +25,20 @@ module Projects
job.run!
end
- validate_state!
- validate_max_size!
- validate_public_folder!
- validate_max_entries!
+ return error(deployment_update.errors.first.full_message) unless deployment_update.valid?
build.artifacts_file.use_file do |artifacts_path|
- create_pages_deployment(artifacts_path, build)
- success
+ deployment = create_pages_deployment(artifacts_path, build)
+
+ break error('The uploaded artifact size does not match the expected value') unless deployment
+
+ if deployment_update.valid?
+ update_project_pages_deployment(deployment)
+ success
+ else
+ error(deployment_update.errors.first.full_message)
+ end
end
- rescue InvalidStateError => e
- error(e.message)
- rescue WrongUploadedDeploymentSizeError => e
- error("Uploading artifacts to pages storage failed")
- raise e
rescue StandardError => e
error(e.message)
raise e
@@ -60,7 +56,7 @@ module Projects
def error(message)
register_failure
log_error("Projects::UpdatePagesService: #{message}")
- @commit_status.allow_failure = !latest?
+ @commit_status.allow_failure = !deployment_update.latest?
@commit_status.description = message
@commit_status.drop(:script_failure)
super
@@ -76,24 +72,22 @@ module Projects
def create_pages_deployment(artifacts_path, build)
sha256 = build.job_artifacts_archive.file_sha256
-
- deployment = nil
File.open(artifacts_path) do |file|
- deployment = project.pages_deployments.create!(file: file,
- file_count: entries_count,
- file_sha256: sha256,
- ci_build_id: build.id
- )
-
- if deployment.size != file.size || deployment.file.size != file.size
- raise(WrongUploadedDeploymentSizeError)
- end
+ deployment = project.pages_deployments.create!(
+ file: file,
+ file_count: deployment_update.entries_count,
+ file_sha256: sha256,
+ ci_build_id: build.id
+ )
- validate_outdated_sha!
+ break if deployment.size != file.size || deployment.file.size != file.size
- project.update_pages_deployment!(deployment)
+ deployment
end
+ end
+ def update_project_pages_deployment(deployment)
+ project.update_pages_deployment!(deployment)
DestroyPagesDeploymentsWorker.perform_in(
OLD_DEPLOYMENTS_DESTRUCTION_DELAY,
project.id,
@@ -109,17 +103,6 @@ module Projects
build.artifacts_file.path
end
- def latest_sha
- project.commit(build.ref).try(:sha).to_s
- ensure
- # Close any file descriptors that were opened and free libgit2 buffers
- project.cleanup
- end
-
- def sha
- build.sha
- end
-
def register_attempt
pages_deployments_total_counter.increment
end
@@ -136,75 +119,6 @@ module Projects
@pages_deployments_failed_total_counter ||= Gitlab::Metrics.counter(:pages_deployments_failed_total, "Counter of GitLab Pages deployments which failed")
end
- def validate_state!
- raise InvalidStateError, 'missing pages artifacts' unless build.artifacts?
- raise InvalidStateError, 'missing artifacts metadata' unless build.artifacts_metadata?
-
- validate_outdated_sha!
- end
-
- def validate_outdated_sha!
- return if latest?
-
- # use pipeline_id in case the build is retried
- last_deployed_pipeline_id = project.pages_metadatum&.pages_deployment&.ci_build&.pipeline_id
-
- return unless last_deployed_pipeline_id
- return if last_deployed_pipeline_id <= build.pipeline_id
-
- raise InvalidStateError, 'build SHA is outdated for this ref'
- end
-
- def latest?
- # check if sha for the ref is still the most recent one
- # this helps in case when multiple deployments happens
- sha == latest_sha
- end
-
- def validate_max_size!
- if total_size > max_size
- raise InvalidStateError, "artifacts for pages are too large: #{total_size}"
- end
- end
-
- # Calculate page size after extract
- def total_size
- @total_size ||= build.artifacts_metadata_entry(PUBLIC_DIR + '/', recursive: true).total_size
- end
-
- def max_size_from_settings
- Gitlab::CurrentSettings.max_pages_size.megabytes
- end
-
- def max_size
- max_pages_size = max_size_from_settings
-
- return ::Gitlab::Pages::MAX_SIZE if max_pages_size == 0
-
- max_pages_size
- end
-
- def validate_max_entries!
- if pages_file_entries_limit > 0 && entries_count > pages_file_entries_limit
- raise InvalidStateError, "pages site contains #{entries_count} file entries, while limit is set to #{pages_file_entries_limit}"
- end
- end
-
- def validate_public_folder!
- raise InvalidStateError, 'Error: The `public/` folder is missing, or not declared in `.gitlab-ci.yml`.' unless total_size > 0
- end
-
- def entries_count
- # we're using the full archive and pages daemon needs to read it
- # so we want the total count from entries, not only "public/" directory
- # because it better approximates work we need to do before we can serve the site
- @entries_count = build.artifacts_metadata_entry("", recursive: true).entries.count
- end
-
- def pages_file_entries_limit
- project.actual_limits.pages_file_entries
- end
-
def publish_deployed_event
event = ::Pages::PageDeployedEvent.new(data: {
project_id: project.id,
@@ -216,5 +130,3 @@ module Projects
end
end
end
-
-Projects::UpdatePagesService.prepend_mod_with('Projects::UpdatePagesService')
diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml
index cc96a084b03..319c6333e77 100644
--- a/app/views/projects/_files.html.haml
+++ b/app/views/projects/_files.html.haml
@@ -16,7 +16,7 @@
#js-code-owners
- if is_project_overview
- .project-buttons.gl-mb-5.js-show-on-project-root
+ .project-buttons.gl-mb-5.js-show-on-project-root{ data: { qa_selector: 'project_buttons' } }
= render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout), project_buttons: true
#js-tree-list{ data: vue_file_list_data(project, ref) }
diff --git a/config/feature_flags/development/incident_timeline.yml b/config/feature_flags/development/incident_timeline.yml
index 09a08b9fcb6..587ef8b55e8 100644
--- a/config/feature_flags/development/incident_timeline.yml
+++ b/config/feature_flags/development/incident_timeline.yml
@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/353426
milestone: '14.9'
type: development
group: group::respond
-default_enabled: false
+default_enabled: true
diff --git a/config/feature_flags/development/log_response_length.yml b/config/feature_flags/development/log_response_length.yml
new file mode 100644
index 00000000000..1ade057204c
--- /dev/null
+++ b/config/feature_flags/development/log_response_length.yml
@@ -0,0 +1,8 @@
+---
+name: log_response_length
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91448
+rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/366854
+milestone: '15.3'
+type: development
+group: group::workspace
+default_enabled: false
diff --git a/doc/administration/monitoring/prometheus/gitlab_metrics.md b/doc/administration/monitoring/prometheus/gitlab_metrics.md
index 7fd03ee137b..d6575766b17 100644
--- a/doc/administration/monitoring/prometheus/gitlab_metrics.md
+++ b/doc/administration/monitoring/prometheus/gitlab_metrics.md
@@ -178,6 +178,7 @@ configuration option in `gitlab.yml`. These metrics are served from the
| `sidekiq_jobs_queue_duration_seconds` | Histogram | 12.5 | Duration in seconds that a Sidekiq job was queued before being executed | `queue`, `boundary`, `external_dependencies`, `feature_category`, `urgency` |
| `sidekiq_jobs_failed_total` | Counter | 12.2 | Sidekiq jobs failed | `queue`, `boundary`, `external_dependencies`, `feature_category`, `urgency` |
| `sidekiq_jobs_retried_total` | Counter | 12.2 | Sidekiq jobs retried | `queue`, `boundary`, `external_dependencies`, `feature_category`, `urgency` |
+| `sidekiq_jobs_interrupted_total` | Counter | 15.2 | Sidekiq jobs interrupted | `queue`, `boundary`, `external_dependencies`, `feature_category`, `urgency` |
| `sidekiq_jobs_dead_total` | Counter | 13.7 | Sidekiq dead jobs (jobs that have run out of retries) | `queue`, `boundary`, `external_dependencies`, `feature_category`, `urgency` |
| `sidekiq_redis_requests_total` | Counter | 13.1 | Redis requests during a Sidekiq job execution | `queue`, `boundary`, `external_dependencies`, `feature_category`, `job_status`, `urgency` |
| `sidekiq_elasticsearch_requests_total` | Counter | 13.1 | Elasticsearch requests during a Sidekiq job execution | `queue`, `boundary`, `external_dependencies`, `feature_category`, `job_status`, `urgency` |
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 8c0278c9e12..8827371546c 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -28,7 +28,8 @@ module API
Gitlab::GrapeLogging::Loggers::CorrelationIdLogger.new,
Gitlab::GrapeLogging::Loggers::ContextLogger.new,
Gitlab::GrapeLogging::Loggers::ContentLogger.new,
- Gitlab::GrapeLogging::Loggers::UrgencyLogger.new
+ Gitlab::GrapeLogging::Loggers::UrgencyLogger.new,
+ Gitlab::GrapeLogging::Loggers::ResponseLogger.new
]
allow_access_with_scope :api
diff --git a/lib/gitlab/grape_logging/loggers/response_logger.rb b/lib/gitlab/grape_logging/loggers/response_logger.rb
new file mode 100644
index 00000000000..0465f01f7f5
--- /dev/null
+++ b/lib/gitlab/grape_logging/loggers/response_logger.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module GrapeLogging
+ module Loggers
+ class ResponseLogger < ::GrapeLogging::Loggers::Base
+ def parameters(_, response)
+ return {} unless Feature.enabled?(:log_response_length)
+
+ response_bytes = 0
+ response.each { |resp| response_bytes += resp.to_s.bytesize }
+ {
+ response_bytes: response_bytes
+ }
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb
index 269d8bd3bad..cad0e773b05 100644
--- a/lib/gitlab/i18n.rb
+++ b/lib/gitlab/i18n.rb
@@ -25,6 +25,7 @@ module Gitlab
'pt_BR' => 'Portuguese (Brazil) - português (Brasil)',
'ro_RO' => 'Romanian - română',
'ru' => 'Russian - русский',
+ 'si_LK' => 'Sinhalese - සිංහල',
'tr_TR' => 'Turkish - Türkçe',
'uk' => 'Ukrainian - українська',
'zh_CN' => 'Chinese, Simplified - 简体中文',
@@ -61,6 +62,7 @@ module Gitlab
'pt_BR' => 55,
'ro_RO' => 100,
'ru' => 28,
+ 'si_LK' => 11,
'tr_TR' => 12,
'uk' => 49,
'zh_CN' => 99,
diff --git a/lib/gitlab/lograge/custom_options.rb b/lib/gitlab/lograge/custom_options.rb
index 84ead5119d5..f8ec58cf217 100644
--- a/lib/gitlab/lograge/custom_options.rb
+++ b/lib/gitlab/lograge/custom_options.rb
@@ -7,7 +7,7 @@ module Gitlab
LIMITED_ARRAY_SENTINEL = { key: 'truncated', value: '...' }.freeze
IGNORE_PARAMS = Set.new(%w(controller action format)).freeze
- KNOWN_PAYLOAD_PARAMS = [:remote_ip, :user_id, :username, :ua, :queue_duration_s,
+ KNOWN_PAYLOAD_PARAMS = [:remote_ip, :user_id, :username, :ua, :queue_duration_s, :response_bytes,
:etag_route, :request_urgency, :target_duration_s] + CLOUDFLARE_CUSTOM_HEADERS.values
def self.call(event)
@@ -36,6 +36,10 @@ module Gitlab
payload[:feature_flag_states] = Feature.logged_states.map { |key, state| "#{key}:#{state ? 1 : 0}" }
end
+ if Feature.disabled?(:log_response_length)
+ payload.delete(:response_bytes)
+ end
+
payload
end
end
diff --git a/lib/gitlab/pages/deployment_update.rb b/lib/gitlab/pages/deployment_update.rb
new file mode 100644
index 00000000000..2f5c6938e2a
--- /dev/null
+++ b/lib/gitlab/pages/deployment_update.rb
@@ -0,0 +1,111 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Pages
+ class DeploymentUpdate
+ include ActiveModel::Validations
+
+ PUBLIC_DIR = 'public'
+
+ validate :validate_state, unless: -> { errors.any? }
+ validate :validate_outdated_sha, unless: -> { errors.any? }
+ validate :validate_max_size, unless: -> { errors.any? }
+ validate :validate_public_folder, unless: -> { errors.any? }
+ validate :validate_max_entries, unless: -> { errors.any? }
+
+ def initialize(project, build)
+ @project = project
+ @build = build
+ end
+
+ def latest?
+ # check if sha for the ref is still the most recent one
+ # this helps in case when multiple deployments happens
+ sha == latest_sha
+ end
+
+ def entries_count
+ # we're using the full archive and pages daemon needs to read it
+ # so we want the total count from entries, not only "public/" directory
+ # because it better approximates work we need to do before we can serve the site
+ @entries_count = build.artifacts_metadata_entry("", recursive: true).entries.count
+ end
+
+ private
+
+ attr_reader :build, :project
+
+ def validate_state
+ errors.add(:base, 'missing pages artifacts') unless build.artifacts?
+ errors.add(:base, 'missing artifacts metadata') unless build.artifacts_metadata?
+ end
+
+ def validate_max_size
+ if total_size > max_size
+ errors.add(:base, "artifacts for pages are too large: #{total_size}")
+ end
+ end
+
+ # Calculate page size after extract
+ def total_size
+ @total_size ||= build.artifacts_metadata_entry(PUBLIC_DIR + '/', recursive: true).total_size
+ end
+
+ def max_size_from_settings
+ Gitlab::CurrentSettings.max_pages_size.megabytes
+ end
+
+ def max_size
+ max_pages_size = max_size_from_settings
+
+ return ::Gitlab::Pages::MAX_SIZE if max_pages_size == 0
+
+ max_pages_size
+ end
+
+ def validate_max_entries
+ if pages_file_entries_limit > 0 && entries_count > pages_file_entries_limit
+ errors.add(
+ :base,
+ "pages site contains #{entries_count} file entries, while limit is set to #{pages_file_entries_limit}"
+ )
+ end
+ end
+
+ def validate_public_folder
+ if total_size <= 0
+ errors.add(:base, 'Error: The `public/` folder is missing, or not declared in `.gitlab-ci.yml`.')
+ end
+ end
+
+ def pages_file_entries_limit
+ project.actual_limits.pages_file_entries
+ end
+
+ def validate_outdated_sha
+ return if latest?
+
+ # use pipeline_id in case the build is retried
+ last_deployed_pipeline_id = project.pages_metadatum&.pages_deployment&.ci_build&.pipeline_id
+
+ return unless last_deployed_pipeline_id
+ return if last_deployed_pipeline_id <= build.pipeline_id
+
+ errors.add(:base, 'build SHA is outdated for this ref')
+ end
+
+ def latest_sha
+ project.commit(build.ref).try(:sha).to_s
+ ensure
+ # Close any file descriptors that were opened and free libgit2 buffers
+ project.cleanup
+ end
+
+ def sha
+ build.sha
+ end
+ end
+ end
+end
+
+Gitlab::Pages::DeploymentUpdate.prepend_mod_with('Gitlab::Pages::DeploymentUpdate')
diff --git a/lib/gitlab/sidekiq_middleware/server_metrics.rb b/lib/gitlab/sidekiq_middleware/server_metrics.rb
index dc5481289da..ea2b405c934 100644
--- a/lib/gitlab/sidekiq_middleware/server_metrics.rb
+++ b/lib/gitlab/sidekiq_middleware/server_metrics.rb
@@ -31,6 +31,7 @@ module Gitlab
sidekiq_elasticsearch_requests_duration_seconds: ::Gitlab::Metrics.histogram(:sidekiq_elasticsearch_requests_duration_seconds, 'Duration in seconds that a Sidekiq job spent in requests to an Elasticsearch server', {}, SIDEKIQ_LATENCY_BUCKETS),
sidekiq_jobs_failed_total: ::Gitlab::Metrics.counter(:sidekiq_jobs_failed_total, 'Sidekiq jobs failed'),
sidekiq_jobs_retried_total: ::Gitlab::Metrics.counter(:sidekiq_jobs_retried_total, 'Sidekiq jobs retried'),
+ sidekiq_jobs_interrupted_total: ::Gitlab::Metrics.counter(:sidekiq_jobs_interrupted_total, 'Sidekiq jobs interrupted'),
sidekiq_redis_requests_total: ::Gitlab::Metrics.counter(:sidekiq_redis_requests_total, 'Redis requests during a Sidekiq job execution'),
sidekiq_elasticsearch_requests_total: ::Gitlab::Metrics.counter(:sidekiq_elasticsearch_requests_total, 'Elasticsearch requests during a Sidekiq job execution'),
sidekiq_running_jobs: ::Gitlab::Metrics.gauge(:sidekiq_running_jobs, 'Number of Sidekiq jobs running', {}, :all),
@@ -89,6 +90,10 @@ module Gitlab
@metrics[:sidekiq_jobs_retried_total].increment(labels, 1)
end
+ if job['interrupted_count'].present?
+ @metrics[:sidekiq_jobs_interrupted_total].increment(labels, 1)
+ end
+
job_succeeded = false
monotonic_time_start = Gitlab::Metrics::System.monotonic_time
job_thread_cputime_start = get_thread_cputime
diff --git a/lib/tasks/gems.rake b/lib/tasks/gems.rake
index 27ea735059e..c6be6d9eead 100644
--- a/lib/tasks/gems.rake
+++ b/lib/tasks/gems.rake
@@ -1,6 +1,7 @@
# frozen_string_literal: true
namespace :gems do
+ # :nocov:
namespace :error_tracking_open_api do
desc 'Generate OpenAPI client for Error Tracking'
# rubocop:disable Rails/RakeEnvironment
@@ -29,7 +30,6 @@ namespace :gems do
end
# rubocop:enable Rails/RakeEnvironment
- # Stubbed in specs
def root_directory
File.expand_path('../../vendor/gems', __dir__)
end
@@ -59,6 +59,7 @@ namespace :gems do
replace_string(content, /(\.test_files\s*=).*/, '\1 []')
end
+ remove_entry_secure(gem_dir / 'Gemfile')
remove_entry_secure(gem_dir / '.rubocop.yml')
remove_entry_secure(gem_dir / '.travis.yml')
remove_entry_secure(gem_dir / 'git_push.sh')
@@ -103,4 +104,5 @@ namespace :gems do
LICENSE
end
end
+ # :nocov:
end
diff --git a/qa/qa/fixtures/software_licenses/GFDL-1.2-only b/qa/qa/fixtures/software_licenses/GFDL-1.2-only
new file mode 100644
index 00000000000..4421c2a496a
--- /dev/null
+++ b/qa/qa/fixtures/software_licenses/GFDL-1.2-only
@@ -0,0 +1,397 @@
+GNU Free Documentation License
+Version 1.2, November 2002
+
+
+Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+
+0. PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document "free" in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of "copyleft", which means that derivative
+works of the document must themselves be free in the same sense. It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does. But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book. We recommend this License
+principally for works whose purpose is instruction or reference.
+
+
+1. APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License. Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein. The "Document", below,
+refers to any such manual or work. Any member of the public is a
+licensee, and is addressed as "you". You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A "Modified Version" of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A "Secondary Section" is a named appendix or a front-matter section of
+the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall subject
+(or to related matters) and contains nothing that could fall directly
+within that overall subject. (Thus, if the Document is in part a
+textbook of mathematics, a Secondary Section may not explain any
+mathematics.) The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The "Invariant Sections" are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License. If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant. The Document may contain zero
+Invariant Sections. If the Document does not identify any Invariant
+Sections then there are none.
+
+The "Cover Texts" are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License. A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A "Transparent" copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters. A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text. A copy that is not "Transparent" is called "Opaque".
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, LaTeX input format, SGML
+or XML using a publicly available DTD, and standard-conforming simple
+HTML, PostScript or PDF designed for human modification. Examples of
+transparent image formats include PNG, XCF and JPG. Opaque formats
+include proprietary formats that can be read and edited only by
+proprietary word processors, SGML or XML for which the DTD and/or
+processing tools are not generally available, and the
+machine-generated HTML, PostScript or PDF produced by some word
+processors for output purposes only.
+
+The "Title Page" means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page. For works in
+formats which do not have any title page as such, "Title Page" means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+A section "Entitled XYZ" means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language. (Here XYZ stands for a
+specific section name mentioned below, such as "Acknowledgements",
+"Dedications", "Endorsements", or "History".) To "Preserve the Title"
+of such a section when you modify the Document means that it remains a
+section "Entitled XYZ" according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document. These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+
+2. VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no other
+conditions whatsoever to those of this License. You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute. However, you may accept
+compensation in exchange for copies. If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+
+3. COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover. Both covers must also clearly and legibly identify
+you as the publisher of these copies. The front cover must present
+the full title with all words of the title equally prominent and
+visible. You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to give
+them a chance to provide you with an updated version of the Document.
+
+
+4. MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it. In addition, you must do these things in the Modified Version:
+
+A. Use in the Title Page (and on the covers, if any) a title distinct
+from that of the Document, and from those of previous versions
+(which should, if there were any, be listed in the History section
+of the Document). You may use the same title as a previous version
+if the original publisher of that version gives permission.
+B. List on the Title Page, as authors, one or more persons or entities
+responsible for authorship of the modifications in the Modified
+Version, together with at least five of the principal authors of the
+Document (all of its principal authors, if it has fewer than five),
+unless they release you from this requirement.
+C. State on the Title page the name of the publisher of the
+Modified Version, as the publisher.
+D. Preserve all the copyright notices of the Document.
+E. Add an appropriate copyright notice for your modifications
+adjacent to the other copyright notices.
+F. Include, immediately after the copyright notices, a license notice
+giving the public permission to use the Modified Version under the
+terms of this License, in the form shown in the Addendum below.
+G. Preserve in that license notice the full lists of Invariant Sections
+and required Cover Texts given in the Document's license notice.
+H. Include an unaltered copy of this License.
+I. Preserve the section Entitled "History", Preserve its Title, and add
+to it an item stating at least the title, year, new authors, and
+publisher of the Modified Version as given on the Title Page. If
+there is no section Entitled "History" in the Document, create one
+stating the title, year, authors, and publisher of the Document as
+given on its Title Page, then add an item describing the Modified
+Version as stated in the previous sentence.
+J. Preserve the network location, if any, given in the Document for
+public access to a Transparent copy of the Document, and likewise
+the network locations given in the Document for previous versions
+it was based on. These may be placed in the "History" section.
+You may omit a network location for a work that was published at
+least four years before the Document itself, or if the original
+publisher of the version it refers to gives permission.
+K. For any section Entitled "Acknowledgements" or "Dedications",
+Preserve the Title of the section, and preserve in the section all
+the substance and tone of each of the contributor acknowledgements
+and/or dedications given therein.
+L. Preserve all the Invariant Sections of the Document,
+unaltered in their text and in their titles. Section numbers
+or the equivalent are not considered part of the section titles.
+M. Delete any section Entitled "Endorsements". Such a section
+may not be included in the Modified Version.
+N. Do not retitle any existing section to be Entitled "Endorsements"
+or to conflict in title with any Invariant Section.
+O. Preserve any Warranty Disclaimers.
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant. To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled "Endorsements", provided it contains
+nothing but endorsements of your Modified Version by various
+parties--for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version. Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity. If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+
+5. COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy. If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled "History"
+in the various original documents, forming one section Entitled
+"History"; likewise combine any sections Entitled "Acknowledgements",
+and any sections Entitled "Dedications". You must delete all sections
+Entitled "Endorsements".
+
+
+6. COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other documents
+released under this License, and replace the individual copies of this
+License in the various documents with a single copy that is included in
+the collection, provided that you follow the rules of this License for
+verbatim copying of each of the documents in all other respects.
+
+You may extract a single document from such a collection, and distribute
+it individually under this License, provided you insert a copy of this
+License into the extracted document, and follow this License in all
+other respects regarding verbatim copying of that document.
+
+
+7. AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an "aggregate" if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+
+8. TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections. You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers. In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled "Acknowledgements",
+"Dedications", or "History", the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+
+9. TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document except
+as expressly provided for under this License. Any other attempt to
+copy, modify, sublicense or distribute the Document is void, and will
+automatically terminate your rights under this License. However,
+parties who have received copies, or rights, from you under this
+License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+
+10. FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions
+of the GNU Free Documentation License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns. See
+https://www.gnu.org/licenses/.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License "or any later version" applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation. If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation.
+
+
+ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+Copyright (c) YEAR YOUR NAME.
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.2
+or any later version published by the Free Software Foundation;
+with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the section entitled "GNU
+Free Documentation License".
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the "with...Texts." line with this:
+
+with the Invariant Sections being LIST THEIR TITLES, with the
+Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
diff --git a/qa/qa/fixtures/software_licenses/bsd-3-clause b/qa/qa/fixtures/software_licenses/bsd-3-clause
new file mode 100644
index 00000000000..3deb7c523fb
--- /dev/null
+++ b/qa/qa/fixtures/software_licenses/bsd-3-clause
@@ -0,0 +1,11 @@
+Copyright 2022 Joe Bloggs
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index 9983ee2a33d..022e08215be 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -44,6 +44,7 @@ module QA
end
view 'app/views/projects/_files.html.haml' do
+ element :project_buttons
element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern
end
@@ -193,6 +194,12 @@ module QA
has_element?(:badge_image_link, link_url: link_url)
end
end
+
+ def has_license?(name)
+ within_element(:project_buttons) do
+ has_link?(name)
+ end
+ end
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/license_detecton_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/license_detecton_spec.rb
new file mode 100644
index 00000000000..8074e1fa992
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/license_detecton_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.describe 'Create' do
+ describe 'Repository License Detection' do
+ after do
+ project.remove_via_api!
+ end
+
+ let(:project) { Resource::Project.fabricate_via_api! }
+
+ shared_examples 'project license detection' do
+ it 'displays the name of the license on the repository' do
+ license_path = File.expand_path("../../../../../fixtures/software_licenses/#{license_file_name}", __dir__)
+ Resource::Repository::Commit.fabricate_via_api! do |commit|
+ commit.project = project
+ commit.add_files([{ file_path: 'LICENSE', content: File.read(license_path) }])
+ end
+
+ project.visit!
+
+ Page::Project::Show.perform do |show|
+ expect(show).to have_license(rendered_license_name)
+ end
+ end
+ end
+
+ context 'on a project with a commonly used LICENSE',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/366842' do
+ it_behaves_like 'project license detection' do
+ let(:license_file_name) {'bsd-3-clause'}
+ let(:rendered_license_name) {'BSD 3-Clause "New" or "Revised" License'}
+ end
+ end
+
+ context 'on a project with a less commonly used LICENSE',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/366843' do
+ it_behaves_like 'project license detection' do
+ let(:license_file_name) {'GFDL-1.2-only'}
+ let(:rendered_license_name) {'Other'}
+ end
+ end
+ end
+ end
+end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index c5306fda0a5..1e28ef4ba93 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -559,6 +559,28 @@ RSpec.describe ApplicationController do
expect(controller.last_payload[:target_duration_s]).to eq(0.25)
end
end
+
+ it 'logs response length' do
+ sign_in user
+
+ get :index
+
+ expect(controller.last_payload[:response_bytes]).to eq('authenticated'.bytesize)
+ end
+
+ context 'with log_response_length disabled' do
+ before do
+ stub_feature_flags(log_response_length: false)
+ end
+
+ it 'logs response length' do
+ sign_in user
+
+ get :index
+
+ expect(controller.last_payload).not_to include(:response_bytes)
+ end
+ end
end
describe '#access_denied' do
diff --git a/spec/frontend/issues/show/components/incidents/timeline_events_form_spec.js b/spec/frontend/issues/show/components/incidents/timeline_events_form_spec.js
index 78a2dfac358..620cdfc53b0 100644
--- a/spec/frontend/issues/show/components/incidents/timeline_events_form_spec.js
+++ b/spec/frontend/issues/show/components/incidents/timeline_events_form_spec.js
@@ -7,6 +7,7 @@ import IncidentTimelineEventForm from '~/issues/show/components/incidents/timeli
import createTimelineEventMutation from '~/issues/show/components/incidents/graphql/queries/create_timeline_event.mutation.graphql';
import createMockApollo from 'helpers/mock_apollo_helper';
import { createAlert } from '~/flash';
+import { useFakeDate } from 'helpers/fake_date';
import { timelineEventsCreateEventResponse, timelineEventsCreateEventError } from './mock_data';
Vue.use(VueApollo);
@@ -21,6 +22,8 @@ function createMockApolloProvider(response = addEventResponse) {
}
describe('Timeline events form', () => {
+ // July 8 2020
+ useFakeDate(2020, 6, 8);
let wrapper;
const mountComponent = ({ mockApollo, mountMethod = shallowMountExtended, stubs }) => {
@@ -49,8 +52,14 @@ describe('Timeline events form', () => {
const findSubmitAndAddButton = () => wrapper.findByText('Save and add another event');
const findCancelButton = () => wrapper.findByText('Cancel');
const findDatePicker = () => wrapper.findComponent(GlDatepicker);
+ const findDatePickerInput = () => wrapper.findByTestId('input-datepicker');
const findHourInput = () => wrapper.findByTestId('input-hours');
const findMinuteInput = () => wrapper.findByTestId('input-minutes');
+ const setDatetime = () => {
+ findDatePicker().vm.$emit('input', new Date('2021-08-12'));
+ findHourInput().vm.$emit('input', 5);
+ findMinuteInput().vm.$emit('input', 45);
+ };
const submitForm = async () => {
findSubmitButton().trigger('click');
@@ -85,6 +94,22 @@ describe('Timeline events form', () => {
await cancelForm();
expect(wrapper.emitted()).toEqual(closeFormEvent);
});
+
+ it('should clear the form', async () => {
+ setDatetime();
+ await nextTick();
+
+ expect(findDatePickerInput().element.value).toBe('2021-08-12');
+ expect(findHourInput().element.value).toBe('5');
+ expect(findMinuteInput().element.value).toBe('45');
+
+ wrapper.vm.clear();
+ await nextTick();
+
+ expect(findDatePickerInput().element.value).toBe('2020-07-08');
+ expect(findHourInput().element.value).toBe('0');
+ expect(findMinuteInput().element.value).toBe('0');
+ });
});
describe('addTimelineEventQuery', () => {
@@ -92,7 +117,7 @@ describe('Timeline events form', () => {
input: {
incidentId: 'gid://gitlab/Issue/1',
note: '',
- occurredAt: '2020-07-06T00:00:00.000Z',
+ occurredAt: '2020-07-08T00:00:00.000Z',
},
};
@@ -117,9 +142,7 @@ describe('Timeline events form', () => {
},
};
- findDatePicker().vm.$emit('input', new Date('2021-08-12'));
- findHourInput().vm.$emit('input', 5);
- findMinuteInput().vm.$emit('input', 45);
+ setDatetime();
await nextTick();
await submitForm();
diff --git a/spec/frontend/issues/show/components/incidents/timeline_events_tab_spec.js b/spec/frontend/issues/show/components/incidents/timeline_events_tab_spec.js
index 7efa6ad8829..2d87851a761 100644
--- a/spec/frontend/issues/show/components/incidents/timeline_events_tab_spec.js
+++ b/spec/frontend/issues/show/components/incidents/timeline_events_tab_spec.js
@@ -152,6 +152,15 @@ describe('TimelineEventsTab', () => {
expect(findTimelineEventForm().isVisible()).toBe(true);
});
+ it('should clear the form when button is clicked', async () => {
+ const mockClear = jest.fn();
+ wrapper.vm.$refs.eventForm.clear = mockClear;
+
+ await findAddEventButton().trigger('click');
+
+ expect(mockClear).toHaveBeenCalled();
+ });
+
it('should hide the form when the hide event is emitted', async () => {
// open the form
await findAddEventButton().trigger('click');
diff --git a/spec/lib/gitlab/grape_logging/loggers/response_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/response_logger_spec.rb
new file mode 100644
index 00000000000..94e880d979d
--- /dev/null
+++ b/spec/lib/gitlab/grape_logging/loggers/response_logger_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::GrapeLogging::Loggers::ResponseLogger do
+ let(:logger) { described_class.new }
+
+ describe '#parameters' do
+ let(:response1) { 'response1' }
+ let(:response) { [response1] }
+
+ subject { logger.parameters(nil, response) }
+
+ it { expect(subject).to eq({ response_bytes: response1.bytesize }) }
+
+ context 'with multiple response parts' do
+ let(:response2) { 'response2' }
+ let(:response) { [response1, response2] }
+
+ it { expect(subject).to eq({ response_bytes: response1.bytesize + response2.bytesize }) }
+ end
+
+ context 'with log_response_length disabled' do
+ before do
+ stub_feature_flags(log_response_length: false)
+ end
+
+ it { expect(subject).to eq({}) }
+ end
+ end
+end
diff --git a/spec/lib/gitlab/lograge/custom_options_spec.rb b/spec/lib/gitlab/lograge/custom_options_spec.rb
index 58b05be6ff9..090b79c5d3c 100644
--- a/spec/lib/gitlab/lograge/custom_options_spec.rb
+++ b/spec/lib/gitlab/lograge/custom_options_spec.rb
@@ -25,7 +25,8 @@ RSpec.describe Gitlab::Lograge::CustomOptions do
remote_ip: '192.168.1.2',
ua: 'Nyxt',
queue_duration_s: 0.2,
- etag_route: '/etag'
+ etag_route: '/etag',
+ response_bytes: 1234
}
end
@@ -55,6 +56,20 @@ RSpec.describe Gitlab::Lograge::CustomOptions do
expect(subject[:user_id]).to eq('test')
end
+ it 'adds the response length' do
+ expect(subject[:response_bytes]).to eq(1234)
+ end
+
+ context 'with log_response_length disabled' do
+ before do
+ stub_feature_flags(log_response_length: false)
+ end
+
+ it 'does not add the response length' do
+ expect(subject).not_to include(:response_bytes)
+ end
+ end
+
it 'adds Cloudflare headers' do
expect(subject[:cf_ray]).to eq(event.payload[:cf_ray])
expect(subject[:cf_request_id]).to eq(event.payload[:cf_request_id])
diff --git a/spec/lib/gitlab/pages/deployment_update_spec.rb b/spec/lib/gitlab/pages/deployment_update_spec.rb
new file mode 100644
index 00000000000..cf109248f36
--- /dev/null
+++ b/spec/lib/gitlab/pages/deployment_update_spec.rb
@@ -0,0 +1,140 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Pages::DeploymentUpdate do
+ let_it_be(:project, refind: true) { create(:project, :repository) }
+
+ let_it_be(:old_pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
+
+ let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
+ let(:invalid_file) { fixture_file_upload('spec/fixtures/dk.png') }
+
+ let(:file) { fixture_file_upload("spec/fixtures/pages.zip") }
+ let(:empty_file) { fixture_file_upload("spec/fixtures/pages_empty.zip") }
+ let(:empty_metadata_filename) { "spec/fixtures/pages_empty.zip.meta" }
+ let(:metadata_filename) { "spec/fixtures/pages.zip.meta" }
+ let(:metadata) { fixture_file_upload(metadata_filename) if File.exist?(metadata_filename) }
+
+ subject(:pages_deployment_update) { described_class.new(project, build) }
+
+ context 'for new artifacts' do
+ context 'for a valid job' do
+ let!(:artifacts_archive) { create(:ci_job_artifact, :correct_checksum, file: file, job: build) }
+
+ before do
+ create(:ci_job_artifact, file_type: :metadata, file_format: :gzip, file: metadata, job: build)
+
+ build.reload
+ end
+
+ it 'is valid' do
+ expect(pages_deployment_update).to be_valid
+ end
+
+ context 'when missing artifacts metadata' do
+ before do
+ expect(build).to receive(:artifacts_metadata?).and_return(false)
+ end
+
+ it 'is invalid' do
+ expect(pages_deployment_update).not_to be_valid
+ expect(pages_deployment_update.errors.full_messages).to include('missing artifacts metadata')
+ end
+ end
+ end
+
+ it 'is invalid for invalid archive' do
+ create(:ci_job_artifact, :archive, file: invalid_file, job: build)
+
+ expect(pages_deployment_update).not_to be_valid
+ expect(pages_deployment_update.errors.full_messages).to include('missing artifacts metadata')
+ end
+ end
+
+ describe 'maximum pages artifacts size' do
+ let(:metadata) { spy('metadata') } # rubocop: disable RSpec/VerifiedDoubles
+
+ before do
+ file = fixture_file_upload('spec/fixtures/pages.zip')
+ metafile = fixture_file_upload('spec/fixtures/pages.zip.meta')
+
+ create(:ci_job_artifact, :archive, :correct_checksum, file: file, job: build)
+ create(:ci_job_artifact, :metadata, file: metafile, job: build)
+
+ allow(build).to receive(:artifacts_metadata_entry)
+ .and_return(metadata)
+ end
+
+ context 'when maximum pages size is set to zero' do
+ before do
+ stub_application_setting(max_pages_size: 0)
+ end
+
+ context "when size is above the limit" do
+ before do
+ allow(metadata).to receive(:total_size).and_return(1.megabyte)
+ allow(metadata).to receive(:entries).and_return([])
+ end
+
+ it 'is valid' do
+ expect(pages_deployment_update).to be_valid
+ end
+ end
+ end
+
+ context 'when size is limited on the instance level' do
+ before do
+ stub_application_setting(max_pages_size: 100)
+ end
+
+ context "when size is below the limit" do
+ before do
+ allow(metadata).to receive(:total_size).and_return(1.megabyte)
+ allow(metadata).to receive(:entries).and_return([])
+ end
+
+ it 'is valid' do
+ expect(pages_deployment_update).to be_valid
+ end
+ end
+
+ context "when size is above the limit" do
+ before do
+ allow(metadata).to receive(:total_size).and_return(101.megabyte)
+ allow(metadata).to receive(:entries).and_return([])
+ end
+
+ it 'is invalid' do
+ expect(pages_deployment_update).not_to be_valid
+ expect(pages_deployment_update.errors.full_messages)
+ .to include('artifacts for pages are too large: 105906176')
+ end
+ end
+ end
+ end
+
+ context 'when retrying the job' do
+ let!(:older_deploy_job) do
+ create(
+ :generic_commit_status,
+ :failed,
+ pipeline: pipeline,
+ ref: build.ref,
+ stage: 'deploy',
+ name: 'pages:deploy'
+ )
+ end
+
+ before do
+ create(:ci_job_artifact, :correct_checksum, file: file, job: build)
+ create(:ci_job_artifact, file_type: :metadata, file_format: :gzip, file: metadata, job: build)
+ build.reload
+ end
+
+ it 'marks older pages:deploy jobs retried' do
+ expect(pages_deployment_update).to be_valid
+ 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 7d31979a393..117b37ffda3 100644
--- a/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb
@@ -169,6 +169,16 @@ RSpec.describe Gitlab::SidekiqMiddleware::ServerMetrics do
subject.call(worker, job, :test) { nil }
end
end
+
+ context 'when job is interrupted' do
+ let(:job) { { 'interrupted_count' => 1 } }
+
+ it 'sets sidekiq_jobs_interrupted_total metric' do
+ expect(interrupted_total_metric).to receive(:increment)
+
+ subject.call(worker, job, :test) { nil }
+ end
+ end
end
end
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 4064f24cff0..e3207636bdc 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -34,6 +34,14 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
it { is_expected.to validate_length_of(:external_url).is_at_most(255) }
+ describe 'validation' do
+ it 'does not become invalid record when external_url is empty' do
+ environment = build(:environment, external_url: nil)
+
+ expect(environment).to be_valid
+ end
+ end
+
describe '.before_save' do
it 'ensures environment tier when a new object is created' do
environment = build(:environment, name: 'gprd', tier: nil)
diff --git a/spec/models/work_items/widgets/hierarchy_spec.rb b/spec/models/work_items/widgets/hierarchy_spec.rb
index 6d05953ecff..ab2bcfee13f 100644
--- a/spec/models/work_items/widgets/hierarchy_spec.rb
+++ b/spec/models/work_items/widgets/hierarchy_spec.rb
@@ -3,7 +3,10 @@
require 'spec_helper'
RSpec.describe WorkItems::Widgets::Hierarchy do
- let_it_be(:work_item) { create(:work_item) }
+ let_it_be(:group) { create(:group) }
+ let_it_be(:project) { create(:project, group: group) }
+ let_it_be(:task) { create(:work_item, :task, project: project) }
+ let_it_be(:work_item_parent) { create(:work_item, project: project) }
describe '.type' do
subject { described_class.type }
@@ -12,17 +15,17 @@ RSpec.describe WorkItems::Widgets::Hierarchy do
end
describe '#type' do
- subject { described_class.new(work_item).type }
+ subject { described_class.new(task).type }
it { is_expected.to eq(:hierarchy) }
end
describe '#parent' do
- let_it_be(:parent_link) { create(:parent_link) }
+ let_it_be(:parent_link) { create(:parent_link, work_item: task, work_item_parent: work_item_parent) }
subject { described_class.new(parent_link.work_item).parent }
- it { is_expected.to eq parent_link.work_item_parent }
+ it { is_expected.to eq(parent_link.work_item_parent) }
context 'when work_items flag is disabled' do
before do
@@ -31,15 +34,23 @@ RSpec.describe WorkItems::Widgets::Hierarchy do
it { is_expected.to be_nil }
end
+
+ context 'when work_items flag is enabled for the parent group' do
+ before do
+ stub_feature_flags(work_items: group)
+ end
+
+ it { is_expected.to eq(parent_link.work_item_parent) }
+ end
end
describe '#children' do
- let_it_be(:parent_link1) { create(:parent_link, work_item_parent: work_item) }
- let_it_be(:parent_link2) { create(:parent_link, work_item_parent: work_item) }
+ let_it_be(:parent_link1) { create(:parent_link, work_item_parent: work_item_parent, work_item: task) }
+ let_it_be(:parent_link2) { create(:parent_link, work_item_parent: work_item_parent) }
- subject { described_class.new(work_item).children }
+ subject { described_class.new(work_item_parent).children }
- it { is_expected.to match_array([parent_link1.work_item, parent_link2.work_item]) }
+ it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) }
context 'when work_items flag is disabled' do
before do
@@ -48,5 +59,13 @@ RSpec.describe WorkItems::Widgets::Hierarchy do
it { is_expected.to be_empty }
end
+
+ context 'when work_items flag is enabled for the parent group' do
+ before do
+ stub_feature_flags(work_items: group)
+ end
+
+ it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) }
+ end
end
end
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index 06e39ccc8c7..24b5e35e422 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -171,16 +171,6 @@ RSpec.describe Projects::UpdatePagesService do
end
end
- shared_examples 'fails with outdated reference message' do
- it 'fails' do
- expect(execute).not_to eq(:success)
- expect(project.reload.pages_metadatum).not_to be_deployed
-
- expect(deploy_status).to be_failed
- expect(deploy_status.description).to eq('build SHA is outdated for this ref')
- end
- end
-
shared_examples 'successfully deploys' do
it 'succeeds' do
expect do
@@ -212,27 +202,29 @@ RSpec.describe Projects::UpdatePagesService do
project.update_pages_deployment!(new_deployment)
end
- include_examples 'fails with outdated reference message'
+ it 'fails with outdated reference message' do
+ expect(execute).to eq(:error)
+ expect(project.reload.pages_metadatum).not_to be_deployed
+
+ expect(deploy_status).to be_failed
+ expect(deploy_status.description).to eq('build SHA is outdated for this ref')
+ end
end
end
- context 'when uploaded deployment size is wrong' do
- it 'raises an error' do
- allow_next_instance_of(PagesDeployment) do |deployment|
- allow(deployment)
- .to receive(:size)
- .and_return(file.size + 1)
- end
+ it 'fails when uploaded deployment size is wrong' do
+ allow_next_instance_of(PagesDeployment) do |deployment|
+ allow(deployment)
+ .to receive(:size)
+ .and_return(file.size + 1)
+ end
- expect do
- expect(execute).not_to eq(:success)
+ expect(execute).not_to eq(:success)
- expect(GenericCommitStatus.last.description).to eq("Error: The uploaded artifact size does not match the expected value.")
- project.pages_metadatum.reload
- expect(project.pages_metadatum).not_to be_deployed
- expect(project.pages_metadatum.pages_deployment).to be_ni
- end.to raise_error(Projects::UpdatePagesService::WrongUploadedDeploymentSizeError)
- end
+ expect(GenericCommitStatus.last.description).to eq('The uploaded artifact size does not match the expected value')
+ project.pages_metadatum.reload
+ expect(project.pages_metadatum).not_to be_deployed
+ expect(project.pages_metadatum.pages_deployment).to be_nil
end
end
end
diff --git a/spec/support/shared_contexts/lib/gitlab/sidekiq_middleware/server_metrics_shared_context.rb b/spec/support/shared_contexts/lib/gitlab/sidekiq_middleware/server_metrics_shared_context.rb
index 0d992f33c61..449db59e35d 100644
--- a/spec/support/shared_contexts/lib/gitlab/sidekiq_middleware/server_metrics_shared_context.rb
+++ b/spec/support/shared_contexts/lib/gitlab/sidekiq_middleware/server_metrics_shared_context.rb
@@ -10,6 +10,7 @@ RSpec.shared_context 'server metrics with mocked prometheus' do
let(:gitaly_seconds_metric) { double('gitaly seconds metric') }
let(:failed_total_metric) { double('failed total metric') }
let(:retried_total_metric) { double('retried total metric') }
+ let(:interrupted_total_metric) { double('interrupted total metric') }
let(:redis_requests_total) { double('redis calls total metric') }
let(:running_jobs_metric) { double('running jobs metric') }
let(:redis_seconds_metric) { double('redis seconds metric') }
@@ -30,6 +31,7 @@ RSpec.shared_context 'server metrics with mocked prometheus' do
allow(Gitlab::Metrics).to receive(:histogram).with(:sidekiq_elasticsearch_requests_duration_seconds, anything, anything, anything).and_return(elasticsearch_seconds_metric)
allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_jobs_failed_total, anything).and_return(failed_total_metric)
allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_jobs_retried_total, anything).and_return(retried_total_metric)
+ allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_jobs_interrupted_total, anything).and_return(interrupted_total_metric)
allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_redis_requests_total, anything).and_return(redis_requests_total)
allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_elasticsearch_requests_total, anything).and_return(elasticsearch_requests_total)
allow(Gitlab::Metrics).to receive(:counter).with(:sidekiq_load_balancing_count, anything).and_return(load_balancing_metric)
diff --git a/vendor/gems/error_tracking_open_api/Gemfile b/vendor/gems/error_tracking_open_api/Gemfile
deleted file mode 100644
index c2e3127cdcf..00000000000
--- a/vendor/gems/error_tracking_open_api/Gemfile
+++ /dev/null
@@ -1,9 +0,0 @@
-source 'https://rubygems.org'
-
-gemspec
-
-group :development, :test do
- gem 'rake', '~> 13.0.1'
- gem 'pry-byebug'
- gem 'rubocop', '~> 0.66.0'
-end
diff --git a/vendor/gems/error_tracking_open_api/README.md b/vendor/gems/error_tracking_open_api/README.md
index 1bd234c8ddb..18757e2e183 100644
--- a/vendor/gems/error_tracking_open_api/README.md
+++ b/vendor/gems/error_tracking_open_api/README.md
@@ -1,4 +1,4 @@
-# Generated by `rake gems:error_tracking_open_api:generate` on 2022-07-02
+# Generated by `rake gems:error_tracking_open_api:generate` on 2022-07-14
See https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/development/rake_tasks.md#update-openapi-client-for-error-tracking-feature