Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
b49ebeb658
commit
8e6efd45b2
|
@ -1,10 +1,19 @@
|
|||
<script>
|
||||
import { GlButtonGroup, GlButton, GlDropdown, GlFormCheckbox } from '@gitlab/ui';
|
||||
import {
|
||||
GlButtonGroup,
|
||||
GlButton,
|
||||
GlDropdown,
|
||||
GlFormCheckbox,
|
||||
GlTooltipDirective,
|
||||
} from '@gitlab/ui';
|
||||
import { mapActions, mapGetters, mapState } from 'vuex';
|
||||
import { SETTINGS_DROPDOWN } from '../i18n';
|
||||
|
||||
export default {
|
||||
i18n: SETTINGS_DROPDOWN,
|
||||
directives: {
|
||||
GlTooltip: GlTooltipDirective,
|
||||
},
|
||||
components: {
|
||||
GlButtonGroup,
|
||||
GlButton,
|
||||
|
@ -35,9 +44,13 @@ export default {
|
|||
|
||||
<template>
|
||||
<gl-dropdown
|
||||
v-gl-tooltip
|
||||
icon="settings"
|
||||
:text="__('Diff view settings')"
|
||||
:title="$options.i18n.preferences"
|
||||
:text="$options.i18n.preferences"
|
||||
:text-sr-only="true"
|
||||
:aria-label="$options.i18n.preferences"
|
||||
:header-text="$options.i18n.preferences"
|
||||
toggle-class="js-show-diff-settings"
|
||||
right
|
||||
>
|
||||
|
|
|
@ -23,4 +23,5 @@ export const DIFF_FILE = {
|
|||
export const SETTINGS_DROPDOWN = {
|
||||
whitespace: __('Show whitespace changes'),
|
||||
fileByFile: __('Show one file at a time'),
|
||||
preferences: __('Preferences'),
|
||||
};
|
||||
|
|
|
@ -11459,9 +11459,6 @@ msgstr ""
|
|||
msgid "Diff limits"
|
||||
msgstr ""
|
||||
|
||||
msgid "Diff view settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Difference between start date and now"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ RSpec.describe 'lograge', type: :request do
|
|||
|
||||
context 'with a log subscriber' do
|
||||
include_context 'parsed logs'
|
||||
include_context 'clear DB Load Balancing configuration'
|
||||
|
||||
let(:subscriber) { Lograge::LogSubscribers::ActionController.new }
|
||||
|
||||
|
@ -195,9 +196,25 @@ RSpec.describe 'lograge', type: :request do
|
|||
end
|
||||
|
||||
context 'with db payload' do
|
||||
let(:db_load_balancing_logging_keys) do
|
||||
%w[
|
||||
db_primary_wal_count
|
||||
db_replica_wal_count
|
||||
db_replica_count
|
||||
db_replica_cached_count
|
||||
db_primary_count
|
||||
db_primary_cached_count
|
||||
db_primary_duration_s
|
||||
db_replica_duration_s
|
||||
]
|
||||
end
|
||||
|
||||
before do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
end
|
||||
|
||||
context 'when RequestStore is enabled', :request_store do
|
||||
it 'includes db counters' do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
subscriber.process_action(event)
|
||||
|
||||
expect(log_data).to include("db_count" => a_value >= 1, "db_write_count" => 0, "db_cached_count" => 0)
|
||||
|
@ -206,12 +223,47 @@ RSpec.describe 'lograge', type: :request do
|
|||
|
||||
context 'when RequestStore is disabled' do
|
||||
it 'does not include db counters' do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
subscriber.process_action(event)
|
||||
|
||||
expect(log_data).not_to include("db_count", "db_write_count", "db_cached_count")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when load balancing is enabled' do
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
|
||||
end
|
||||
|
||||
context 'with db payload' do
|
||||
context 'when RequestStore is enabled', :request_store do
|
||||
it 'includes db counters for load balancing' do
|
||||
subscriber.process_action(event)
|
||||
|
||||
expect(log_data).to include(*db_load_balancing_logging_keys)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when RequestStore is disabled' do
|
||||
it 'does not include db counters for load balancing' do
|
||||
subscriber.process_action(event)
|
||||
|
||||
expect(log_data).not_to include(*db_load_balancing_logging_keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when load balancing is disabled' do
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(false)
|
||||
end
|
||||
|
||||
it 'does not include db counters for load balancing' do
|
||||
subscriber.process_action(event)
|
||||
|
||||
expect(log_data).not_to include(*db_load_balancing_logging_keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -117,6 +117,42 @@ RSpec.describe Gitlab::InstrumentationHelper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when load balancing is enabled' do
|
||||
include_context 'clear DB Load Balancing configuration'
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
|
||||
end
|
||||
|
||||
it 'includes DB counts' do
|
||||
subject
|
||||
|
||||
expect(payload).to include(db_replica_count: 0,
|
||||
db_replica_cached_count: 0,
|
||||
db_primary_count: 0,
|
||||
db_primary_cached_count: 0,
|
||||
db_primary_wal_count: 0,
|
||||
db_replica_wal_count: 0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when load balancing is disabled' do
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(false)
|
||||
end
|
||||
|
||||
it 'does not include DB counts' do
|
||||
subject
|
||||
|
||||
expect(payload).not_to include(db_replica_count: 0,
|
||||
db_replica_cached_count: 0,
|
||||
db_primary_count: 0,
|
||||
db_primary_cached_count: 0,
|
||||
db_primary_wal_count: 0,
|
||||
db_replica_wal_count: 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.queue_duration_for_job' do
|
||||
|
|
|
@ -228,6 +228,8 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
|
|||
end
|
||||
|
||||
context 'when the job performs database queries' do
|
||||
include_context 'clear DB Load Balancing configuration'
|
||||
|
||||
before do
|
||||
allow(Time).to receive(:now).and_return(timestamp)
|
||||
allow(Process).to receive(:clock_gettime).and_call_original
|
||||
|
@ -248,28 +250,112 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
|
|||
)
|
||||
end
|
||||
|
||||
it 'logs the database time' do
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
|
||||
shared_examples 'performs database queries' do
|
||||
it 'logs the database time', :aggregate_errors do
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
|
||||
|
||||
call_subject(job, 'test_queue') do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
call_subject(job, 'test_queue') do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
end
|
||||
end
|
||||
|
||||
it 'prevents database time from leaking to the next job', :aggregate_errors do
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload).ordered
|
||||
|
||||
call_subject(job.dup, 'test_queue') do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
end
|
||||
|
||||
Gitlab::SafeRequestStore.clear!
|
||||
|
||||
call_subject(job.dup, 'test_queue') { }
|
||||
end
|
||||
end
|
||||
|
||||
it 'prevents database time from leaking to the next job' do
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
|
||||
expect(logger).to receive(:info).with(expected_start_payload).ordered
|
||||
expect(logger).to receive(:info).with(expected_end_payload).ordered
|
||||
|
||||
call_subject(job.dup, 'test_queue') do
|
||||
ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
|
||||
context 'when load balancing is disabled' do
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(false)
|
||||
end
|
||||
|
||||
Gitlab::SafeRequestStore.clear!
|
||||
let(:expected_end_payload_with_db) do
|
||||
expected_end_payload.merge(
|
||||
'db_duration_s' => a_value >= 0.1,
|
||||
'db_count' => a_value >= 1,
|
||||
'db_cached_count' => 0,
|
||||
'db_write_count' => 0
|
||||
)
|
||||
end
|
||||
|
||||
call_subject(job.dup, 'test_queue') { }
|
||||
include_examples 'performs database queries'
|
||||
end
|
||||
|
||||
context 'when load balancing is enabled' do
|
||||
before do
|
||||
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
|
||||
end
|
||||
|
||||
let(:expected_end_payload_with_db) do
|
||||
expected_end_payload.merge(
|
||||
'db_duration_s' => a_value >= 0.1,
|
||||
'db_count' => a_value >= 1,
|
||||
'db_cached_count' => 0,
|
||||
'db_write_count' => 0,
|
||||
'db_replica_count' => 0,
|
||||
'db_replica_cached_count' => 0,
|
||||
'db_replica_wal_count' => 0,
|
||||
'db_replica_duration_s' => a_value >= 0,
|
||||
'db_primary_count' => a_value >= 1,
|
||||
'db_primary_cached_count' => 0,
|
||||
'db_primary_wal_count' => 0,
|
||||
'db_primary_duration_s' => a_value > 0
|
||||
)
|
||||
end
|
||||
|
||||
let(:end_payload) do
|
||||
start_payload.merge(
|
||||
'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec',
|
||||
'job_status' => 'done',
|
||||
'duration_s' => 0.0,
|
||||
'completed_at' => timestamp.to_f,
|
||||
'cpu_s' => 1.111112,
|
||||
'db_duration_s' => 0.0,
|
||||
'db_cached_count' => 0,
|
||||
'db_count' => 0,
|
||||
'db_write_count' => 0,
|
||||
'db_replica_count' => 0,
|
||||
'db_replica_cached_count' => 0,
|
||||
'db_replica_wal_count' => 0,
|
||||
'db_replica_duration_s' => 0,
|
||||
'db_primary_count' => 0,
|
||||
'db_primary_cached_count' => 0,
|
||||
'db_primary_wal_count' => 0,
|
||||
'db_primary_duration_s' => 0
|
||||
)
|
||||
end
|
||||
|
||||
include_examples 'performs database queries'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the job uses load balancing capabilities' do
|
||||
let(:expected_payload) { { 'database_chosen' => 'retry' } }
|
||||
|
||||
before do
|
||||
allow(Time).to receive(:now).and_return(timestamp)
|
||||
allow(Process).to receive(:clock_gettime).and_call_original
|
||||
end
|
||||
|
||||
it 'logs the database chosen' do
|
||||
expect(logger).to receive(:info).with(start_payload).ordered
|
||||
expect(logger).to receive(:info).with(include(expected_payload)).ordered
|
||||
|
||||
call_subject(job, 'test_queue') do
|
||||
job[:database_chosen] = 'retry'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue