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
9a1884f2
Commit
9a1884f2
authored
Feb 23, 2021
by
Anastasia McDonald
Committed by
Sanad Liaquat
Feb 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add E2E for snippet repository storage move
Final version
parent
579dc9d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
5 deletions
+90
-5
qa/qa/resource/snippet.rb
qa/qa/resource/snippet.rb
+27
-0
qa/qa/runtime/api/repository_storage_moves.rb
qa/qa/runtime/api/repository_storage_moves.rb
+17
-5
qa/qa/specs/features/api/3_create/snippet/snippet_repository_storage_move_spec.rb
.../3_create/snippet/snippet_repository_storage_move_spec.rb
+45
-0
qa/qa/support/api.rb
qa/qa/support/api.rb
+1
-0
No files found.
qa/qa/resource/snippet.rb
View file @
9a1884f2
...
...
@@ -6,6 +6,7 @@ module QA
attr_accessor
:title
,
:description
,
:file_content
,
:visibility
,
:file_name
attribute
:id
attribute
:http_url_to_repo
def
initialize
@title
=
'New snippet title'
...
...
@@ -53,6 +54,10 @@ module QA
'/snippets'
end
def
api_put_path
"/snippets/
#{
id
}
"
end
def
api_post_body
{
title:
title
,
...
...
@@ -72,6 +77,28 @@ module QA
file
[
:file_path
]
=
file
.
delete
(
:name
)
end
end
def
has_file?
(
file_path
)
response
=
get
Runtime
::
API
::
Request
.
new
(
api_client
,
api_get_path
).
url
raise
ResourceNotFoundError
,
"Request returned (
#{
response
.
code
}
): `
#{
response
}
`."
if
response
.
code
==
HTTP_STATUS_NOT_FOUND
file_output
=
parse_body
(
response
)[
:files
]
file_output
.
any?
{
|
file
|
file
[
:path
]
==
file_path
}
end
def
change_repository_storage
(
new_storage
)
post_body
=
{
destination_storage_name:
new_storage
}
response
=
post
Runtime
::
API
::
Request
.
new
(
api_client
,
"/snippets/
#{
id
}
/repository_storage_moves"
).
url
,
post_body
unless
response
.
code
.
between?
(
200
,
300
)
raise
ResourceUpdateFailedError
,
"Could not change repository storage to
#{
new_storage
}
. Request returned (
#{
response
.
code
}
): `
#{
response
}
`."
end
wait_until
(
sleep_interval:
1
)
{
Runtime
::
API
::
RepositoryStorageMoves
.
has_status?
(
self
,
'finished'
,
new_storage
)
}
rescue
Support
::
Repeater
::
RepeaterConditionExceededError
raise
Runtime
::
API
::
RepositoryStorageMoves
::
RepositoryStorageMovesError
,
'Timed out while waiting for the snippet repository storage move to finish'
end
end
end
end
qa/qa/runtime/api/repository_storage_moves.rb
View file @
9a1884f2
...
...
@@ -9,9 +9,9 @@ module QA
RepositoryStorageMovesError
=
Class
.
new
(
RuntimeError
)
def
has_status?
(
project
,
status
,
destination_storage
=
Env
.
additional_repository_storage
)
find_any
do
|
move
|
next
unless
move
[
:project
][
:path_with_namespace
]
==
project
.
path_with_namespace
def
has_status?
(
resource
,
status
,
destination_storage
=
Env
.
additional_repository_storage
)
find_any
(
resource
)
do
|
move
|
next
unless
resource_equals?
(
resource
,
move
)
QA
::
Runtime
::
Logger
.
debug
(
"Move data:
#{
move
}
"
)
...
...
@@ -20,16 +20,28 @@ module QA
end
end
def
find_any
def
find_any
(
resource
)
Logger
.
debug
(
'Getting repository storage moves'
)
Support
::
Waiter
.
wait_until
do
with_paginated_response_body
(
Request
.
new
(
api_client
,
'/project_repository_storage_moves'
,
per_page:
'100'
).
url
)
do
|
page
|
with_paginated_response_body
(
Request
.
new
(
api_client
,
"/
#{
resource_name
(
resource
)
}
_repository_storage_moves"
,
per_page:
'100'
).
url
)
do
|
page
|
break
true
if
page
.
any?
{
|
item
|
yield
item
}
end
end
end
def
resource_equals?
(
resource
,
move
)
if
resource
.
class
.
name
.
include?
(
'Snippet'
)
move
[
:snippet
][
:id
]
==
resource
.
id
else
move
[
:project
][
:path_with_namespace
]
==
resource
.
path_with_namespace
end
end
def
resource_name
(
resource
)
resource
.
class
.
name
.
split
(
'::'
).
last
.
downcase
end
private
def
api_client
...
...
qa/qa/specs/features/api/3_create/snippet/snippet_repository_storage_move_spec.rb
0 → 100644
View file @
9a1884f2
# frozen_string_literal: true
module
QA
RSpec
.
describe
'Create'
do
describe
'Snippet repository storage'
,
:requires_admin
,
:orchestrated
,
:repository_storage
do
let
(
:source_storage
)
{
{
type: :gitaly
,
name:
'default'
}
}
let
(
:destination_storage
)
{
{
type: :gitaly
,
name:
QA
::
Runtime
::
Env
.
additional_repository_storage
}
}
let
(
:snippet
)
do
Resource
::
Snippet
.
fabricate_via_api!
do
|
snippet
|
snippet
.
title
=
'Snippet to move storage of'
snippet
.
file_name
=
'original_file'
snippet
.
file_content
=
'Original file content'
snippet
.
api_client
=
Runtime
::
API
::
Client
.
as_admin
end
end
praefect_manager
=
Service
::
PraefectManager
.
new
before
do
praefect_manager
.
gitlab
=
'gitlab'
end
it
'moves snippet repository from one Gitaly storage to another'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1700'
do
expect
(
snippet
).
to
have_file
(
'original_file'
)
expect
{
snippet
.
change_repository_storage
(
destination_storage
[
:name
])
}.
not_to
raise_error
expect
{
praefect_manager
.
verify_storage_move
(
source_storage
,
destination_storage
)
}.
not_to
raise_error
# verifies you can push commits to the moved snippet
Resource
::
Repository
::
Push
.
fabricate!
do
|
push
|
push
.
repository_http_uri
=
snippet
.
http_url_to_repo
push
.
file_name
=
'new_file'
push
.
file_content
=
'new file content'
push
.
commit_message
=
'Adding a new snippet file'
push
.
new_branch
=
false
end
aggregate_failures
do
expect
(
snippet
).
to
have_file
(
'original_file'
)
expect
(
snippet
).
to
have_file
(
'new_file'
)
end
end
end
end
end
qa/qa/support/api.rb
View file @
9a1884f2
...
...
@@ -9,6 +9,7 @@ module QA
HTTP_STATUS_CREATED
=
201
HTTP_STATUS_NO_CONTENT
=
204
HTTP_STATUS_ACCEPTED
=
202
HTTP_STATUS_NOT_FOUND
=
404
HTTP_STATUS_SERVER_ERROR
=
500
def
post
(
url
,
payload
,
args
=
{})
...
...
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