diff options
Diffstat (limited to 'qa/qa/resource')
-rw-r--r-- | qa/qa/resource/base.rb | 11 | ||||
-rw-r--r-- | qa/qa/resource/bulk_import_group.rb | 12 | ||||
-rw-r--r-- | qa/qa/resource/clusters/agent.rb | 13 | ||||
-rw-r--r-- | qa/qa/resource/clusters/agent_token.rb | 13 | ||||
-rw-r--r-- | qa/qa/resource/deploy_token.rb | 3 | ||||
-rw-r--r-- | qa/qa/resource/file.rb | 2 | ||||
-rw-r--r-- | qa/qa/resource/fork.rb | 8 | ||||
-rw-r--r-- | qa/qa/resource/issue.rb | 47 | ||||
-rw-r--r-- | qa/qa/resource/kubernetes_cluster/project_cluster.rb | 14 | ||||
-rw-r--r-- | qa/qa/resource/merge_request_from_fork.rb | 2 | ||||
-rw-r--r-- | qa/qa/resource/project.rb | 18 | ||||
-rw-r--r-- | qa/qa/resource/sandbox.rb | 16 |
12 files changed, 125 insertions, 34 deletions
diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index a7243b7ebc2..26a2a668cc1 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -77,17 +77,24 @@ module QA def log_fabrication(method, resource, parents, args) start = Time.now - yield.tap do + Support::FabricationTracker.start_fabrication + result = yield.tap do + fabrication_time = Time.now - start + + Support::FabricationTracker.save_fabrication(:"#{method}_fabrication", fabrication_time) Runtime::Logger.debug do msg = ["==#{'=' * parents.size}>"] msg << "Built a #{name}" msg << "as a dependency of #{parents.last}" if parents.any? msg << "via #{method}" - msg << "in #{Time.now - start} seconds" + msg << "in #{fabrication_time} seconds" msg.join(' ') end end + Support::FabricationTracker.finish_fabrication + + result end # Define custom attribute diff --git a/qa/qa/resource/bulk_import_group.rb b/qa/qa/resource/bulk_import_group.rb index 5380bb16f10..e8dc2d291b8 100644 --- a/qa/qa/resource/bulk_import_group.rb +++ b/qa/qa/resource/bulk_import_group.rb @@ -59,6 +59,9 @@ module QA } end + # Get import status + # + # @return [String] def import_status response = get(Runtime::API::Request.new(api_client, "/bulk_imports/#{import_id}").url) @@ -69,6 +72,15 @@ module QA parse_body(response)[:status] end + # Get import details + # + # @return [Array] + def import_details + response = get(Runtime::API::Request.new(api_client, "/bulk_imports/#{import_id}/entities").url) + + parse_body(response) + end + private def transform_api_resource(api_resource) diff --git a/qa/qa/resource/clusters/agent.rb b/qa/qa/resource/clusters/agent.rb index cad5a4c6b1d..ee5a292b9b3 100644 --- a/qa/qa/resource/clusters/agent.rb +++ b/qa/qa/resource/clusters/agent.rb @@ -19,13 +19,12 @@ module QA def fabricate! puts 'TODO: FABRICATE VIA UI' end - # TODO - # - # The UI for this model is not yet implemented. So far it can only be - # created through the GraphQL API - # def fabricate - # - # end + + def resource_web_url(resource) + super + rescue ResourceURLMissingError + # this particular resource does not expose a web_url property + end def api_get_path "gid://gitlab/Clusters::Agent/#{id}" diff --git a/qa/qa/resource/clusters/agent_token.rb b/qa/qa/resource/clusters/agent_token.rb index 3286f46cdb2..6d803b94564 100644 --- a/qa/qa/resource/clusters/agent_token.rb +++ b/qa/qa/resource/clusters/agent_token.rb @@ -13,13 +13,12 @@ module QA def fabricate! puts 'TODO: FABRICATE VIA UI' end - # TODO - # - # The UI for this model is not yet implemented. So far it can only be - # created through the GraphQL API - # def fabricate - # - # end + + def resource_web_url(resource) + super + rescue ResourceURLMissingError + # this particular resource does not expose a web_url property + end def api_get_path "gid://gitlab/Clusters::AgentToken/#{id}" diff --git a/qa/qa/resource/deploy_token.rb b/qa/qa/resource/deploy_token.rb index 151454c37b1..f5d3b87fc2b 100644 --- a/qa/qa/resource/deploy_token.rb +++ b/qa/qa/resource/deploy_token.rb @@ -4,6 +4,7 @@ module QA module Resource class DeployToken < Base attr_accessor :name, :expires_at + attr_writer :scopes attribute :username do Page::Project::Settings::Repository.perform do |repository_page| @@ -37,7 +38,7 @@ module QA setting.expand_deploy_tokens do |page| page.fill_token_name(name) page.fill_token_expires_at(expires_at) - page.fill_scopes(read_repository: true, read_package_registry: true, write_package_registry: true) + page.fill_scopes(@scopes) page.add_token end diff --git a/qa/qa/resource/file.rb b/qa/qa/resource/file.rb index 4ca180373f6..9b05c0cb456 100644 --- a/qa/qa/resource/file.rb +++ b/qa/qa/resource/file.rb @@ -67,7 +67,7 @@ module QA private def transform_api_resource(api_resource) - api_resource[:web_url] = "#{Runtime::Scenario.gitlab_address}/#{project.full_path}/-/tree/#{branch}/#{api_resource[:file_path]}" + api_resource[:web_url] = "#{Runtime::Scenario.gitlab_address}/#{project.full_path}/-/blob/#{branch}/#{api_resource[:file_path]}" api_resource end end diff --git a/qa/qa/resource/fork.rb b/qa/qa/resource/fork.rb index b3814011f2c..d0313670e8b 100644 --- a/qa/qa/resource/fork.rb +++ b/qa/qa/resource/fork.rb @@ -37,11 +37,9 @@ module QA namespace_path ||= user.name # Sign out as admin and sign is as the fork user - Page::Main::Menu.perform(&:sign_out) - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform do |login| - login.sign_in_using_credentials(user: user) - end + Flow::Login.sign_in(as: user) + + @api_client = Runtime::API::Client.new(:gitlab, is_new_session: false, user: user) upstream.visit! diff --git a/qa/qa/resource/issue.rb b/qa/qa/resource/issue.rb index 9214d4eff4a..344f177932f 100644 --- a/qa/qa/resource/issue.rb +++ b/qa/qa/resource/issue.rb @@ -9,6 +9,7 @@ module QA Project.fabricate! do |resource| resource.name = 'project-for-issues' resource.description = 'project for adding issues' + resource.api_client = api_client end end @@ -93,6 +94,52 @@ module QA attempts: attempts ) end + + # Object comparison + # + # @param [QA::Resource::Issue] other + # @return [Boolean] + def ==(other) + other.is_a?(Issue) && comparable_issue == other.comparable_issue + end + + # Override inspect for a better rspec failure diff output + # + # @return [String] + def inspect + JSON.pretty_generate(comparable_issue) + end + + protected + + # Return subset of fields for comparing issues + # + # @return [Hash] + def comparable_issue + reload! if api_response.nil? + + api_resource.slice( + :state, + :description, + :type, + :title, + :labels, + :milestone, + :upvotes, + :downvotes, + :merge_requests_count, + :user_notes_count, + :due_date, + :has_tasks, + :task_status, + :confidential, + :discussion_locked, + :issue_type, + :task_completion_status, + :closed_at, + :created_at + ) + end end end end diff --git a/qa/qa/resource/kubernetes_cluster/project_cluster.rb b/qa/qa/resource/kubernetes_cluster/project_cluster.rb index b3eba77fc46..0a63ff47694 100644 --- a/qa/qa/resource/kubernetes_cluster/project_cluster.rb +++ b/qa/qa/resource/kubernetes_cluster/project_cluster.rb @@ -13,8 +13,8 @@ module QA Resource::Project.fabricate! end - def ingress_ip - @ingress_ip ||= @cluster.fetch_external_ip_for_ingress + attribute :ingress_ip do + @cluster.fetch_external_ip_for_ingress end def fabricate! @@ -24,7 +24,7 @@ module QA &:go_to_infrastructure_kubernetes) Page::Project::Infrastructure::Kubernetes::Index.perform( - &:add_kubernetes_cluster) + &:connect_existing_cluster) Page::Project::Infrastructure::Kubernetes::Add.perform( &:add_existing_cluster) @@ -39,14 +39,10 @@ module QA end Page::Project::Infrastructure::Kubernetes::Show.perform do |show| - # We must wait a few seconds for permissions to be set up correctly for new cluster - sleep 25 - if @install_ingress - populate(:ingress_ip) + ingress_ip - show.open_details - show.set_domain("#{ingress_ip}.nip.io") + show.set_domain("#{@ingress_ip}.nip.io") show.save_domain end end diff --git a/qa/qa/resource/merge_request_from_fork.rb b/qa/qa/resource/merge_request_from_fork.rb index b0579cf37b8..512f3eb7bfc 100644 --- a/qa/qa/resource/merge_request_from_fork.rb +++ b/qa/qa/resource/merge_request_from_fork.rb @@ -6,7 +6,7 @@ module QA attr_accessor :fork_branch attribute :fork do - Fork.fabricate_via_api! + Fork.fabricate_via_browser_ui! end attribute :push do diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index 3f6a4eee5ac..864f3a14c3d 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -27,7 +27,9 @@ module QA :import_error attribute :group do - Group.fabricate! + Group.fabricate! do |group| + group.api_client = api_client + end end attribute :path_with_namespace do @@ -91,6 +93,7 @@ module QA new_page.choose_name(@name) new_page.add_description(@description) new_page.set_visibility(@visibility) + new_page.disable_initialize_with_sast new_page.disable_initialize_with_readme unless @initialize_with_readme new_page.create_new_project end @@ -214,6 +217,10 @@ module QA "#{api_get_path}/wikis" end + def api_push_rules_path + "#{api_get_path}/push_rule" + end + def api_post_body post_body = { name: name, @@ -358,6 +365,15 @@ module QA parse_body(response) end + def push_rules + response = get(request_url(api_push_rules_path)) + parse_body(response) + end + + def add_push_rules(rules) + api_post_to(api_push_rules_path, rules) + end + # Object comparison # # @param [QA::Resource::Project] other diff --git a/qa/qa/resource/sandbox.rb b/qa/qa/resource/sandbox.rb index b351d78a184..385e0fa4f7e 100644 --- a/qa/qa/resource/sandbox.rb +++ b/qa/qa/resource/sandbox.rb @@ -7,6 +7,17 @@ module QA # creating it if it doesn't yet exist. # class Sandbox < GroupBase + class << self + # Force top level group creation via UI if test is executed on dot_com environment + def fabricate!(*args, &prepare_block) + return fabricate_via_browser_ui!(*args, &prepare_block) if Specs::Helpers::ContextSelector.dot_com? + + fabricate_via_api!(*args, &prepare_block) + rescue NotImplementedError + fabricate_via_browser_ui!(*args, &prepare_block) + end + end + def initialize @path = Runtime::Namespace.sandbox_name end @@ -14,6 +25,8 @@ module QA alias_method :full_path, :path def fabricate! + Flow::Login.sign_in_unless_signed_in + Page::Main::Menu.perform(&:go_to_groups) Page::Dashboard::Groups.perform do |groups_page| @@ -23,10 +36,13 @@ module QA groups_page.click_new_group Page::Group::New.perform do |group| + group.click_create_group group.set_path(path) group.set_visibility('Public') group.create end + + @id = Page::Group::Show.perform(&:group_id) end end end |