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
ee7f7597
Commit
ee7f7597
authored
Jan 29, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
17dbfea4
d8f7bfe3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
17 deletions
+66
-17
ee/app/models/groups/repository_storage_move.rb
ee/app/models/groups/repository_storage_move.rb
+15
-0
ee/spec/factories/group_repository_storage_moves.rb
ee/spec/factories/group_repository_storage_moves.rb
+29
-0
ee/spec/models/groups/repository_storage_move_spec.rb
ee/spec/models/groups/repository_storage_move_spec.rb
+5
-2
spec/support/shared_examples/models/concerns/repository_storage_movable_shared_examples.rb
...ls/concerns/repository_storage_movable_shared_examples.rb
+16
-14
spec/tasks/gitlab/pages_rake_spec.rb
spec/tasks/gitlab/pages_rake_spec.rb
+1
-1
No files found.
ee/app/models/groups/repository_storage_move.rb
View file @
ee7f7597
...
@@ -5,11 +5,26 @@
...
@@ -5,11 +5,26 @@
# balance storage capacity.
# balance storage capacity.
module
Groups
module
Groups
class
RepositoryStorageMove
<
ApplicationRecord
class
RepositoryStorageMove
<
ApplicationRecord
extend
::
Gitlab
::
Utils
::
Override
include
RepositoryStorageMovable
self
.
table_name
=
'group_repository_storage_moves'
self
.
table_name
=
'group_repository_storage_moves'
belongs_to
:container
,
class_name:
'Group'
,
inverse_of: :repository_storage_moves
,
foreign_key: :group_id
belongs_to
:container
,
class_name:
'Group'
,
inverse_of: :repository_storage_moves
,
foreign_key: :group_id
alias_attribute
:group
,
:container
alias_attribute
:group
,
:container
scope
:with_groups
,
->
{
includes
(
container: :route
)
}
scope
:with_groups
,
->
{
includes
(
container: :route
)
}
override
:schedule_repository_storage_update_worker
def
schedule_repository_storage_update_worker
# No-op. It will be implemented in https://gitlab.com/gitlab-org/gitlab/-/issues/299059
end
private
override
:error_key
def
error_key
:group
end
end
end
end
end
ee/spec/factories/group_repository_storage_moves.rb
0 → 100644
View file @
ee7f7597
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:group_repository_storage_move
,
class:
'Groups::RepositoryStorageMove'
do
container
{
association
(
:group
)
}
source_storage_name
{
'default'
}
trait
:scheduled
do
state
{
Groups
::
RepositoryStorageMove
.
state_machines
[
:state
].
states
[
:scheduled
].
value
}
end
trait
:started
do
state
{
Groups
::
RepositoryStorageMove
.
state_machines
[
:state
].
states
[
:started
].
value
}
end
trait
:replicated
do
state
{
Groups
::
RepositoryStorageMove
.
state_machines
[
:state
].
states
[
:replicated
].
value
}
end
trait
:finished
do
state
{
Groups
::
RepositoryStorageMove
.
state_machines
[
:state
].
states
[
:finished
].
value
}
end
trait
:failed
do
state
{
Groups
::
RepositoryStorageMove
.
state_machines
[
:state
].
states
[
:failed
].
value
}
end
end
end
ee/spec/models/groups/repository_storage_move_spec.rb
View file @
ee7f7597
...
@@ -3,7 +3,10 @@
...
@@ -3,7 +3,10 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Groups
::
RepositoryStorageMove
,
type: :model
do
RSpec
.
describe
Groups
::
RepositoryStorageMove
,
type: :model
do
describe
'associations'
do
it_behaves_like
'handles repository moves'
,
check_worker:
false
do
it
{
is_expected
.
to
belong_to
(
:container
).
class_name
(
'Group'
)
}
let_it_be_with_refind
(
:container
)
{
create
(
:group
)
}
let
(
:repository_storage_factory_key
)
{
:group_repository_storage_move
}
let
(
:error_key
)
{
:group
}
end
end
end
end
spec/support/shared_examples/models/concerns/repository_storage_movable_shared_examples.rb
View file @
ee7f7597
# frozen_string_literal: true
# frozen_string_literal: true
RSpec
.
shared_examples
'handles repository moves'
do
RSpec
.
shared_examples
'handles repository moves'
do
|
check_worker:
true
|
describe
'associations'
do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:container
)
}
it
{
is_expected
.
to
belong_to
(
:container
)
}
end
end
...
@@ -33,7 +33,7 @@ RSpec.shared_examples 'handles repository moves' do
...
@@ -33,7 +33,7 @@ RSpec.shared_examples 'handles repository moves' do
subject
{
build
(
repository_storage_factory_key
,
container:
container
)
}
subject
{
build
(
repository_storage_factory_key
,
container:
container
)
}
it
"does not allow the container to be read-only on create"
do
it
"does not allow the container to be read-only on create"
do
container
.
update!
(
repository_read_only:
true
)
container
.
set_repository_read_only!
expect
(
subject
).
not_to
be_valid
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
[
error_key
].
first
).
to
match
(
/is read only/
)
expect
(
subject
.
errors
[
error_key
].
first
).
to
match
(
/is read only/
)
...
@@ -61,23 +61,25 @@ RSpec.shared_examples 'handles repository moves' do
...
@@ -61,23 +61,25 @@ RSpec.shared_examples 'handles repository moves' do
context
'when in the default state'
do
context
'when in the default state'
do
subject
(
:storage_move
)
{
create
(
repository_storage_factory_key
,
container:
container
,
destination_storage_name:
'test_second_storage'
)
}
subject
(
:storage_move
)
{
create
(
repository_storage_factory_key
,
container:
container
,
destination_storage_name:
'test_second_storage'
)
}
context
'and transits to scheduled'
do
if
check_worker
it
'triggers the corresponding repository storage worker'
do
context
'and transits to scheduled'
do
expect
(
repository_storage_worker
).
to
receive
(
:perform_async
).
with
(
container
.
id
,
'test_second_storage'
,
storage_move
.
id
)
it
'triggers the corresponding repository storage worker'
do
expect
(
repository_storage_worker
).
to
receive
(
:perform_async
).
with
(
container
.
id
,
'test_second_storage'
,
storage_move
.
id
)
storage_move
.
schedule!
storage_move
.
schedule!
expect
(
container
).
to
be_repository_read_only
expect
(
container
).
to
be_repository_read_only
end
end
context
'when the transition fails'
do
context
'when the transition fails'
do
it
'does not trigger the corresponding repository storage worker and adds an error'
do
it
'does not trigger the corresponding repository storage worker and adds an error'
do
allow
(
storage_move
.
container
).
to
receive
(
:set_repository_read_only!
).
and_raise
(
StandardError
,
'foobar'
)
allow
(
storage_move
.
container
).
to
receive
(
:set_repository_read_only!
).
and_raise
(
StandardError
,
'foobar'
)
expect
(
repository_storage_worker
).
not_to
receive
(
:perform_async
)
expect
(
repository_storage_worker
).
not_to
receive
(
:perform_async
)
storage_move
.
schedule!
storage_move
.
schedule!
expect
(
storage_move
.
errors
[
error_key
]).
to
include
(
'foobar'
)
expect
(
storage_move
.
errors
[
error_key
]).
to
include
(
'foobar'
)
end
end
end
end
end
end
end
...
...
spec/tasks/gitlab/pages_rake_spec.rb
View file @
ee7f7597
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'rake_helper'
require
'rake_helper'
RSpec
.
describe
'gitlab:pages:migrate_legacy_storagerake task'
do
RSpec
.
describe
'gitlab:pages:migrate_legacy_storagerake task'
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/-/issues/300123'
do
before
(
:context
)
do
before
(
:context
)
do
Rake
.
application
.
rake_require
'tasks/gitlab/pages'
Rake
.
application
.
rake_require
'tasks/gitlab/pages'
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