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
Jérome Perrin
gitlab-ce
Commits
8c5ce1b0
Commit
8c5ce1b0
authored
May 29, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs covering listing all gitlab:storage:* types
parent
b384d5e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
5 deletions
+101
-5
lib/tasks/gitlab/storage.rake
lib/tasks/gitlab/storage.rake
+1
-1
spec/tasks/gitlab/storage_rake_spec.rb
spec/tasks/gitlab/storage_rake_spec.rb
+100
-4
No files found.
lib/tasks/gitlab/storage.rake
View file @
8c5ce1b0
...
@@ -25,7 +25,7 @@ namespace :gitlab do
...
@@ -25,7 +25,7 @@ namespace :gitlab do
desc
'Gitlab | Storage | Summary of existing projects using Legacy Storage'
desc
'Gitlab | Storage | Summary of existing projects using Legacy Storage'
task
legacy_projects: :environment
do
task
legacy_projects: :environment
do
helper
=
Gitlab
::
HashedStorage
::
RakeHelper
helper
=
Gitlab
::
HashedStorage
::
RakeHelper
helper
.
relation_summary
(
'projects'
,
Project
.
without_storage_feature
(
:repository
))
helper
.
relation_summary
(
'projects
using Legacy Storage
'
,
Project
.
without_storage_feature
(
:repository
))
end
end
desc
'Gitlab | Storage | List existing projects using Legacy Storage'
desc
'Gitlab | Storage | List existing projects using Legacy Storage'
...
...
spec/tasks/gitlab/storage_rake_spec.rb
View file @
8c5ce1b0
require
'rake_helper'
require
'rake_helper'
describe
'gitlab:storage
rake tasks
'
do
describe
'gitlab:storage
:*
'
do
before
do
before
do
Rake
.
application
.
rake_require
'tasks/gitlab/storage'
Rake
.
application
.
rake_require
'tasks/gitlab/storage'
stub_warn_user_is_not_gitlab
stub_warn_user_is_not_gitlab
end
end
describe
'migrate_to_hashed rake task'
do
shared_examples
"rake listing entities"
do
|
entity_name
,
storage_type
|
context
'limiting to 2'
do
before
do
stub_env
(
'LIMIT'
=>
2
)
end
it
"lists 2 out of 3
#{
storage_type
.
downcase
}
#{
entity_name
}
"
do
create_collection
expect
{
run_rake_task
(
task
)
}.
to
output
(
/Found 3
#{
entity_name
}
using
#{
storage_type
}
Storage.*Displaying first 2
#{
entity_name
}
/m
).
to_stdout
end
end
context
"without any
#{
storage_type
.
downcase
}
#{
entity_name
.
singularize
}
"
do
it
'displays message for empty results'
do
expect
{
run_rake_task
(
task
)
}.
to
output
(
/Found 0
#{
entity_name
}
using
#{
storage_type
}
Storage/
).
to_stdout
end
end
end
shared_examples
"rake entities summary"
do
|
entity_name
,
storage_type
|
context
"with existing 3
#{
storage_type
.
downcase
}
#{
entity_name
}
"
do
it
"reports 3
#{
storage_type
.
downcase
}
#{
entity_name
}
"
do
create_collection
expect
{
run_rake_task
(
task
)
}.
to
output
(
/Found 3
#{
entity_name
}
using
#{
storage_type
}
Storage/
).
to_stdout
end
end
context
"without any
#{
storage_type
.
downcase
}
#{
entity_name
.
singularize
}
"
do
it
'displays message for empty results'
do
expect
{
run_rake_task
(
task
)
}.
to
output
(
/Found 0
#{
entity_name
}
using
#{
storage_type
}
Storage/
).
to_stdout
end
end
end
describe
'gitlab:storage:migrate_to_hashed'
do
context
'0 legacy projects'
do
context
'0 legacy projects'
do
it
'does nothing'
do
it
'does nothing'
do
expect
(
StorageMigratorWorker
).
not_to
receive
(
:perform_async
)
expect
(
StorageMigratorWorker
).
not_to
receive
(
:perform_async
)
...
@@ -16,8 +52,8 @@ describe 'gitlab:storage rake tasks' do
...
@@ -16,8 +52,8 @@ describe 'gitlab:storage rake tasks' do
end
end
end
end
context
'
5
legacy projects'
do
context
'
3
legacy projects'
do
let
(
:projects
)
{
create_list
(
:project
,
5
,
storage_version:
0
)
}
let
(
:projects
)
{
create_list
(
:project
,
3
,
storage_version:
0
)
}
context
'in batches of 1'
do
context
'in batches of 1'
do
before
do
before
do
...
@@ -49,4 +85,64 @@ describe 'gitlab:storage rake tasks' do
...
@@ -49,4 +85,64 @@ describe 'gitlab:storage rake tasks' do
end
end
end
end
end
end
describe
'gitlab:storage:legacy_projects'
do
it_behaves_like
'rake entities summary'
,
'projects'
,
'Legacy'
do
let
(
:task
)
{
'gitlab:storage:legacy_projects'
}
let
(
:create_collection
)
{
create_list
(
:project
,
3
,
storage_version:
0
)
}
end
end
describe
'gitlab:storage:list_legacy_projects'
do
it_behaves_like
'rake listing entities'
,
'projects'
,
'Legacy'
do
let
(
:task
)
{
'gitlab:storage:list_legacy_projects'
}
let
(
:create_collection
)
{
create_list
(
:project
,
3
,
storage_version:
0
)
}
end
end
describe
'gitlab:storage:hashed_projects'
do
it_behaves_like
'rake entities summary'
,
'projects'
,
'Hashed'
do
let
(
:task
)
{
'gitlab:storage:hashed_projects'
}
let
(
:create_collection
)
{
create_list
(
:project
,
3
,
storage_version:
1
)
}
end
end
describe
'gitlab:storage:list_hashed_projects'
do
it_behaves_like
'rake listing entities'
,
'projects'
,
'Hashed'
do
let
(
:task
)
{
'gitlab:storage:list_hashed_projects'
}
let
(
:create_collection
)
{
create_list
(
:project
,
3
,
storage_version:
1
)
}
end
end
describe
'gitlab:storage:legacy_attachments'
do
it_behaves_like
'rake entities summary'
,
'attachments'
,
'Legacy'
do
let
(
:task
)
{
'gitlab:storage:legacy_attachments'
}
let
(
:project
)
{
create
(
:project
,
storage_version:
1
)
}
let
(
:create_collection
)
{
create_list
(
:upload
,
3
,
model:
project
)
}
end
end
describe
'gitlab:storage:list_legacy_attachments'
do
it_behaves_like
'rake listing entities'
,
'attachments'
,
'Legacy'
do
let
(
:task
)
{
'gitlab:storage:list_legacy_attachments'
}
let
(
:project
)
{
create
(
:project
,
storage_version:
1
)
}
let
(
:create_collection
)
{
create_list
(
:upload
,
3
,
model:
project
)
}
end
end
describe
'gitlab:storage:hashed_attachments'
do
it_behaves_like
'rake entities summary'
,
'attachments'
,
'Hashed'
do
let
(
:task
)
{
'gitlab:storage:hashed_attachments'
}
let
(
:project
)
{
create
(
:project
,
storage_version:
2
)
}
let
(
:create_collection
)
{
create_list
(
:upload
,
3
,
model:
project
)
}
end
end
describe
'gitlab:storage:list_hashed_attachments'
do
it_behaves_like
'rake listing entities'
,
'attachments'
,
'Hashed'
do
let
(
:task
)
{
'gitlab:storage:list_hashed_attachments'
}
let
(
:project
)
{
create
(
:project
,
storage_version:
2
)
}
let
(
:create_collection
)
{
create_list
(
:upload
,
3
,
model:
project
)
}
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