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
b5ed9e38
Commit
b5ed9e38
authored
Apr 06, 2022
by
Katrin Leinweber
Committed by
Dmitry Gruzd
Apr 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore unindexed projects that have no repository
Changelog: changed EE: true
parent
d853a87a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
4 deletions
+43
-4
ee/lib/tasks/gitlab/elastic.rake
ee/lib/tasks/gitlab/elastic.rake
+10
-4
ee/spec/tasks/gitlab/elastic_rake_spec.rb
ee/spec/tasks/gitlab/elastic_rake_spec.rb
+33
-0
No files found.
ee/lib/tasks/gitlab/elastic.rake
View file @
b5ed9e38
...
...
@@ -160,7 +160,15 @@ namespace :gitlab do
desc
"GitLab | Elasticsearch | Display which projects are not indexed"
task
projects_not_indexed: :environment
do
not_indexed
=
Project
.
where
.
not
(
id:
IndexStatus
.
select
(
:project_id
).
distinct
)
not_indexed
=
[]
Project
.
where
.
not
(
id:
IndexStatus
.
select
(
:project_id
).
distinct
).
each_batch
do
|
batch
|
batch
.
each
do
|
project
|
next
if
!
project
.
repository_exists?
||
project
.
empty_repo?
not_indexed
<<
project
end
end
if
not_indexed
.
count
==
0
puts
'All projects are currently indexed'
.
color
(
:green
)
...
...
@@ -271,9 +279,7 @@ namespace :gitlab do
projects
[
1
..
500
]
end
arr
.
each
do
|
p
|
puts
"Project '
#{
p
.
full_path
}
' (ID:
#{
p
.
id
}
) isn't indexed."
.
color
(
:red
)
end
arr
.
each
{
|
p
|
puts
"Project '
#{
p
.
full_path
}
' (ID:
#{
p
.
id
}
) isn't indexed."
.
color
(
:red
)
}
puts
"
#{
arr
.
count
}
out of
#{
projects
.
count
}
non-indexed projects shown."
end
...
...
ee/spec/tasks/gitlab/elastic_rake_spec.rb
View file @
b5ed9e38
...
...
@@ -348,4 +348,37 @@ RSpec.describe 'gitlab:elastic namespace rake tasks', :elastic, :silence_stdout
end
end
end
describe
'projects_not_indexed'
do
subject
{
run_rake_task
(
'gitlab:elastic:projects_not_indexed'
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
context
'no projects are indexed'
do
it
'displays non-indexed projects'
do
expected
=
<<~
END
Project '
#{
project
.
full_path
}
' (ID:
#{
project
.
id
}
) isn't indexed.
1 out of 1 non-indexed projects shown.
END
expect
{
subject
}.
to
output
(
expected
).
to_stdout
end
end
context
'all projects are indexed'
do
before
do
IndexStatus
.
create!
(
project:
project
,
indexed_at:
Time
.
current
,
last_commit:
'foo'
)
end
it
'displays that all projects are indexed'
do
expect
{
subject
}.
to
output
(
/All projects are currently indexed/
).
to_stdout
end
it
'does not include projects without repositories'
do
create
(
:project
)
expect
{
subject
}.
to
output
(
/All projects are currently indexed/
).
to_stdout
end
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