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
8f6c47f0
Commit
8f6c47f0
authored
May 17, 2021
by
Andrejs Cunskis
Committed by
Dan Davison
May 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2E: Validate subgroup migration
parent
61e1a40a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
78 deletions
+117
-78
qa/qa.rb
qa/qa.rb
+1
-0
qa/qa/resource/group.rb
qa/qa/resource/group.rb
+17
-26
qa/qa/resource/group_base.rb
qa/qa/resource/group_base.rb
+74
-0
qa/qa/resource/sandbox.rb
qa/qa/resource/sandbox.rb
+7
-31
qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb
...tures/browser_ui/1_manage/group/bulk_import_group_spec.rb
+18
-21
No files found.
qa/qa.rb
View file @
8f6c47f0
...
...
@@ -65,6 +65,7 @@ module QA
autoload
:ApiFabricator
,
'qa/resource/api_fabricator'
autoload
:Base
,
'qa/resource/base'
autoload
:GroupBase
,
'qa/resource/group_base'
autoload
:Sandbox
,
'qa/resource/sandbox'
autoload
:Group
,
'qa/resource/group'
autoload
:Issue
,
'qa/resource/issue'
...
...
qa/qa/resource/group.rb
View file @
8f6c47f0
...
...
@@ -2,10 +2,8 @@
module
QA
module
Resource
class
Group
<
Base
include
Members
attr_accessor
:path
,
:description
class
Group
<
GroupBase
attr_accessor
:description
attribute
:sandbox
do
Sandbox
.
fabricate_via_api!
do
|
sandbox
|
...
...
@@ -13,10 +11,6 @@ module QA
end
end
attribute
:full_path
attribute
:id
attribute
:name
attribute
:runners_token
attribute
:require_two_factor_authentication
def
initialize
...
...
@@ -59,14 +53,6 @@ module QA
"/groups/
#{
CGI
.
escape
(
"
#{
sandbox
.
path
}
/
#{
path
}
"
)
}
"
end
def
api_put_path
"/groups/
#{
id
}
"
end
def
api_post_path
'/groups'
end
def
api_post_body
{
parent_id:
sandbox
.
id
,
...
...
@@ -77,17 +63,14 @@ module QA
}
end
def
api_delete_path
"/groups/
#{
id
}
"
end
def
set_require_two_factor_authentication
(
value
:)
put_body
=
{
require_two_factor_authentication:
value
}
response
=
put
Runtime
::
API
::
Request
.
new
(
api_client
,
api_put_path
).
url
,
put_body
return
if
response
.
code
==
HTTP_STATUS_OK
unless
response
.
code
==
HTTP_STATUS_OK
raise
ResourceUpdateFailedError
,
"Could not update require_two_factor_authentication to
#{
value
}
. Request returned (
#{
response
.
code
}
): `
#{
response
}
`."
end
raise
(
ResourceUpdateFailedError
,
<<~
ERROR
.
strip
)
Could not update require_two_factor_authentication to
#{
value
}
. Request returned (
#{
response
.
code
}
): `
#{
response
}
`.
ERROR
end
def
change_repository_storage
(
new_storage
)
...
...
@@ -95,12 +78,20 @@ module QA
response
=
post
Runtime
::
API
::
Request
.
new
(
api_client
,
"/groups/
#{
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
}
`."
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
)
}
wait_until
(
sleep_interval:
1
)
do
Runtime
::
API
::
RepositoryStorageMoves
.
has_status?
(
self
,
'finished'
,
new_storage
)
end
rescue
Support
::
Repeater
::
RepeaterConditionExceededError
raise
Runtime
::
API
::
RepositoryStorageMoves
::
RepositoryStorageMovesError
,
'Timed out while waiting for the group repository storage move to finish'
raise
(
Runtime
::
API
::
RepositoryStorageMoves
::
RepositoryStorageMovesError
,
'Timed out while waiting for the group repository storage move to finish'
)
end
end
end
...
...
qa/qa/resource/group_base.rb
0 → 100644
View file @
8f6c47f0
# frozen_string_literal: true
module
QA
module
Resource
# Base class for group classes Resource::Sandbox and Resource::Group
#
class
GroupBase
<
Base
include
Members
attr_accessor
:path
attribute
:id
attribute
:runners_token
attribute
:name
attribute
:full_path
# API post path
#
# @return [String]
def
api_post_path
'/groups'
end
# API put path
#
# @return [String]
def
api_put_path
"/groups/
#{
id
}
"
end
# API delete path
#
# @return [String]
def
api_delete_path
"/groups/
#{
id
}
"
end
# Object comparison
#
# @param [QA::Resource::GroupBase] other
# @return [Boolean]
def
==
(
other
)
other
.
is_a?
(
GroupBase
)
&&
comparable_group
==
other
.
comparable_group
end
# Override inspect for a better rspec failure diff output
#
# @return [String]
def
inspect
JSON
.
pretty_generate
(
comparable_group
)
end
protected
# Return subset of fields for comparing groups
#
# @return [Hash]
def
comparable_group
reload!
if
api_response
.
nil?
api_resource
.
except
(
:id
,
:web_url
,
:visibility
,
:full_name
,
:full_path
,
:created_at
,
:parent_id
,
:runners_token
)
end
end
end
end
qa/qa/resource/sandbox.rb
View file @
8f6c47f0
...
...
@@ -6,16 +6,7 @@ module QA
# Ensure we're in our sandbox namespace, either by navigating to it or by
# creating it if it doesn't yet exist.
#
class
Sandbox
<
Base
include
Members
attr_accessor
:path
attribute
:id
attribute
:runners_token
attribute
:name
attribute
:full_path
class
Sandbox
<
GroupBase
def
initialize
@path
=
Runtime
::
Namespace
.
sandbox_name
end
...
...
@@ -56,18 +47,6 @@ module QA
"/groups/
#{
path
}
"
end
def
api_members_path
"
#{
api_get_path
}
/members"
end
def
api_post_path
'/groups'
end
def
api_delete_path
"/groups/
#{
id
}
"
end
def
api_post_body
{
path:
path
,
...
...
@@ -76,17 +55,14 @@ module QA
}
end
def
api_put_path
"/groups/
#{
id
}
"
end
def
update_group_setting
(
group_setting
:,
value
:)
put_body
=
{
"
#{
group_setting
}
"
:
value
}
re
sponse
=
put
Runtime
::
API
::
Request
.
new
(
api_client
,
api_put_path
).
url
,
put_body
response
=
put
(
Runtime
::
API
::
Request
.
new
(
api_client
,
api_put_path
).
url
,
{
"
#{
group_setting
}
"
:
value
})
re
turn
if
response
.
code
==
HTTP_STATUS_OK
unless
response
.
code
==
HTTP_STATUS_OK
raise
ResourceUpdateFailedError
,
"Could not update
#{
group_setting
}
to
#{
value
}
. Request returned (
#{
response
.
code
}
): `
#{
response
}
`."
end
raise
(
ResourceUpdateFailedError
,
"Could not update
#{
group_setting
}
to
#{
value
}
. Request returned (
#{
response
.
code
}
): `
#{
response
}
`."
)
end
end
end
...
...
qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb
View file @
8f6c47f0
...
...
@@ -26,30 +26,27 @@ module QA
end
end
let!
(
:subgroup
)
do
Resource
::
Group
.
fabricate_via_api!
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
source_group
group
.
path
=
"subgroup-for-import-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
let
(
:imported_group
)
do
Resource
::
Group
.
new
.
tap
do
|
group
|
group
.
api_client
=
api_client
group
.
path
=
source_group
.
path
end
.
reload!
rescue
Resource
::
ApiFabricator
::
ResourceNotFoundError
nil
end
end
# Return subset of fields for comparing groups
#
# @param [Resource::Group, nil] group
# @return [Hash]
def
comparable_group
(
group
)
group
&
.
api_resource
&
.
except
(
:id
,
:web_url
,
:visibility
,
:full_name
,
:full_path
,
:created_at
,
:parent_id
,
:runners_token
)
let
(
:imported_subgroup
)
do
Resource
::
Group
.
new
.
tap
do
|
group
|
group
.
api_client
=
api_client
group
.
sandbox
=
imported_group
group
.
path
=
subgroup
.
path
end
end
def
staging?
...
...
@@ -73,15 +70,15 @@ module QA
it
(
'performs bulk group import from another gitlab instance'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785'
,
# https://gitlab.com/gitlab-org/gitlab/-/issues/330344
exclude:
{
job:
[
'ce:relative_url'
,
'ee:relative_url'
]
}
exclude:
{
job:
[
'ce:relative_url'
,
'ee:relative_url'
]
}
# https://gitlab.com/gitlab-org/gitlab/-/issues/330344
)
do
Page
::
Group
::
BulkImport
.
perform
do
|
import_page
|
import_page
.
import_group
(
source_group
.
path
,
sandbox
.
path
)
aggregate_failures
do
expect
(
import_page
).
to
have_imported_group
(
source_group
.
path
,
wait:
120
)
expect
(
comparable_group
(
imported_group
)).
to
eq
(
comparable_group
(
source_group
))
expect
(
imported_group
).
to
eq
(
source_group
)
expect
(
imported_subgroup
).
to
eq
(
subgroup
)
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