diff options
author | Grzegorz Bizon | off until 20th June <grzegorz@gitlab.com> | 2018-06-12 10:34:55 +0000 |
---|---|---|
committer | Grzegorz Bizon | off until 20th June <grzegorz@gitlab.com> | 2018-06-12 10:34:55 +0000 |
commit | 9a4eadc87672de5b07b41df24810fbfe6c1f259e (patch) | |
tree | d79e3bd4d9b0f21696c44378c35c9152e7b3bfef /qa | |
parent | 9556030d10df455deaf16d65c46c5b0537c14bac (diff) | |
parent | 1dca45ff9670d0bd7cc0b2f3cbe23a8b4a809453 (diff) | |
download | gitlab-ce-9a4eadc87672de5b07b41df24810fbfe6c1f259e.tar.gz |
Merge branch 'qa-112-fix-auto-devops-cluster-spec' into 'master'
Qa 112 fix auto devops cluster spec
See merge request gitlab-org/gitlab-ce!19584
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/factory/repository/push.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 12 | ||||
-rw-r--r-- | qa/qa/service/kubernetes_cluster.rb | 17 | ||||
-rw-r--r-- | qa/qa/specs/features/project/auto_devops_spec.rb | 2 |
4 files changed, 28 insertions, 5 deletions
diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb index 7bb808652da..7c0d580c5ca 100644 --- a/qa/qa/factory/repository/push.rb +++ b/qa/qa/factory/repository/push.rb @@ -1,3 +1,5 @@ +require 'pathname' + module QA module Factory module Repository diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index fe432edfa2a..81d00d45753 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -46,6 +46,18 @@ module QA def sandbox_name ENV['GITLAB_SANDBOX_NAME'] end + + def gcloud_account_key + ENV.fetch("GCLOUD_ACCOUNT_KEY") + end + + def gcloud_account_email + ENV.fetch("GCLOUD_ACCOUNT_EMAIL") + end + + def gcloud_zone + ENV.fetch('GCLOUD_ZONE') + end end end end diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb index 604bc522983..7627c8c7ad9 100644 --- a/qa/qa/service/kubernetes_cluster.rb +++ b/qa/qa/service/kubernetes_cluster.rb @@ -20,9 +20,11 @@ module QA gcloud container clusters create #{cluster_name} --enable-legacy-authorization - --zone us-central1-a + --zone #{Runtime::Env.gcloud_zone} && gcloud container clusters - get-credentials #{cluster_name} + get-credentials + --zone #{Runtime::Env.gcloud_zone} + #{cluster_name} CMD @api_url = `kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}'` @@ -32,7 +34,12 @@ module QA end def remove! - shell("gcloud container clusters delete #{cluster_name} --quiet --async") + shell <<~CMD.tr("\n", ' ') + gcloud container clusters delete + --zone #{Runtime::Env.gcloud_zone} + #{cluster_name} + --quiet --async + CMD end private @@ -54,9 +61,9 @@ module QA def attempt_login_with_env_vars puts "No gcloud account. Attempting to login from env vars GCLOUD_ACCOUNT_EMAIL and GCLOUD_ACCOUNT_KEY." gcloud_account_key = Tempfile.new('gcloud-account-key') - gcloud_account_key.write(ENV.fetch("GCLOUD_ACCOUNT_KEY")) + gcloud_account_key.write(Runtime::Env.gcloud_account_key) gcloud_account_key.close - gcloud_account_email = ENV.fetch("GCLOUD_ACCOUNT_EMAIL") + gcloud_account_email = Runtime::Env.gcloud_account_email shell("gcloud auth activate-service-account #{gcloud_account_email} --key-file #{gcloud_account_key.path}") ensure gcloud_account_key && gcloud_account_key.unlink diff --git a/qa/qa/specs/features/project/auto_devops_spec.rb b/qa/qa/specs/features/project/auto_devops_spec.rb index f3f59d33457..202a847d1a5 100644 --- a/qa/qa/specs/features/project/auto_devops_spec.rb +++ b/qa/qa/specs/features/project/auto_devops_spec.rb @@ -1,3 +1,5 @@ +require 'pathname' + module QA feature 'Auto Devops', :kubernetes do after do |