diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-29 18:09:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-29 18:09:58 +0300 |
commit | 647de7e6fd971d435396cc8730a2d162240e3d7c (patch) | |
tree | 3e2fc4e6e8027375d6061f2ad4badda04ef04476 /qa | |
parent | 4233d3aa86fe94e6288279aa55d42ed95bfe753c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
7 files changed, 121 insertions, 75 deletions
@@ -75,7 +75,6 @@ module QA autoload :CiVariable, 'qa/resource/ci_variable' autoload :Runner, 'qa/resource/runner' autoload :PersonalAccessToken, 'qa/resource/personal_access_token' - autoload :KubernetesCluster, 'qa/resource/kubernetes_cluster' autoload :User, 'qa/resource/user' autoload :ProjectMilestone, 'qa/resource/project_milestone' autoload :Members, 'qa/resource/members' @@ -89,6 +88,11 @@ module QA autoload :UserGPG, 'qa/resource/user_gpg' autoload :Visibility, 'qa/resource/visibility' + module KubernetesCluster + autoload :Base, 'qa/resource/kubernetes_cluster/base' + autoload :ProjectCluster, 'qa/resource/kubernetes_cluster/project_cluster' + end + module Events autoload :Base, 'qa/resource/events/base' autoload :Project, 'qa/resource/events/project' diff --git a/qa/qa/resource/kubernetes_cluster.rb b/qa/qa/resource/kubernetes_cluster.rb deleted file mode 100644 index 7306acfe2a4..00000000000 --- a/qa/qa/resource/kubernetes_cluster.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true - -require 'securerandom' - -module QA - module Resource - class KubernetesCluster < Base - attr_writer :project, :cluster, - :install_helm_tiller, :install_ingress, :install_prometheus, :install_runner, :domain - - attribute :ingress_ip do - Page::Project::Operations::Kubernetes::Show.perform(&:ingress_ip) - end - - def fabricate! - @project.visit! - - Page::Project::Menu.perform( - &:go_to_operations_kubernetes) - - Page::Project::Operations::Kubernetes::Index.perform( - &:add_kubernetes_cluster) - - Page::Project::Operations::Kubernetes::Add.perform( - &:add_existing_cluster) - - Page::Project::Operations::Kubernetes::AddExisting.perform do |cluster_page| - cluster_page.set_cluster_name(@cluster.cluster_name) - cluster_page.set_api_url(@cluster.api_url) - cluster_page.set_ca_certificate(@cluster.ca_certificate) - cluster_page.set_token(@cluster.token) - cluster_page.uncheck_rbac! unless @cluster.rbac - cluster_page.add_cluster! - end - - if @install_helm_tiller - Page::Project::Operations::Kubernetes::Show.perform do |show| - # We must wait a few seconds for permissions to be set up correctly for new cluster - sleep 10 - - # Open applications tab - show.open_applications - - # Helm must be installed before everything else - show.install!(:helm) - show.await_installed(:helm) - - show.install!(:ingress) if @install_ingress - show.install!(:prometheus) if @install_prometheus - show.install!(:runner) if @install_runner - - show.await_installed(:ingress) if @install_ingress - show.await_installed(:prometheus) if @install_prometheus - show.await_installed(:runner) if @install_runner - - if @install_ingress - populate(:ingress_ip) - - show.open_details - show.set_domain("#{ingress_ip}.nip.io") - show.save_domain - end - end - end - end - end - end -end diff --git a/qa/qa/resource/kubernetes_cluster/base.rb b/qa/qa/resource/kubernetes_cluster/base.rb new file mode 100644 index 00000000000..38bca48be17 --- /dev/null +++ b/qa/qa/resource/kubernetes_cluster/base.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'securerandom' + +module QA + module Resource + module KubernetesCluster + class Base < Resource::Base + attr_writer :add_name_uuid + + attribute :id + attribute :name + attribute :domain + attribute :enabled + attribute :managed + attribute :management_project_id + + attribute :api_url + attribute :token + attribute :ca_cert + attribute :namespace + + attribute :authorization_type + attribute :environment_scope + + def initialize + @add_name_uuid = true + @enabled = true + @managed = true + @authorization_type = :rbac + @environment_scope = :* + end + + def name=(new_name) + @name = @add_name_uuid ? "#{new_name}-#{SecureRandom.hex(5)}" : new_name + end + end + end + end +end diff --git a/qa/qa/resource/kubernetes_cluster/project_cluster.rb b/qa/qa/resource/kubernetes_cluster/project_cluster.rb new file mode 100644 index 00000000000..5c61cc29236 --- /dev/null +++ b/qa/qa/resource/kubernetes_cluster/project_cluster.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +module QA + module Resource + module KubernetesCluster + class ProjectCluster < Base + attr_writer :cluster, + :install_helm_tiller, :install_ingress, :install_prometheus, :install_runner, :domain + + attribute :project do + Resource::Project.fabricate! + end + + attribute :ingress_ip do + Page::Project::Operations::Kubernetes::Show.perform(&:ingress_ip) + end + + def fabricate! + project.visit! + + Page::Project::Menu.perform( + &:go_to_operations_kubernetes) + + Page::Project::Operations::Kubernetes::Index.perform( + &:add_kubernetes_cluster) + + Page::Project::Operations::Kubernetes::Add.perform( + &:add_existing_cluster) + + Page::Project::Operations::Kubernetes::AddExisting.perform do |cluster_page| + cluster_page.set_cluster_name(@cluster.cluster_name) + cluster_page.set_api_url(@cluster.api_url) + cluster_page.set_ca_certificate(@cluster.ca_certificate) + cluster_page.set_token(@cluster.token) + cluster_page.uncheck_rbac! unless @cluster.rbac + cluster_page.add_cluster! + end + + if @install_helm_tiller + Page::Project::Operations::Kubernetes::Show.perform do |show| + # We must wait a few seconds for permissions to be set up correctly for new cluster + sleep 10 + + # Open applications tab + show.open_applications + + # Helm must be installed before everything else + show.install!(:helm) + show.await_installed(:helm) + + show.install!(:ingress) if @install_ingress + show.install!(:prometheus) if @install_prometheus + show.install!(:runner) if @install_runner + + show.await_installed(:ingress) if @install_ingress + show.await_installed(:prometheus) if @install_prometheus + show.await_installed(:runner) if @install_runner + + if @install_ingress + populate(:ingress_ip) + + show.open_details + show.set_domain("#{ingress_ip}.nip.io") + show.save_domain + end + end + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb index 0a52b01af03..292fc40bec4 100644 --- a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb +++ b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb @@ -35,7 +35,7 @@ module QA end # Connect K8s cluster - Resource::KubernetesCluster.fabricate! do |k8s_cluster| + Resource::KubernetesCluster::ProjectCluster.fabricate! do |k8s_cluster| k8s_cluster.project = project k8s_cluster.cluster = cluster k8s_cluster.install_helm_tiller = true diff --git a/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb index 9a52109c8cb..ab6c08f8ec5 100644 --- a/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb +++ b/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb @@ -21,12 +21,10 @@ module QA end it 'can create and associate a project cluster', :smoke do - Resource::KubernetesCluster.fabricate_via_browser_ui! do |k8s_cluster| + Resource::KubernetesCluster::ProjectCluster.fabricate_via_browser_ui! do |k8s_cluster| k8s_cluster.project = project k8s_cluster.cluster = cluster - end - - project.visit! + end.project.visit! Page::Project::Menu.perform(&:go_to_operations_kubernetes) diff --git a/qa/qa/specs/features/browser_ui/8_monitor/apm/dashboards_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/apm/dashboards_spec.rb index f7463c69db1..465b3530d00 100644 --- a/qa/qa/specs/features/browser_ui/8_monitor/apm/dashboards_spec.rb +++ b/qa/qa/specs/features/browser_ui/8_monitor/apm/dashboards_spec.rb @@ -69,7 +69,7 @@ module QA project.description = 'Cluster with Prometheus' end - @cluster_props = Resource::KubernetesCluster.fabricate_via_browser_ui! do |cluster_settings| + @cluster_props = Resource::KubernetesCluster::ProjectCluster.fabricate_via_browser_ui! do |cluster_settings| cluster_settings.project = @project cluster_settings.cluster = @cluster cluster_settings.install_helm_tiller = true |