diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 03:07:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 03:07:29 +0000 |
commit | f698fdbdcb4482adf2b5ead68be09355ae24e322 (patch) | |
tree | 9f7b9dd81dbd81f08682ace1467e975c24bc5c42 /qa | |
parent | 6af29c941af34330dd4f9ed9c513823d8067243b (diff) | |
download | gitlab-ce-f698fdbdcb4482adf2b5ead68be09355ae24e322.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/flow/login.rb | 20 | ||||
-rw-r--r-- | qa/qa/page/project/job/show.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 2 | ||||
-rw-r--r-- | qa/qa/service/cluster_provider/gcloud.rb | 36 |
4 files changed, 44 insertions, 16 deletions
diff --git a/qa/qa/flow/login.rb b/qa/qa/flow/login.rb index d84dfaa9377..5505fabd4ae 100644 --- a/qa/qa/flow/login.rb +++ b/qa/qa/flow/login.rb @@ -5,33 +5,33 @@ module QA module Login module_function - def while_signed_in(as: nil) + def while_signed_in(as: nil, address: :gitlab) Page::Main::Menu.perform(&:sign_out_if_signed_in) - sign_in(as: as) + sign_in(as: as, address: address) yield Page::Main::Menu.perform(&:sign_out) end - def while_signed_in_as_admin - while_signed_in(as: Runtime::User.admin) do + def while_signed_in_as_admin(address: :gitlab) + while_signed_in(as: Runtime::User.admin, address: address) do yield end end - def sign_in(as: nil) - Runtime::Browser.visit(:gitlab, Page::Main::Login) + def sign_in(as: nil, address: :gitlab) + Runtime::Browser.visit(address, Page::Main::Login) Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: as) } end - def sign_in_as_admin - sign_in(as: Runtime::User.admin) + def sign_in_as_admin(address: :gitlab) + sign_in(as: Runtime::User.admin, address: address) end - def sign_in_unless_signed_in(as: nil) - sign_in(as: as) unless Page::Main::Menu.perform(&:signed_in?) + def sign_in_unless_signed_in(as: nil, address: :gitlab) + sign_in(as: as, address: address) unless Page::Main::Menu.perform(&:signed_in?) end end end diff --git a/qa/qa/page/project/job/show.rb b/qa/qa/page/project/job/show.rb index cf847710024..a1a5b3c296e 100644 --- a/qa/qa/page/project/job/show.rb +++ b/qa/qa/page/project/job/show.rb @@ -27,7 +27,7 @@ module QA::Page wait(reload: false, max: wait, interval: 1) do result = find_element(:build_trace).text - !result.empty? + result.include?('Job') end result diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 9cf72457fa6..184ccd3ef07 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -226,7 +226,7 @@ module QA end def gcloud_region - ENV.fetch('GCLOUD_REGION') + ENV['GCLOUD_REGION'] end def gcloud_num_nodes diff --git a/qa/qa/service/cluster_provider/gcloud.rb b/qa/qa/service/cluster_provider/gcloud.rb index 9c82151666c..f0fb5eee6e3 100644 --- a/qa/qa/service/cluster_provider/gcloud.rb +++ b/qa/qa/service/cluster_provider/gcloud.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'active_support/inflector' + module QA module Service module ClusterProvider @@ -8,8 +10,22 @@ module QA find_executable('gcloud') || raise("You must first install `gcloud` executable to run these tests.") end + def initialize(rbac:) + super(rbac: rbac) + @attempts = 0 + @available_regions = %w( + asia-east1 asia-east2 + asia-northeast1 asia-south1 + asia-southeast1 australia-southeast1 + europe-west1 europe-west2 europe-west4 + northamerica-northeast1 southamerica-east1 + us-central1 us-east1 us-east4 + us-west1 us-west2 + ) + end + def set_credentials(admin_user) - master_auth = JSON.parse(`gcloud container clusters describe #{cluster_name} --region #{Runtime::Env.gcloud_region} --format 'json(masterAuth.username, masterAuth.password)'`) + master_auth = JSON.parse(`gcloud container clusters describe #{cluster_name} --region #{@region} --format 'json(masterAuth.username, masterAuth.password)'`) shell <<~CMD.tr("\n", ' ') kubectl config set-credentials #{admin_user} @@ -58,29 +74,41 @@ module QA end def create_cluster + @region = get_region + shell <<~CMD.tr("\n", ' ') gcloud container clusters create #{cluster_name} #{auth_options} --enable-basic-auth - --region #{Runtime::Env.gcloud_region} + --region #{@region} --disk-size 10GB --num-nodes #{Runtime::Env.gcloud_num_nodes} && gcloud container clusters get-credentials - --region #{Runtime::Env.gcloud_region} + --region #{@region} #{cluster_name} CMD + rescue QA::Service::Shellout::CommandError + @attempts += 1 + + retry unless @attempts > 1 + + raise $!, "Tried and failed to provision the cluster #{@attempts} #{"time".pluralize(@attempts)}.", $!.backtrace end def delete_cluster shell <<~CMD.tr("\n", ' ') gcloud container clusters delete - --region #{Runtime::Env.gcloud_region} + --region #{@region} #{cluster_name} --quiet --async CMD end + + def get_region + Runtime::Env.gcloud_region || @available_regions.delete(@available_regions.sample) + end end end end |