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
1393e786
Commit
1393e786
authored
Nov 19, 2020
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix intermitten elastic-related specs failures
parent
61f92c32
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
ee/spec/models/elastic/migration_record_spec.rb
ee/spec/models/elastic/migration_record_spec.rb
+3
-3
ee/spec/support/elastic.rb
ee/spec/support/elastic.rb
+15
-8
ee/spec/support/helpers/elasticsearch_helpers.rb
ee/spec/support/helpers/elasticsearch_helpers.rb
+1
-1
ee/spec/workers/elastic/migration_worker_spec.rb
ee/spec/workers/elastic/migration_worker_spec.rb
+2
-2
No files found.
ee/spec/models/elastic/migration_record_spec.rb
View file @
1393e786
...
...
@@ -7,7 +7,7 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
describe
'#save!'
do
it
'creates an index if it is not found'
do
es_helper
.
delete_index
(
index_name:
@
migrations_index_name
)
es_helper
.
delete_index
(
index_name:
es_helper
.
migrations_index_name
)
expect
{
record
.
save!
(
completed:
true
)
}.
to
raise_error
(
/index is not found/
)
end
...
...
@@ -55,7 +55,7 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
completed_versions
.
each
{
|
migration
|
migration
.
save!
(
completed:
true
)
}
in_progress_migration
.
save!
(
completed:
false
)
es_helper
.
refresh_index
(
index_name:
@
migrations_index_name
)
es_helper
.
refresh_index
(
index_name:
es_helper
.
migrations_index_name
)
end
it
'loads all records'
do
...
...
@@ -64,7 +64,7 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
end
it
'returns empty array if no index present'
do
es_helper
.
delete_index
(
index_name:
@
migrations_index_name
)
es_helper
.
delete_index
(
index_name:
es_helper
.
migrations_index_name
)
expect
(
described_class
.
persisted_versions
(
completed:
true
)).
to
eq
([])
expect
(
described_class
.
persisted_versions
(
completed:
false
)).
to
eq
([])
...
...
ee/spec/support/elastic.rb
View file @
1393e786
# frozen_string_literal: true
RSpec
.
configure
do
|
config
|
config
.
before
(
:each
,
:elastic
)
do
config
.
around
(
:each
,
:elastic
)
do
|
example
|
helper
=
Gitlab
::
Elastic
::
Helper
.
default
Elastic
::
ProcessBookkeepingService
.
clear_tracking!
Gitlab
::
Elastic
::
Helper
.
default
.
delete_index
Gitlab
::
Elastic
::
Helper
.
default
.
create_empty_index
(
options:
{
settings:
{
number_of_replicas:
0
}
})
@migrations_index_name
=
Gitlab
::
Elastic
::
Helper
.
default
.
create_migrations_index
end
config
.
after
(
:each
,
:elastic
)
do
Gitlab
::
Elastic
::
Helper
.
default
.
delete_index
# Delete the migration index and the main ES index
helper
.
delete_index
(
index_name:
helper
.
migrations_index_name
)
helper
.
delete_index
helper
.
create_empty_index
(
options:
{
settings:
{
number_of_replicas:
0
}
})
helper
.
create_migrations_index
example
.
run
helper
.
delete_index
(
index_name:
helper
.
migrations_index_name
)
helper
.
delete_index
Elastic
::
ProcessBookkeepingService
.
clear_tracking!
Gitlab
::
Elastic
::
Helper
.
default
.
delete_index
(
index_name:
@migrations_index_name
)
end
config
.
include
ElasticsearchHelpers
,
:elastic
...
...
ee/spec/support/helpers/elasticsearch_helpers.rb
View file @
1393e786
...
...
@@ -36,7 +36,7 @@ module ElasticsearchHelpers
def
refresh_index!
es_helper
.
refresh_index
es_helper
.
refresh_index
(
index_name:
@migrations_index_name
)
# rubocop:disable Gitlab/ModuleWithInstanceVariables
es_helper
.
refresh_index
(
index_name:
es_helper
.
migrations_index_name
)
end
def
es_helper
...
...
ee/spec/workers/elastic/migration_worker_spec.rb
View file @
1393e786
...
...
@@ -23,9 +23,9 @@ RSpec.describe Elastic::MigrationWorker, :elastic do
end
it
'creates an index if it does not exist'
do
Gitlab
::
Elastic
::
Helper
.
default
.
delete_index
(
index_name:
@
migrations_index_name
)
Gitlab
::
Elastic
::
Helper
.
default
.
delete_index
(
index_name:
es_helper
.
migrations_index_name
)
expect
{
subject
.
perform
}.
to
change
{
Gitlab
::
Elastic
::
Helper
.
default
.
index_exists?
(
index_name:
@
migrations_index_name
)
}.
from
(
false
).
to
(
true
)
expect
{
subject
.
perform
}.
to
change
{
Gitlab
::
Elastic
::
Helper
.
default
.
index_exists?
(
index_name:
es_helper
.
migrations_index_name
)
}.
from
(
false
).
to
(
true
)
end
context
'no unexecuted migrations'
do
...
...
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