summaryrefslogtreecommitdiff
path: root/qa/qa/resource/group.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/resource/group.rb')
-rw-r--r--qa/qa/resource/group.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb
index c7565871b0b..0f06113f85b 100644
--- a/qa/qa/resource/group.rb
+++ b/qa/qa/resource/group.rb
@@ -5,6 +5,10 @@ module QA
class Group < GroupBase
attr_accessor :description
+ attribute :full_path do
+ determine_full_path
+ end
+
attribute :sandbox do
Sandbox.fabricate_via_api! do |sandbox|
sandbox.api_client = api_client
@@ -29,6 +33,7 @@ module QA
group_show.go_to_new_subgroup
Page::Group::New.perform do |group_new|
+ group_new.click_create_group
group_new.set_path(path)
group_new.set_visibility('Public')
group_new.create
@@ -47,10 +52,16 @@ module QA
resource_web_url(api_get)
rescue ResourceNotFoundError
super
+
+ Support::Retrier.retry_on_exception(sleep_interval: 5) do
+ resource = resource_web_url(api_get)
+ populate(:runners_token)
+ resource
+ end
end
def api_get_path
- "/groups/#{CGI.escape("#{sandbox.path}/#{path}")}"
+ "/groups/#{CGI.escape(determine_full_path)}"
end
def api_post_body
@@ -93,6 +104,32 @@ module QA
'Timed out while waiting for the group repository storage move to finish'
)
end
+
+ private
+
+ # Determine the path up to the root group.
+ #
+ # This is equivalent to the full_path API attribute. We can't use the full_path attribute
+ # because it depends on the group being fabricated first, and we use this method to help
+ # _check_ if the group exists.
+ #
+ # @param [QA::Resource::GroupBase] sandbox the immediate parent group of this group
+ # @param [String] path the path name of this group (the leaf, not the full path)
+ # @return [String]
+ def determine_full_path
+ determine_parent_group_paths(sandbox, path)
+ end
+
+ # Recursively traverse the parents of this group up to the root group.
+ #
+ # @param [QA::Resource::GroupBase] parent the immediate parent group
+ # @param [String] path the path traversed so far
+ # @return [String]
+ def determine_parent_group_paths(parent, path)
+ return "#{parent.path}/#{path}" unless parent.respond_to?(:sandbox)
+
+ determine_parent_group_paths(parent.sandbox, "#{parent.path}/#{path}")
+ end
end
end
end