diff --git a/docs/run_qa_against_gdk.md b/docs/run_qa_against_gdk.md index 182b2d3af2e1e260887be4f8b5c4b3f870b3c40d..43abf13a132caf84c1e29af1b4697876deb2f3bc 100644 --- a/docs/run_qa_against_gdk.md +++ b/docs/run_qa_against_gdk.md @@ -47,7 +47,38 @@ $ bundle exec bin/qa QA::EE::Scenario::Test::Geo --primary-address http://localh $ CHROME_HEADLESS=0 bundle exec bin/qa QA::EE::Scenario::Test::Geo --primary-address http://localhost:3001 --secondary-address http://localhost:3002 --primary-name primary --secondary-name secondary --without-setup ``` -### QA Tool support on macOS +## Run Kubernetes QA tests against your GDK setup + +**Prerequisites**: +To run the Kubernetes QA tests locally from your machine, +you must have access to the [QA Tunnel] and follow the instructions +[found here](https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc%2Fhowto%2Fauto_devops.md) +(employees only) + +If you have [k3d] installed on your local machine - + +```bash +# from the gitlab/qa directory... +$ QA_K3D_HOSTNAME=127.0.0.1 bundle exec bin/qa Test::Integration::Kubernetes https://.qa-tunnel.gitlab.info -- qa/specs/features/browser_ui/7_configure/ +``` + +If you do not have [k3d] installed and would like to run it orchestrated, [see Orchestrated](#orchestrated) + +### Orchestrated + +1. If you are making local changes to the tests, build a QA image + +```bash +$ docker build -t gitlab/gitlab-ce-qa:your-custom-tag --file ./qa/Dockerfile ./ +``` + +2. From the [`gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa) project, run: + +```bash +$ exe/gitlab-qa Test::Instance::Any gitlab/gitlab-ce-qa:your-custom-tag https://.qa-tunnel.gitlab.info -- qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb --tag kubernetes +``` + +## QA Tool support on macOS Most of our development for GitLab is done on macOS. This brings some challenges as Docker on macOS doesn't have feature parity with it's Linux conterpart. @@ -148,6 +179,7 @@ You should be able to use your navigator and point it to `http://gitlab-primary. [Docker bridge issue]: https://github.com/moby/moby/issues/22753#issuecomment-253534261 [dnsdock]: https://github.com/aacebedo/dnsdock [Git protocol]: https://docs.gitlab.com/ee/administration/git_protocol.html#doc-nav +[k3d]: https://github.com/rancher/k3d ---- diff --git a/lib/gitlab/qa/component/specs.rb b/lib/gitlab/qa/component/specs.rb index 44e8a8305d6ec5e646e057e9827d7ecb1216d216..6b2302a4c1f9bc9d2b8fffb48766bacff67999d9 100644 --- a/lib/gitlab/qa/component/specs.rb +++ b/lib/gitlab/qa/component/specs.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'securerandom' module Gitlab @@ -31,8 +33,6 @@ module Gitlab puts "Running test suite `#{suite}` for #{release.project_name}" - name = "#{release.project_name}-qa-#{SecureRandom.hex(4)}" - @docker.run(release.qa_image, release.qa_tag, suite, *args) do |command| command << "-t --rm --net=#{network || 'bridge'}" @@ -40,6 +40,9 @@ module Gitlab command.env(key, value) end + # set k3d hostname to listen on + command.env('QA_K3D_HOSTNAME', hostname) + command.volume('/var/run/docker.sock', '/var/run/docker.sock') command.volume(File.join(Runtime::Env.host_artifacts_dir, name), File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp')) @@ -50,6 +53,14 @@ module Gitlab command.name(name) end end + + def name + "#{release.project_name}-qa-#{SecureRandom.hex(4)}" + end + + def hostname + "#{name}.#{network}" + end end end end diff --git a/lib/gitlab/qa/runtime/env.rb b/lib/gitlab/qa/runtime/env.rb index dec03e2d97a254a1b9be30188d23f8d5c60f0c7c..0adec49ea35e54fd13d31982176c397a222622a8 100644 --- a/lib/gitlab/qa/runtime/env.rb +++ b/lib/gitlab/qa/runtime/env.rb @@ -39,6 +39,7 @@ module Gitlab 'QA_DEBUG' => :qa_debug, 'QA_LOG_PATH' => :qa_log_path, 'QA_CAN_TEST_GIT_PROTOCOL_V2' => :qa_can_test_git_protocol_v2, + 'QA_K3D_HOSTNAME' => :k3d_hostname, 'GITLAB_QA_USERNAME_1' => :gitlab_qa_username_1, 'GITLAB_QA_PASSWORD_1' => :gitlab_qa_password_1, 'GITLAB_QA_USERNAME_2' => :gitlab_qa_username_2, @@ -130,12 +131,6 @@ module Gitlab end end - def require_kubernetes_environment! - %w[GCLOUD_ACCOUNT_EMAIL GCLOUD_ACCOUNT_KEY CLOUDSDK_CORE_PROJECT GCLOUD_REGION].each do |env_key| - raise ArgumentError, "Environment variable #{env_key} must be set to run kubernetes specs" unless ENV.key?(env_key) - end - end - def skip_pull? (ENV['QA_SKIP_PULL'] =~ /^(false|no|0)$/i) != 0 end diff --git a/lib/gitlab/qa/scenario/test/integration/kubernetes.rb b/lib/gitlab/qa/scenario/test/integration/kubernetes.rb index e6443715da92682c86e9a3f4069bc0ff5845d4c7..95fd67192129bf339fa93c2ea8254d37fbcd4bdd 100644 --- a/lib/gitlab/qa/scenario/test/integration/kubernetes.rb +++ b/lib/gitlab/qa/scenario/test/integration/kubernetes.rb @@ -6,10 +6,7 @@ module Gitlab module Test module Integration class Kubernetes < Scenario::Template - # rubocop:disable Metrics/AbcSize def perform(release, *rspec_args) - Runtime::Env.require_kubernetes_environment! - Component::Gitlab.perform do |gitlab| gitlab.release = release gitlab.network = 'test' @@ -47,7 +44,6 @@ module Gitlab end end end - # rubocop:enable Metrics/AbcSize end end end