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
ce1e1ef8
Commit
ce1e1ef8
authored
Apr 09, 2020
by
Dylan Griffith
Committed by
Dmitry Gruzd
Apr 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Elastic_indexer_worker_spec is now passing
But index_record_service_spec still flaky
parent
7e3811f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
17 deletions
+51
-17
ee/spec/services/elastic/index_record_service_spec.rb
ee/spec/services/elastic/index_record_service_spec.rb
+27
-3
ee/spec/workers/elastic_indexer_worker_spec.rb
ee/spec/workers/elastic_indexer_worker_spec.rb
+24
-14
No files found.
ee/spec/services/elastic/index_record_service_spec.rb
View file @
ce1e1ef8
...
...
@@ -5,6 +5,11 @@ require 'spec_helper'
describe
Elastic
::
IndexRecordService
,
:elastic
do
subject
{
described_class
.
new
}
# Create admin user and search globally to avoid dealing with permissions in
# these tests
let
(
:user
)
{
create
(
:admin
)
}
let
(
:search_options
)
{
{
options:
{
current_user:
user
,
project_ids: :any
}}
}
before
do
stub_ee_application_setting
(
elasticsearch_indexing:
true
)
...
...
@@ -27,13 +32,21 @@ describe Elastic::IndexRecordService, :elastic do
it
'indexes new records'
do
object
=
create
(
type
)
Sidekiq
::
Testing
.
disable!
do
if
type
!=
:project
# You cannot find anything in the index if it's parent project is
# not first indexed.
subject
.
execute
(
object
.
project
,
true
)
end
end
# Prevent records from being added via bulk indexing updates
::
Elastic
::
ProcessBookkeepingService
.
clear_tracking!
expect
do
expect
(
subject
.
execute
(
object
,
true
)).
to
eq
(
true
)
ensure_elasticsearch_index!
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
records
.
size
}.
by
(
1
)
end
.
to
change
{
object
.
class
.
elastic_search
(
'*'
,
search_options
).
total_count
}.
by
(
1
)
end
it
'updates the index when object is changed'
do
...
...
@@ -41,6 +54,13 @@ describe Elastic::IndexRecordService, :elastic do
Sidekiq
::
Testing
.
disable!
do
object
=
create
(
type
)
if
type
!=
:project
# You cannot find anything in the index if it's parent project is
# not first indexed.
subject
.
execute
(
object
.
project
,
true
)
end
expect
(
subject
.
execute
(
object
,
true
)).
to
eq
(
true
)
object
.
update
(
attribute
=>
"new"
)
end
...
...
@@ -48,7 +68,7 @@ describe Elastic::IndexRecordService, :elastic do
expect
do
expect
(
subject
.
execute
(
object
,
false
)).
to
eq
(
true
)
ensure_elasticsearch_index!
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'new'
).
records
.
size
}.
by
(
1
)
end
.
to
change
{
object
.
class
.
elastic_search
(
'new'
,
search_options
).
total_count
}.
by
(
1
)
end
it
'ignores Elasticsearch::Transport::Transport::Errors::NotFound errors'
do
...
...
@@ -74,7 +94,11 @@ describe Elastic::IndexRecordService, :elastic do
end
# Nothing should be in the index at this point
expect
(
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
).
to
be
(
0
)
expect
(
Project
.
elastic_search
(
'*'
,
search_options
).
total_count
).
to
be
(
0
)
expect
(
Issue
.
elastic_search
(
'*'
,
search_options
).
total_count
).
to
be
(
0
)
expect
(
Milestone
.
elastic_search
(
'*'
,
search_options
).
total_count
).
to
be
(
0
)
expect
(
MergeRequest
.
elastic_search
(
'*'
,
search_options
).
total_count
).
to
be
(
0
)
expect
(
ProjectSnippet
.
elastic_search
(
'*'
,
search_options
).
total_count
).
to
be
(
0
)
end
it
'indexes records associated with the project'
do
...
...
ee/spec/workers/elastic_indexer_worker_spec.rb
View file @
ce1e1ef8
...
...
@@ -5,7 +5,10 @@ require 'spec_helper'
describe
ElasticIndexerWorker
,
:elastic
do
subject
{
described_class
.
new
}
let
(
:search_options
)
{
{
options:
{
public_and_internal_projects:
true
}}
}
# Create admin user and search globally to avoid dealing with permissions in
# these tests
let
(
:user
)
{
create
(
:admin
)
}
let
(
:search_options
)
{
{
options:
{
current_user:
user
,
project_ids: :any
}}
}
before
do
stub_ee_application_setting
(
elasticsearch_indexing:
true
)
...
...
@@ -25,12 +28,12 @@ describe ElasticIndexerWorker, :elastic do
describe
'Indexing, updating, and deleting records'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:type
,
:name
,
:attribute
)
do
:project
|
"Project"
|
:name
:issue
|
"Issue"
|
:title
:note
|
"Note"
|
:note
:milestone
|
"Milestone"
|
:title
:merge_request
|
"MergeRequest"
|
:title
where
(
:type
,
:name
)
do
:project
|
"Project"
:issue
|
"Issue"
:note
|
"Note"
:milestone
|
"Milestone"
:merge_request
|
"MergeRequest"
end
with_them
do
...
...
@@ -49,6 +52,13 @@ describe ElasticIndexerWorker, :elastic do
Sidekiq
::
Testing
.
disable!
do
object
=
create
(
type
)
if
type
!=
:project
# You cannot find anything in the index if it's parent project is
# not first indexed.
subject
.
perform
(
"index"
,
"Project"
,
object
.
project
.
id
,
object
.
project
.
es_id
)
end
subject
.
perform
(
"index"
,
name
,
object
.
id
,
object
.
es_id
)
ensure_elasticsearch_index!
object
.
destroy
...
...
@@ -57,7 +67,7 @@ describe ElasticIndexerWorker, :elastic do
expect
do
subject
.
perform
(
"delete"
,
name
,
object
.
id
,
object
.
es_id
,
{
'es_parent'
=>
object
.
es_parent
})
ensure_elasticsearch_index!
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
}.
by
(
-
1
)
end
.
to
change
{
object
.
class
.
elastic_search
(
'*'
,
search_options
).
total_count
}.
by
(
-
1
)
end
end
end
...
...
@@ -66,7 +76,7 @@ describe ElasticIndexerWorker, :elastic do
project
,
issue
,
milestone
,
note
,
merge_request
=
nil
Sidekiq
::
Testing
.
disable!
do
project
=
create
:project
,
:repository
,
:public
project
=
create
:project
,
:repository
subject
.
perform
(
"index"
,
"Project"
,
project
.
id
,
project
.
es_id
)
issue
=
create
:issue
,
project:
project
...
...
@@ -86,11 +96,11 @@ describe ElasticIndexerWorker, :elastic do
ensure_elasticsearch_index!
## All database objects + data from repository. The absolute value does not matter
expect
(
Project
.
elastic_search
(
'*'
,
search_options
).
records
.
to_a
).
to
include
(
project
)
expect
(
Issue
.
elastic_search
(
'*'
,
search_options
).
records
.
to_a
).
to
include
(
issue
)
expect
(
Milestone
.
elastic_search
(
'*'
,
search_options
).
records
.
to_a
).
to
include
(
milestone
)
expect
(
Note
.
elastic_search
(
'*'
,
search_options
).
records
.
to_a
).
to
include
(
note
)
expect
(
MergeRequest
.
elastic_search
(
'*'
,
search_options
).
records
.
to_a
).
to
include
(
merge_request
)
expect
(
Project
.
elastic_search
(
'*'
,
search_options
).
records
).
to
include
(
project
)
expect
(
Issue
.
elastic_search
(
'*'
,
search_options
).
records
).
to
include
(
issue
)
expect
(
Milestone
.
elastic_search
(
'*'
,
search_options
).
records
).
to
include
(
milestone
)
expect
(
Note
.
elastic_search
(
'*'
,
search_options
).
records
).
to
include
(
note
)
expect
(
MergeRequest
.
elastic_search
(
'*'
,
search_options
).
records
).
to
include
(
merge_request
)
subject
.
perform
(
"delete"
,
"Project"
,
project
.
id
,
project
.
es_id
)
ensure_elasticsearch_index!
...
...
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