Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
2477ab55
Commit
2477ab55
authored
Nov 20, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
fdffdcf1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
248 additions
and
27 deletions
+248
-27
changelogs/unreleased/36483-move-the-confidence-column-in-the-security-dashboard.yml
...-move-the-confidence-column-in-the-security-dashboard.yml
+5
-0
changelogs/unreleased/add_missing_add_index_rubocop_spec.yml
changelogs/unreleased/add_missing_add_index_rubocop_spec.yml
+5
-0
config/initializers/sidekiq.rb
config/initializers/sidekiq.rb
+8
-15
lib/gitlab/sidekiq_middleware.rb
lib/gitlab/sidekiq_middleware.rb
+34
-0
lib/tasks/gettext.rake
lib/tasks/gettext.rake
+1
-1
spec/frontend/vue_shared/components/notes/system_note_spec.js
.../frontend/vue_shared/components/notes/system_note_spec.js
+14
-10
spec/lib/gitlab/google_code_import/client_spec.rb
spec/lib/gitlab/google_code_import/client_spec.rb
+2
-0
spec/lib/gitlab/google_code_import/importer_spec.rb
spec/lib/gitlab/google_code_import/importer_spec.rb
+3
-1
spec/lib/gitlab/google_code_import/project_creator_spec.rb
spec/lib/gitlab/google_code_import/project_creator_spec.rb
+2
-0
spec/lib/gitlab/sidekiq_middleware_spec.rb
spec/lib/gitlab/sidekiq_middleware_spec.rb
+135
-0
spec/rubocop/cop/migration/add_index_spec.rb
spec/rubocop/cop/migration/add_index_spec.rb
+39
-0
No files found.
changelogs/unreleased/36483-move-the-confidence-column-in-the-security-dashboard.yml
0 → 100644
View file @
2477ab55
---
title
:
Move confidence column in the security dashboard
merge_request
:
20435
author
:
Dheeraj Joshi
type
:
changed
changelogs/unreleased/add_missing_add_index_rubocop_spec.yml
0 → 100644
View file @
2477ab55
---
title
:
add missing test for add_index rubocop rule
merge_request
:
20464
author
:
Eric Thomas
type
:
other
config/initializers/sidekiq.rb
View file @
2477ab55
...
...
@@ -31,21 +31,17 @@ enable_json_logs = Gitlab.config.sidekiq.log_format == 'json'
enable_sidekiq_memory_killer
=
ENV
[
'SIDEKIQ_MEMORY_KILLER_MAX_RSS'
].
to_i
.
nonzero?
use_sidekiq_daemon_memory_killer
=
ENV
[
"SIDEKIQ_DAEMON_MEMORY_KILLER"
].
to_i
.
nonzero?
use_sidekiq_legacy_memory_killer
=
!
use_sidekiq_daemon_memory_killer
use_request_store
=
ENV
[
'SIDEKIQ_REQUEST_STORE'
].
to_i
.
nonzero?
Sidekiq
.
configure_server
do
|
config
|
config
.
redis
=
queues_config_hash
config
.
server_middleware
do
|
chain
|
chain
.
add
Gitlab
::
SidekiqMiddleware
::
Monitor
chain
.
add
Gitlab
::
SidekiqMiddleware
::
Metrics
if
Settings
.
monitoring
.
sidekiq_exporter
chain
.
add
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
if
ENV
[
'SIDEKIQ_LOG_ARGUMENTS'
]
&&
!
enable_json_logs
chain
.
add
Gitlab
::
SidekiqMiddleware
::
MemoryKiller
if
enable_sidekiq_memory_killer
&&
use_sidekiq_legacy_memory_killer
chain
.
add
Gitlab
::
SidekiqMiddleware
::
RequestStoreMiddleware
unless
ENV
[
'SIDEKIQ_REQUEST_STORE'
]
==
'0'
chain
.
add
Gitlab
::
SidekiqMiddleware
::
BatchLoader
chain
.
add
Gitlab
::
SidekiqMiddleware
::
CorrelationLogger
chain
.
add
Gitlab
::
SidekiqMiddleware
::
InstrumentationLogger
chain
.
add
Gitlab
::
SidekiqStatus
::
ServerMiddleware
end
config
.
server_middleware
(
&
Gitlab
::
SidekiqMiddleware
.
server_configurator
({
metrics:
Settings
.
monitoring
.
sidekiq_exporter
,
arguments_logger:
ENV
[
'SIDEKIQ_LOG_ARGUMENTS'
]
&&
!
enable_json_logs
,
memory_killer:
enable_sidekiq_memory_killer
&&
use_sidekiq_legacy_memory_killer
,
request_store:
use_request_store
}))
if
enable_json_logs
Sidekiq
.
logger
.
formatter
=
Gitlab
::
SidekiqLogging
::
JSONFormatter
.
new
...
...
@@ -56,10 +52,7 @@ Sidekiq.configure_server do |config|
config
.
error_handlers
<<
Gitlab
::
SidekiqLogging
::
ExceptionHandler
.
new
end
config
.
client_middleware
do
|
chain
|
chain
.
add
Gitlab
::
SidekiqStatus
::
ClientMiddleware
chain
.
add
Gitlab
::
SidekiqMiddleware
::
CorrelationInjector
end
config
.
client_middleware
(
&
Gitlab
::
SidekiqMiddleware
.
client_configurator
)
config
.
on
:startup
do
# Clear any connections that might have been obtained before starting
...
...
lib/gitlab/sidekiq_middleware.rb
0 → 100644
View file @
2477ab55
# frozen_string_literal: true
module
Gitlab
# The SidekiqMiddleware class is responsible for configuring the
# middleware stacks used in the client and server middlewares
module
SidekiqMiddleware
# The result of this method should be passed to
# Sidekiq's `config.server_middleware` method
# eg: `config.server_middleware(&Gitlab::SidekiqMiddleware.server_configurator)`
def
self
.
server_configurator
(
metrics:
true
,
arguments_logger:
true
,
memory_killer:
true
,
request_store:
true
)
lambda
do
|
chain
|
chain
.
add
Gitlab
::
SidekiqMiddleware
::
Monitor
chain
.
add
Gitlab
::
SidekiqMiddleware
::
Metrics
if
metrics
chain
.
add
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
if
arguments_logger
chain
.
add
Gitlab
::
SidekiqMiddleware
::
MemoryKiller
if
memory_killer
chain
.
add
Gitlab
::
SidekiqMiddleware
::
RequestStoreMiddleware
if
request_store
chain
.
add
Gitlab
::
SidekiqMiddleware
::
BatchLoader
chain
.
add
Gitlab
::
SidekiqMiddleware
::
CorrelationLogger
chain
.
add
Gitlab
::
SidekiqMiddleware
::
InstrumentationLogger
chain
.
add
Gitlab
::
SidekiqStatus
::
ServerMiddleware
end
end
# The result of this method should be passed to
# Sidekiq's `config.client_middleware` method
# eg: `config.client_middleware(&Gitlab::SidekiqMiddleware.client_configurator)`
def
self
.
client_configurator
lambda
do
|
chain
|
chain
.
add
Gitlab
::
SidekiqStatus
::
ClientMiddleware
chain
.
add
Gitlab
::
SidekiqMiddleware
::
CorrelationInjector
end
end
end
end
lib/tasks/gettext.rake
View file @
2477ab55
...
...
@@ -94,7 +94,7 @@ namespace :gettext do
if
pot_diff
.
present?
raise
<<~
MSG
Newly translated strings found, please add them to
`
#{
pot_file
}
` by running:
Changes in translated strings found, please update file
`
#{
pot_file
}
` by running:
bin/rake gettext:regenerate
...
...
spec/frontend/vue_shared/components/notes/system_note_spec.js
View file @
2477ab55
import
Vue
from
'
vue
'
;
import
i
ssueSystemNote
from
'
~/vue_shared/components/notes/system_note.vue
'
;
import
{
createLocalVue
,
mount
}
from
'
@vue/test-utils
'
;
import
I
ssueSystemNote
from
'
~/vue_shared/components/notes/system_note.vue
'
;
import
createStore
from
'
~/notes/stores
'
;
import
initMRPopovers
from
'
~/mr_popover/index
'
;
jest
.
mock
(
'
~/mr_popover/index
'
,
()
=>
jest
.
fn
());
const
localVue
=
createLocalVue
();
describe
(
'
system note component
'
,
()
=>
{
let
vm
;
let
props
;
...
...
@@ -30,34 +32,36 @@ describe('system note component', () => {
const
store
=
createStore
();
store
.
dispatch
(
'
setTargetNoteHash
'
,
`note_
${
props
.
note
.
id
}
`
);
const
Component
=
Vue
.
extend
(
issueSystemNote
);
vm
=
new
Component
({
vm
=
mount
(
IssueSystemNote
,
{
store
,
localVue
,
propsData
:
props
,
}).
$mount
();
attachToDocument
:
true
,
sync
:
false
,
});
});
afterEach
(()
=>
{
vm
.
$
destroy
();
vm
.
destroy
();
});
it
(
'
should render a list item with correct id
'
,
()
=>
{
expect
(
vm
.
$el
.
getAttribute
(
'
id
'
)).
toEqual
(
`note_
${
props
.
note
.
id
}
`
);
expect
(
vm
.
attributes
(
'
id
'
)).
toEqual
(
`note_
${
props
.
note
.
id
}
`
);
});
it
(
'
should render target class is note is target note
'
,
()
=>
{
expect
(
vm
.
$el
.
classList
).
toContain
(
'
target
'
);
expect
(
vm
.
classes
()
).
toContain
(
'
target
'
);
});
it
(
'
should render svg icon
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.timeline-icon svg
'
)).
toBeDefined
(
);
expect
(
vm
.
find
(
'
.timeline-icon svg
'
).
exists
()).
toBe
(
true
);
});
// Redcarpet Markdown renderer wraps text in `<p>` tags
// we need to strip them because they break layout of commit lists in system notes:
// https://gitlab.com/gitlab-org/gitlab-foss/uploads/b07a10670919254f0220d3ff5c1aa110/jqzI.png
it
(
'
removes wrapping paragraph from note HTML
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.system-note-message
'
).
innerHTML
).
toContain
(
'
<span>closed</span>
'
);
expect
(
vm
.
find
(
'
.system-note-message
'
).
html
()
).
toContain
(
'
<span>closed</span>
'
);
});
it
(
'
should initMRPopovers onMount
'
,
()
=>
{
...
...
spec/lib/gitlab/google_code_import/client_spec.rb
View file @
2477ab55
# frozen_string_literal: true
require
"spec_helper"
describe
Gitlab
::
GoogleCodeImport
::
Client
do
...
...
spec/lib/gitlab/google_code_import/importer_spec.rb
View file @
2477ab55
# frozen_string_literal: true
require
"spec_helper"
describe
Gitlab
::
GoogleCodeImport
::
Importer
do
...
...
@@ -37,7 +39,7 @@ describe Gitlab::GoogleCodeImport::Importer do
Performance Usability Maintainability Component-Panel Component-Taskbar Component-Battery
Component-Systray Component-Clock Component-Launcher Component-Tint2conf Component-Docs Component-New
)
.
each
do
|
label
|
label
.
sub!
(
"-"
,
": "
)
label
=
label
.
sub
(
"-"
,
": "
)
expect
(
project
.
labels
.
find_by
(
name:
label
)).
not_to
be_nil
end
end
...
...
spec/lib/gitlab/google_code_import/project_creator_spec.rb
View file @
2477ab55
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
GoogleCodeImport
::
ProjectCreator
do
...
...
spec/lib/gitlab/sidekiq_middleware_spec.rb
0 → 100644
View file @
2477ab55
# frozen_string_literal: true
require
'spec_helper'
require
'sidekiq/testing'
describe
Gitlab
::
SidekiqMiddleware
do
class
TestWorker
include
Sidekiq
::
Worker
def
perform
(
_arg
)
end
end
around
do
|
example
|
Sidekiq
::
Testing
.
inline!
{
example
.
run
}
end
let
(
:worker_class
)
{
TestWorker
}
let
(
:job_args
)
{
[
0.01
]
}
# The test sets up a new server middleware stack, ensuring that the
# appropriate middlewares, as passed into server_configurator,
# are invoked.
# Additionally the test ensure that each middleware is
# 1) not failing
# 2) yielding exactly once
describe
'.server_configurator'
do
let
(
:middleware_expected_args
)
{
[
a_kind_of
(
worker_class
),
hash_including
({
'args'
=>
job_args
}),
anything
]
}
let
(
:all_sidekiq_middlewares
)
do
[
Gitlab
::
SidekiqMiddleware
::
Monitor
,
Gitlab
::
SidekiqMiddleware
::
BatchLoader
,
Gitlab
::
SidekiqMiddleware
::
CorrelationLogger
,
Gitlab
::
SidekiqMiddleware
::
InstrumentationLogger
,
Gitlab
::
SidekiqStatus
::
ServerMiddleware
,
Gitlab
::
SidekiqMiddleware
::
Metrics
,
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
,
Gitlab
::
SidekiqMiddleware
::
MemoryKiller
,
Gitlab
::
SidekiqMiddleware
::
RequestStoreMiddleware
]
end
let
(
:enabled_sidekiq_middlewares
)
{
all_sidekiq_middlewares
-
disabled_sidekiq_middlewares
}
before
do
Sidekiq
::
Testing
.
server_middleware
.
clear
Sidekiq
::
Testing
.
server_middleware
(
&
described_class
.
server_configurator
(
metrics:
metrics
,
arguments_logger:
arguments_logger
,
memory_killer:
memory_killer
,
request_store:
request_store
))
enabled_sidekiq_middlewares
.
each
do
|
middleware
|
expect_any_instance_of
(
middleware
).
to
receive
(
:call
).
with
(
*
middleware_expected_args
).
once
.
and_call_original
end
disabled_sidekiq_middlewares
.
each
do
|
middleware
|
expect_any_instance_of
(
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
).
not_to
receive
(
:call
)
end
end
context
"all optional middlewares off"
do
let
(
:metrics
)
{
false
}
let
(
:arguments_logger
)
{
false
}
let
(
:memory_killer
)
{
false
}
let
(
:request_store
)
{
false
}
let
(
:disabled_sidekiq_middlewares
)
do
[
Gitlab
::
SidekiqMiddleware
::
Metrics
,
Gitlab
::
SidekiqMiddleware
::
ArgumentsLogger
,
Gitlab
::
SidekiqMiddleware
::
MemoryKiller
,
Gitlab
::
SidekiqMiddleware
::
RequestStoreMiddleware
]
end
it
"passes through server middlewares"
do
worker_class
.
perform_async
(
*
job_args
)
end
end
context
"all optional middlewares on"
do
let
(
:metrics
)
{
true
}
let
(
:arguments_logger
)
{
true
}
let
(
:memory_killer
)
{
true
}
let
(
:request_store
)
{
true
}
let
(
:disabled_sidekiq_middlewares
)
{
[]
}
it
"passes through server middlewares"
do
worker_class
.
perform_async
(
*
job_args
)
end
end
end
# The test sets up a new client middleware stack. The test ensures
# that each middleware is:
# 1) not failing
# 2) yielding exactly once
describe
'.client_configurator'
do
let
(
:chain
)
{
Sidekiq
::
Middleware
::
Chain
.
new
}
let
(
:job
)
{
{
'args'
=>
job_args
}
}
let
(
:queue
)
{
'default'
}
let
(
:redis_pool
)
{
Sidekiq
.
redis_pool
}
let
(
:middleware_expected_args
)
{
[
worker_class_arg
,
job
,
queue
,
redis_pool
]
}
before
do
described_class
.
client_configurator
.
call
(
chain
)
end
shared_examples
"a client middleware chain"
do
# Its possible that a middleware could accidentally omit a yield call
# this will prevent the full middleware chain from being executed.
# This test ensures that this does not happen
it
"invokes the chain"
do
expect_any_instance_of
(
Gitlab
::
SidekiqStatus
::
ClientMiddleware
).
to
receive
(
:call
).
with
(
*
middleware_expected_args
).
once
.
and_call_original
expect_any_instance_of
(
Gitlab
::
SidekiqMiddleware
::
CorrelationInjector
).
to
receive
(
:call
).
with
(
*
middleware_expected_args
).
once
.
and_call_original
expect
{
|
b
|
chain
.
invoke
(
worker_class_arg
,
job
,
queue
,
redis_pool
,
&
b
)
}.
to
yield_control
.
once
end
end
# Sidekiq documentation states that the worker class could be a string
# or a class reference. We should test for both
context
"handles string worker_class values"
do
let
(
:worker_class_arg
)
{
worker_class
.
to_s
}
it_behaves_like
"a client middleware chain"
end
context
"handles string worker_class values"
do
let
(
:worker_class_arg
)
{
worker_class
}
it_behaves_like
"a client middleware chain"
end
end
end
spec/rubocop/cop/migration/add_index_spec.rb
0 → 100644
View file @
2477ab55
# frozen_string_literal: true
require
'spec_helper'
require
'rubocop'
require
'rubocop/rspec/support'
require_relative
'../../../../rubocop/cop/migration/add_index'
describe
RuboCop
::
Cop
::
Migration
::
AddIndex
do
include
CopHelper
subject
(
:cop
)
{
described_class
.
new
}
context
'in migration'
do
before
do
allow
(
cop
).
to
receive
(
:in_migration?
).
and_return
(
true
)
end
it
'registers an offense when add_index is used'
do
expect_offense
(
<<~
PATTERN
.
strip_indent
)
def change
add_index :table, :column
^^^^^^^^^ `add_index` requires downtime, use `add_concurrent_index` instead
end
PATTERN
end
end
context
'outside of migration'
do
it
'registers no offense'
do
expect_no_offenses
(
<<~
PATTERN
.
strip_indent
)
def change
add_index :table, :column
end
PATTERN
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment