Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-08-02 18:12:15 +00:00
parent 9c33625b8e
commit e28bb9d181
34 changed files with 194 additions and 69 deletions

View File

@ -84,7 +84,7 @@ variables:
GIT_SUBMODULE_STRATEGY: "none" GIT_SUBMODULE_STRATEGY: "none"
GET_SOURCES_ATTEMPTS: "3" GET_SOURCES_ATTEMPTS: "3"
DEBIAN_VERSION: "bullseye" DEBIAN_VERSION: "bullseye"
CHROME_VERSION: "101" CHROME_VERSION: "103"
DOCKER_VERSION: "20.10.14" DOCKER_VERSION: "20.10.14"
RUBY_VERSION: "2.7" RUBY_VERSION: "2.7"

View File

@ -1,5 +1,5 @@
.qa-job-base: .qa-job-base:
image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-bullseye-ruby-2.7:bundler-2.3-git-2.33-chrome-${CHROME_VERSION} image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-bullseye-ruby-2.7:bundler-2.3-chrome-103-docker-20.10.14
extends: extends:
- .default-retry - .default-retry
- .qa-cache - .qa-cache

View File

@ -37,13 +37,20 @@ Add details for required items and delete others.
## Implementation plan ## Implementation plan
<!-- <!--
Steps and the parts of the code that will need to get updated. The plan can also Steps and the parts of the code that will need to get updated.
call-out responsibilities for other team members or teams. The plan can also call-out responsibilities for other team members or teams and
can be split into smaller MRs to simplify the code review process.
e.g.: e.g.:
- MR 1: Part 1
- [ ] ~frontend Step 1
- [ ] ~frontend Step 2
- MR 2: Part 2
- [ ] ~backend Step 1
- [ ] ~backend Step 2
- MR 3: Part 3
- [ ] ~frontend Step 1 - [ ] ~frontend Step 1
- [ ] `@person` Step 1a
- [ ] ~frontend Step 2 - [ ] ~frontend Step 2
--> -->

View File

@ -168,7 +168,7 @@ gem 'asciidoctor', '~> 2.0.10'
gem 'asciidoctor-include-ext', '~> 0.4.0', require: false gem 'asciidoctor-include-ext', '~> 0.4.0', require: false
gem 'asciidoctor-plantuml', '~> 0.0.12' gem 'asciidoctor-plantuml', '~> 0.0.12'
gem 'asciidoctor-kroki', '~> 0.5.0', require: false gem 'asciidoctor-kroki', '~> 0.5.0', require: false
gem 'rouge', '~> 3.29.0' gem 'rouge', '~> 3.30.0'
gem 'truncato', '~> 0.7.11' gem 'truncato', '~> 0.7.11'
gem 'bootstrap_form', '~> 4.2.0' gem 'bootstrap_form', '~> 4.2.0'
gem 'nokogiri', '~> 1.13.6' gem 'nokogiri', '~> 1.13.6'

View File

@ -1126,7 +1126,7 @@ GEM
rexml (3.2.5) rexml (3.2.5)
rinku (2.0.0) rinku (2.0.0)
rotp (6.2.0) rotp (6.2.0)
rouge (3.29.0) rouge (3.30.0)
rqrcode (0.7.0) rqrcode (0.7.0)
chunky_png chunky_png
rqrcode-rails3 (0.1.7) rqrcode-rails3 (0.1.7)
@ -1699,7 +1699,7 @@ DEPENDENCIES
responders (~> 3.0) responders (~> 3.0)
retriable (~> 3.1.2) retriable (~> 3.1.2)
rexml (~> 3.2.5) rexml (~> 3.2.5)
rouge (~> 3.29.0) rouge (~> 3.30.0)
rqrcode-rails3 (~> 0.1.7) rqrcode-rails3 (~> 0.1.7)
rspec-benchmark (~> 0.6.0) rspec-benchmark (~> 0.6.0)
rspec-parameterized rspec-parameterized

View File

@ -59,7 +59,11 @@ export default {
<tooltip-on-truncate class="gl-display-block gl-text-truncate" :title="description"> <tooltip-on-truncate class="gl-display-block gl-text-truncate" :title="description">
{{ description }} {{ description }}
</tooltip-on-truncate> </tooltip-on-truncate>
<tooltip-on-truncate class="gl-display-block gl-text-truncate" :title="ipAddress"> <tooltip-on-truncate
v-if="ipAddress"
class="gl-display-block gl-text-truncate"
:title="ipAddress"
>
<span class="gl-md-display-none gl-lg-display-inline">{{ __('IP Address') }}</span> <span class="gl-md-display-none gl-lg-display-inline">{{ __('IP Address') }}</span>
<strong>{{ ipAddress }}</strong> <strong>{{ ipAddress }}</strong>
</tooltip-on-truncate> </tooltip-on-truncate>

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Projects
class ProjectArchivedEvent < ::Gitlab::EventStore::Event
def schema
{
'type' => 'object',
'properties' => {
'project_id' => { 'type' => 'integer' },
'namespace_id' => { 'type' => 'integer' },
'root_namespace_id' => { 'type' => 'integer' }
},
'required' => %w[project_id namespace_id root_namespace_id]
}
end
end
end

View File

@ -15,7 +15,7 @@ class LfsObject < ApplicationRecord
scope :for_oids, -> (oids) { where(oid: oids) } scope :for_oids, -> (oids) { where(oid: oids) }
scope :for_oid_and_size, -> (oid, size) { find_by(oid: oid, size: size) } scope :for_oid_and_size, -> (oid, size) { find_by(oid: oid, size: size) }
validates :oid, presence: true, uniqueness: true validates :oid, presence: true, uniqueness: true, format: { with: /\A\h{64}\z/ }
mount_file_store_uploader LfsObjectUploader mount_file_store_uploader LfsObjectUploader

View File

@ -121,6 +121,8 @@ module Projects
end end
update_pending_builds if runners_settings_toggled? update_pending_builds if runners_settings_toggled?
publish_event
end end
def after_rename_service(project) def after_rename_service(project)
@ -209,6 +211,18 @@ module Projects
[] []
end end
end end
def publish_event
return unless project.archived_previously_changed?
event = Projects::ProjectArchivedEvent.new(data: {
project_id: @project.id,
namespace_id: @project.namespace_id,
root_namespace_id: @project.root_namespace.id
})
Gitlab::EventStore.publish(event)
end
end end
end end

View File

@ -1,7 +1,7 @@
--- ---
name: archive_rate_limit name: archive_rate_limit
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25750 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25750
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369432
milestone: '12.9' milestone: '12.9'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: async_commit_diff_files name: async_commit_diff_files
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38450 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38450
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369439
milestone: '13.3' milestone: '13.3'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: branch_list_keyset_pagination name: branch_list_keyset_pagination
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35819 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35819
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369435
milestone: '13.2' milestone: '13.2'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: increase_page_size_exponentially name: increase_page_size_exponentially
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66174 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66174
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369434
milestone: '14.1' milestone: '14.1'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: json_wrapper_legacy_mode name: json_wrapper_legacy_mode
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30849 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30849
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369436
milestone: '13.0' milestone: '13.0'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: repository_archive_hotlinking_interception name: repository_archive_hotlinking_interception
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369433
milestone: '12.10' milestone: '12.10'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: unlink_fork_network_upon_visibility_decrease name: unlink_fork_network_upon_visibility_decrease
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/20466 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/20466
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369438
milestone: '12.6' milestone: '12.6'
type: development type: development
group: group::source code group: group::source code

View File

@ -1,7 +1,7 @@
--- ---
name: workhorse_archive_cache_disabled name: workhorse_archive_cache_disabled
introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/16325 introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/16325
rollout_issue_url: rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/369437
milestone: '10.5' milestone: '10.5'
type: development type: development
group: group::source code group: group::source code

View File

@ -9,7 +9,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
Service Ping consists of two kinds of data: Service Ping consists of two kinds of data:
- **Counters**: Track how often a certain event happened over time, such as how many CI/CD pipelines have run. - **Counters**: Track how often a certain event happened over time, such as how many CI/CD pipelines have run.
They are monotonic and always trend up. They are monotonic and usually trend up.
- **Observations**: Facts collected from one or more GitLab instances and can carry arbitrary data. - **Observations**: Facts collected from one or more GitLab instances and can carry arbitrary data.
There are no general guidelines for how to collect those, due to the individual nature of that data. There are no general guidelines for how to collect those, due to the individual nature of that data.

View File

@ -32,6 +32,7 @@ for the most popular hosting services:
<!-- vale gitlab.Spelling = NO --> <!-- vale gitlab.Spelling = NO -->
- [123-reg](https://www.123-reg.co.uk/support/domains/domain-name-server-dns-management-guide/)
- [Amazon](https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html) - [Amazon](https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html)
- [Bluehost](https://www.bluehost.com/help/article/dns-management-add-edit-or-delete-dns-entries) - [Bluehost](https://www.bluehost.com/help/article/dns-management-add-edit-or-delete-dns-entries)
- [Cloudflare](https://support.cloudflare.com/hc/en-us/articles/201720164-Creating-a-Cloudflare-account-and-adding-a-website) - [Cloudflare](https://support.cloudflare.com/hc/en-us/articles/201720164-Creating-a-Cloudflare-account-and-adding-a-website)

View File

@ -29,16 +29,20 @@ module Gitlab
# @param [String] path Directory path the dump will be put into # @param [String] path Directory path the dump will be put into
# @param [String] format `json` or `txt` # @param [String] format `json` or `txt`
# @param [String] filename_label Optional custom string that will be injected into the file name, e.g. `worker_0` # @param [String] filename_label Optional custom string that will be injected into the file name, e.g. `worker_0`
# @return [void] # @return [String] Full path to the resulting dump file
def dump_stats(path:, format: STATS_DEFAULT_FORMAT, filename_label: nil) def dump_stats(path:, format: STATS_DEFAULT_FORMAT, filename_label: nil)
verify_format!(format) verify_format!(format)
with_malloc_stats_print do |stats_print|
format_settings = STATS_FORMATS[format] format_settings = STATS_FORMATS[format]
File.open(File.join(path, file_name(format_settings[:extension], filename_label)), 'wb') do |io| file_path = File.join(path, file_name(format_settings[:extension], filename_label))
with_malloc_stats_print do |stats_print|
File.open(file_path, 'wb') do |io|
write_stats(stats_print, io, format_settings) write_stats(stats_print, io, format_settings)
end end
end end
file_path
end end
private private

View File

@ -23,8 +23,7 @@ module Gitlab
def run def run
return unless active? return unless active?
Gitlab::Memory::Jemalloc.dump_stats(path: reports_path, filename_label: worker_id) Gitlab::Memory::Jemalloc.dump_stats(path: reports_path, filename_label: worker_id).tap { cleanup }
cleanup
end end
def active? def active?

View File

@ -39,12 +39,12 @@ module Gitlab
start_monotonic_time = Gitlab::Metrics::System.monotonic_time start_monotonic_time = Gitlab::Metrics::System.monotonic_time
start_thread_cpu_time = Gitlab::Metrics::System.thread_cpu_time start_thread_cpu_time = Gitlab::Metrics::System.thread_cpu_time
report.run file_path = report.run
cpu_s = Gitlab::Metrics::System.thread_cpu_duration(start_thread_cpu_time) cpu_s = Gitlab::Metrics::System.thread_cpu_duration(start_thread_cpu_time)
duration_s = Gitlab::Metrics::System.monotonic_time - start_monotonic_time duration_s = Gitlab::Metrics::System.monotonic_time - start_monotonic_time
log_report(label: report_label(report), cpu_s: cpu_s, duration_s: duration_s) log_report(label: report_label(report), cpu_s: cpu_s, duration_s: duration_s, size: file_size(file_path))
@report_duration_counter.increment({ report: report_label(report) }, duration_s) @report_duration_counter.increment({ report: report_label(report) }, duration_s)
sleep sleep_between_reports_s sleep sleep_between_reports_s
@ -62,14 +62,15 @@ module Gitlab
sleep_s + rand(sleep_max_delta_s) sleep_s + rand(sleep_max_delta_s)
end end
def log_report(label:, duration_s:, cpu_s:) def log_report(label:, duration_s:, cpu_s:, size:)
Gitlab::AppLogger.info( Gitlab::AppLogger.info(
message: 'finished', message: 'finished',
pid: $$, pid: $$,
worker_id: worker_id, worker_id: worker_id,
perf_report: label, perf_report: label,
duration_s: duration_s.round(2), duration_s: duration_s.round(2),
cpu_s: cpu_s.round(2) cpu_s: cpu_s.round(2),
perf_report_size_bytes: size
) )
end end
@ -94,6 +95,12 @@ module Gitlab
default_labels default_labels
) )
end end
def file_size(file_path)
File.size(file_path.to_s)
rescue Errno::ENOENT
0
end
end end
end end
end end

View File

@ -100,7 +100,7 @@
"codesandbox-api": "0.0.23", "codesandbox-api": "0.0.23",
"compression-webpack-plugin": "^5.0.2", "compression-webpack-plugin": "^5.0.2",
"copy-webpack-plugin": "^6.4.1", "copy-webpack-plugin": "^6.4.1",
"core-js": "^3.24.0", "core-js": "^3.24.1",
"cron-validator": "^1.1.1", "cron-validator": "^1.1.1",
"cronstrue": "^1.122.0", "cronstrue": "^1.122.0",
"cropper": "^2.3.0", "cropper": "^2.3.0",

View File

@ -1,5 +1,5 @@
ARG DOCKER_VERSION=20.10.14 ARG DOCKER_VERSION=20.10.14
ARG CHROME_VERSION=101 ARG CHROME_VERSION=103
ARG QA_BUILD_TARGET=qa ARG QA_BUILD_TARGET=qa
FROM registry.gitlab.com/gitlab-org/gitlab-build-images/debian-bullseye-ruby-2.7:bundler-2.3-git-2.33-lfs-2.9-chrome-${CHROME_VERSION}-docker-${DOCKER_VERSION}-gcloud-383-kubectl-1.23 AS qa FROM registry.gitlab.com/gitlab-org/gitlab-build-images/debian-bullseye-ruby-2.7:bundler-2.3-git-2.33-lfs-2.9-chrome-${CHROME_VERSION}-docker-${DOCKER_VERSION}-gcloud-383-kubectl-1.23 AS qa

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::ProjectArchivedEvent do
subject(:constructor) { described_class.new(data: data) }
where(:data, :valid) do
valid_event = {
project_id: 1,
namespace_id: 2,
root_namespace_id: 3
}
# All combinations of missing keys
with_missing_keys = 0.upto(valid_event.size - 1)
.flat_map { |size| valid_event.keys.combination(size).to_a }
.map { |keys| [valid_event.slice(*keys), false] }
[
[valid_event, true],
*with_missing_keys,
[{ project_id: 'foo', namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: 'foo' }, false],
[{ project_id: [], namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: [] }, false],
[{ project_id: {}, namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: {} }, false],
['foo', false],
[123, false],
[[], false]
]
end
with_them do
it 'validates data' do
if valid
expect { constructor }.not_to raise_error
else
expect { constructor }.to raise_error(Gitlab::EventStore::InvalidEvent)
end
end
end
end

View File

@ -1,3 +1,4 @@
import { __ } from '~/locale';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import RunnerSummaryCell from '~/runner/components/cells/runner_summary_cell.vue'; import RunnerSummaryCell from '~/runner/components/cells/runner_summary_cell.vue';
import { INSTANCE_TYPE, PROJECT_TYPE } from '~/runner/constants'; import { INSTANCE_TYPE, PROJECT_TYPE } from '~/runner/constants';
@ -61,8 +62,16 @@ describe('RunnerTypeCell', () => {
expect(wrapper.text()).toContain(mockDescription); expect(wrapper.text()).toContain(mockDescription);
}); });
it('Displays the runner ip address', () => { it('Displays ip address', () => {
expect(wrapper.text()).toContain(mockIpAddress); expect(wrapper.text()).toContain(`${__('IP Address')} ${mockIpAddress}`);
});
it('Displays no ip address', () => {
createComponent({
ipAddress: null,
});
expect(wrapper.text()).not.toContain(__('IP Address'));
}); });
it('Displays a custom slot', () => { it('Displays a custom slot', () => {

View File

@ -10,7 +10,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
let(:lfs_attributes) do let(:lfs_attributes) do
{ {
oid: 'oid', oid: 'a' * 64,
size: 1, size: 1,
link: 'http://www.gitlab.com/lfs_objects/oid' link: 'http://www.gitlab.com/lfs_objects/oid'
} }

View File

@ -28,11 +28,12 @@ RSpec.describe Gitlab::Memory::Jemalloc do
describe '.dump_stats' do describe '.dump_stats' do
it 'writes stats JSON file' do it 'writes stats JSON file' do
described_class.dump_stats(path: outdir, format: format) file_path = described_class.dump_stats(path: outdir, format: format)
file = Dir.entries(outdir).find { |e| e.match(/jemalloc_stats\.#{$$}\.\d+\.json$/) } file = Dir.entries(outdir).find { |e| e.match(/jemalloc_stats\.#{$$}\.\d+\.json$/) }
expect(file).not_to be_nil expect(file).not_to be_nil
expect(File.read(File.join(outdir, file))).to eq(output) expect(file_path).to eq(File.join(outdir, file))
expect(File.read(file_path)).to eq(output)
end end
end end
end end

View File

@ -3,34 +3,24 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::Memory::Reports::JemallocStats do RSpec.describe Gitlab::Memory::Reports::JemallocStats do
let(:jemalloc_stats) { described_class.new(reports_path: '/empty-dir') } let(:reports_dir) {'/empty-dir'}
let(:jemalloc_stats) { described_class.new(reports_path: reports_dir) }
describe '.run' do describe '.run' do
context 'when :report_jemalloc_stats ops FF is enabled' do context 'when :report_jemalloc_stats ops FF is enabled' do
let(:worker_id) {'puma_1'} let(:worker_id) {'puma_1'}
let(:report_name) {'report.json'}
let(:report_path) { File.join(reports_dir, report_name) }
before do before do
allow(Prometheus::PidProvider).to receive(:worker_id).and_return(worker_id) allow(Prometheus::PidProvider).to receive(:worker_id).and_return(worker_id)
end end
context 'when GITLAB_DIAGNOSTIC_REPORTS_PATH env var is set' do it 'invokes Jemalloc.dump_stats and returns file path' do
let(:reports_dir) { '/empty-dir' } expect(Gitlab::Memory::Jemalloc)
.to receive(:dump_stats).with(path: reports_dir, filename_label: worker_id).and_return(report_path)
before do expect(jemalloc_stats.run).to eq(report_path)
stub_env('GITLAB_DIAGNOSTIC_REPORTS_PATH', reports_dir)
end
it 'writes reports into custom dir while enabled' do
expect(Gitlab::Memory::Jemalloc).to receive(:dump_stats).with(path: reports_dir, filename_label: worker_id)
jemalloc_stats.run
end
end
it 'writes reports into default dir while enabled' do
expect(Gitlab::Memory::Jemalloc).to receive(:dump_stats).with(path: '/empty-dir', filename_label: worker_id)
jemalloc_stats.run
end end
describe 'reports cleanup' do describe 'reports cleanup' do
@ -108,10 +98,10 @@ RSpec.describe Gitlab::Memory::Reports::JemallocStats do
stub_feature_flags(report_jemalloc_stats: false) stub_feature_flags(report_jemalloc_stats: false)
end end
it 'does not run the report' do it 'does not run the report and returns nil' do
expect(Gitlab::Memory::Jemalloc).not_to receive(:dump_stats) expect(Gitlab::Memory::Jemalloc).not_to receive(:dump_stats)
jemalloc_stats.run expect(jemalloc_stats.run).to be_nil
end end
end end
end end

View File

@ -7,6 +7,7 @@ RSpec.describe Gitlab::Memory::ReportsDaemon do
describe '#run_thread' do describe '#run_thread' do
let(:report_duration_counter) { instance_double(::Prometheus::Client::Counter) } let(:report_duration_counter) { instance_double(::Prometheus::Client::Counter) }
let(:file_size) { 1_000_000 }
before do before do
allow(Gitlab::Metrics).to receive(:counter).and_return(report_duration_counter) allow(Gitlab::Metrics).to receive(:counter).and_return(report_duration_counter)
@ -17,10 +18,12 @@ RSpec.describe Gitlab::Memory::ReportsDaemon do
# let alive return 3 times: true, true, false # let alive return 3 times: true, true, false
allow(daemon).to receive(:alive).and_return(true, true, false) allow(daemon).to receive(:alive).and_return(true, true, false)
allow(File).to receive(:size).with(/#{daemon.reports_path}.*\.json/).and_return(file_size)
end end
it 'runs reports' do it 'runs reports' do
expect(daemon.send(:reports)).to all(receive(:run).twice) expect(daemon.send(:reports)).to all(receive(:run).twice.and_call_original)
daemon.send(:run_thread) daemon.send(:run_thread)
end end
@ -32,6 +35,7 @@ RSpec.describe Gitlab::Memory::ReportsDaemon do
hash_including( hash_including(
:duration_s, :duration_s,
:cpu_s, :cpu_s,
perf_report_size_bytes: file_size,
message: 'finished', message: 'finished',
pid: Process.pid, pid: Process.pid,
worker_id: 'worker_1', worker_id: 'worker_1',
@ -41,6 +45,18 @@ RSpec.describe Gitlab::Memory::ReportsDaemon do
daemon.send(:run_thread) daemon.send(:run_thread)
end end
context 'when the report object returns invalid file path' do
before do
allow(File).to receive(:size).with(/#{daemon.reports_path}.*\.json/).and_raise(Errno::ENOENT)
end
it 'logs `0` as `perf_report_size_bytes`' do
expect(Gitlab::AppLogger).to receive(:info).with(hash_including(perf_report_size_bytes: 0)).twice
daemon.send(:run_thread)
end
end
it 'sets real time duration gauge' do it 'sets real time duration gauge' do
expect(report_duration_counter).to receive(:increment).with({ report: 'jemalloc_stats' }, an_instance_of(Float)) expect(report_duration_counter).to receive(:increment).with({ report: 'jemalloc_stats' }, an_instance_of(Float))
@ -58,8 +74,8 @@ RSpec.describe Gitlab::Memory::ReportsDaemon do
allow(daemon).to receive(:reports).and_return([active_report_1, inactive_report, active_report_2]) allow(daemon).to receive(:reports).and_return([active_report_1, inactive_report, active_report_2])
expect(active_report_1).to receive(:run).twice expect(active_report_1).to receive(:run).and_return('/tmp/report_1.json').twice
expect(active_report_2).to receive(:run).twice expect(active_report_2).to receive(:run).and_return('/tmp/report_2.json').twice
expect(inactive_report).not_to receive(:run) expect(inactive_report).not_to receive(:run)
daemon.send(:run_thread) daemon.send(:run_thread)

View File

@ -193,9 +193,9 @@ RSpec.describe LfsObject do
end end
describe '.unreferenced_in_batches' do describe '.unreferenced_in_batches' do
let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') } let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1' * 64) }
let!(:referenced_lfs_object) { create(:lfs_objects_project).lfs_object } let!(:referenced_lfs_object) { create(:lfs_objects_project).lfs_object }
let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2') } let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2' * 64) }
it 'returns lfs objects in batches' do it 'returns lfs objects in batches' do
stub_const('LfsObject::BATCH_SIZE', 1) stub_const('LfsObject::BATCH_SIZE', 1)

View File

@ -348,6 +348,18 @@ RSpec.describe Projects::UpdateService do
end end
end end
context 'when archiving a project' do
it 'publishes a ProjectTransferedEvent' do
expect { update_project(project, user, archived: true) }
.to publish_event(Projects::ProjectArchivedEvent)
.with(
project_id: project.id,
namespace_id: project.namespace_id,
root_namespace_id: project.root_namespace.id
)
end
end
context 'when changing operations feature visibility' do context 'when changing operations feature visibility' do
let(:feature_params) { { operations_access_level: ProjectFeature::DISABLED } } let(:feature_params) { { operations_access_level: ProjectFeature::DISABLED } }

View File

@ -6,12 +6,12 @@ RSpec.describe RemoveUnreferencedLfsObjectsWorker do
let(:worker) { described_class.new } let(:worker) { described_class.new }
describe '#perform' do describe '#perform' do
let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') } let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1' * 64) }
let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2') } let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2' * 64) }
let!(:project1) { create(:project, lfs_enabled: true) } let!(:project1) { create(:project, lfs_enabled: true) }
let!(:project2) { create(:project, lfs_enabled: true) } let!(:project2) { create(:project, lfs_enabled: true) }
let!(:referenced_lfs_object1) { create(:lfs_object, oid: '3') } let!(:referenced_lfs_object1) { create(:lfs_object, oid: '3' * 64) }
let!(:referenced_lfs_object2) { create(:lfs_object, oid: '4') } let!(:referenced_lfs_object2) { create(:lfs_object, oid: '4' * 64) }
let!(:lfs_objects_project1_1) do let!(:lfs_objects_project1_1) do
create(:lfs_objects_project, create(:lfs_objects_project,
project: project1, project: project1,

View File

@ -3729,10 +3729,10 @@ core-js-pure@^3.0.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813" resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813"
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA== integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==
core-js@^3.24.0: core-js@^3.24.1:
version "3.24.0" version "3.24.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.24.0.tgz#4928d4e99c593a234eb1a1f9abd3122b04d3ac57" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.24.1.tgz#cf7724d41724154010a6576b7b57d94c5d66e64f"
integrity sha512-IeOyT8A6iK37Ep4kZDD423mpi6JfPRoPUdQwEWYiGolvn4o6j2diaRzNfDfpTdu3a5qMbrGUzKUpYpRY8jXCkQ== integrity sha512-0QTBSYSUZ6Gq21utGzkfITDylE8jWC9Ne1D2MrhvlsZBI1x39OdDIVbzSqtgMndIy6BlHxBXpMGqzZmnztg2rg==
core-js@~2.3.0: core-js@~2.3.0:
version "2.3.0" version "2.3.0"