Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-17 18:10:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-17 18:10:15 +0300
commit68c476dbd8a2c670aeeebffce8b63b554a3ac7f0 (patch)
treec46b90a5c131d8e8d7fb530f1b8f9390b8eb2613 /qa
parenta62238de7302e54edafa3407a2dc8ba1a5f96e4d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb1
-rw-r--r--qa/qa/resource/group.rb43
-rw-r--r--qa/qa/resource/group_base.rb74
-rw-r--r--qa/qa/resource/sandbox.rb38
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb39
5 files changed, 117 insertions, 78 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 446cf5d0b87..dc730e555dd 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -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'
diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb
index fb7236f9f4c..c7565871b0b 100644
--- a/qa/qa/resource/group.rb
+++ b/qa/qa/resource/group.rb
@@ -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
diff --git a/qa/qa/resource/group_base.rb b/qa/qa/resource/group_base.rb
new file mode 100644
index 00000000000..bdd442a1c8b
--- /dev/null
+++ b/qa/qa/resource/group_base.rb
@@ -0,0 +1,74 @@
+# 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
diff --git a/qa/qa/resource/sandbox.rb b/qa/qa/resource/sandbox.rb
index ae183d55d89..913fd6ab9ec 100644
--- a/qa/qa/resource/sandbox.rb
+++ b/qa/qa/resource/sandbox.rb
@@ -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 }
- response = 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 })
+ return 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
diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb
index 39e77346a0e..055300122d4 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb
@@ -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