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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
abb256e8
Commit
abb256e8
authored
Dec 03, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ES: fix write target forwarding
Add spec
parent
2ef7c83a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
2 deletions
+80
-2
ee/lib/elastic/latest/git_instance_proxy.rb
ee/lib/elastic/latest/git_instance_proxy.rb
+6
-2
ee/spec/lib/elastic/latest/git_instance_proxy_spec.rb
ee/spec/lib/elastic/latest/git_instance_proxy_spec.rb
+74
-0
No files found.
ee/lib/elastic/latest/git_instance_proxy.rb
View file @
abb256e8
...
...
@@ -3,9 +3,13 @@
module
Elastic
module
Latest
module
GitInstanceProxy
def
self
.
methods_for_all_write_targets
extend
ActiveSupport
::
Concern
class_methods
do
def
methods_for_all_write_targets
super
+
[
:delete_index_for_commits_and_blobs
]
end
end
def
es_parent
"project_
#{
project_id
}
"
...
...
ee/spec/lib/elastic/latest/git_instance_proxy_spec.rb
0 → 100644
View file @
abb256e8
# frozen_string_literal: true
require
'spec_helper'
describe
Elastic
::
Latest
::
GitInstanceProxy
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:included_class
)
{
Elastic
::
Latest
::
RepositoryInstanceProxy
}
subject
{
included_class
.
new
(
project
.
repository
)
}
describe
'.methods_for_all_write_targets'
do
it
'contains extra method'
do
expect
(
included_class
.
methods_for_all_write_targets
).
to
contain_exactly
(
*
Elastic
::
Latest
::
ApplicationInstanceProxy
.
methods_for_all_write_targets
,
:delete_index_for_commits_and_blobs
)
end
end
describe
'#es_parent'
do
it
'contains project id'
do
expect
(
subject
.
es_parent
).
to
eq
(
"project_
#{
project
.
id
}
"
)
end
end
describe
'#elastic_search'
do
let
(
:params
)
do
{
type: :fake_type
,
page:
2
,
per:
30
,
options:
{
foo: :bar
}
}
end
it
'provides repository_id if not provided'
do
expected_params
=
params
.
deep_dup
expected_params
[
:options
][
:repository_id
]
=
project
.
id
expect
(
subject
.
class
).
to
receive
(
:elastic_search
).
with
(
'foo'
,
expected_params
)
subject
.
elastic_search
(
'foo'
,
params
)
end
it
'uses provided repository_id'
do
params
[
:options
][
:repository_id
]
=
42
expect
(
subject
.
class
).
to
receive
(
:elastic_search
).
with
(
'foo'
,
params
)
subject
.
elastic_search
(
'foo'
,
params
)
end
end
describe
'#delete_index_for_commits_and_blobs'
do
let
(
:write_targets
)
{
[
double
(
:write_target_1
),
double
(
:write_target_2
)]
}
let
(
:read_target
)
{
double
(
:read_target
)
}
before
do
project
.
repository
.
__elasticsearch__
.
tap
do
|
proxy
|
allow
(
proxy
).
to
receive
(
:elastic_writing_targets
).
and_return
(
write_targets
)
allow
(
proxy
).
to
receive
(
:elastic_reading_target
).
and_return
(
read_target
)
end
end
it
'is forwarded to all write targets'
do
expect
(
read_target
).
not_to
receive
(
:delete_index_for_commits_and_blobs
)
expect
(
write_targets
).
to
all
(
receive
(
:delete_index_for_commits_and_blobs
).
and_return
({
'_shards'
=>
{}
})
)
project
.
repository
.
delete_index_for_commits_and_blobs
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