diff options
Diffstat (limited to 'qa/qa/runtime')
-rw-r--r-- | qa/qa/runtime/address.rb | 9 | ||||
-rw-r--r-- | qa/qa/runtime/api/client.rb | 13 | ||||
-rw-r--r-- | qa/qa/runtime/api/request.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/browser.rb | 9 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 6 | ||||
-rw-r--r-- | qa/qa/runtime/feature.rb | 36 | ||||
-rw-r--r-- | qa/qa/runtime/key/base.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/key/ecdsa.rb | 3 | ||||
-rw-r--r-- | qa/qa/runtime/key/ed25519.rb | 3 | ||||
-rw-r--r-- | qa/qa/runtime/key/rsa.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/namespace.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/release.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/scenario.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/user.rb | 2 |
14 files changed, 80 insertions, 13 deletions
diff --git a/qa/qa/runtime/address.rb b/qa/qa/runtime/address.rb index ffad3974b02..98d042fb43a 100644 --- a/qa/qa/runtime/address.rb +++ b/qa/qa/runtime/address.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime class Address @@ -15,6 +17,13 @@ module QA @instance.to_s end end + + def self.valid?(value) + uri = URI.parse(value) + uri.is_a?(URI::HTTP) && !uri.host.nil? + rescue URI::InvalidURIError + false + end end end end diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb index aff84c89f0e..40a3bc85195 100644 --- a/qa/qa/runtime/api/client.rb +++ b/qa/qa/runtime/api/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'airborne' module QA @@ -14,7 +16,7 @@ module QA def personal_access_token @personal_access_token ||= begin - # you can set the environment variable PERSONAL_ACCESS_TOKEN + # you can set the environment variable GITLAB_QA_ACCESS_TOKEN # to use a specific access token rather than create one from the UI Runtime::Env.personal_access_token ||= create_personal_access_token end @@ -23,15 +25,12 @@ module QA private def create_personal_access_token - if @is_new_session - Runtime::Browser.visit(@address, Page::Main::Login) { do_create_personal_access_token } - else - do_create_personal_access_token - end + Runtime::Browser.visit(@address, Page::Main::Login) if @is_new_session + do_create_personal_access_token end def do_create_personal_access_token - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) Resource::PersonalAccessToken.fabricate!.access_token end end diff --git a/qa/qa/runtime/api/request.rb b/qa/qa/runtime/api/request.rb index ff9f0004524..310c1dfeeb4 100644 --- a/qa/qa/runtime/api/request.rb +++ b/qa/qa/runtime/api/request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime module API diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index 0b805b855ac..3bf4b3bbbfb 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/core' require 'capybara/rspec' require 'capybara-screenshot/rspec' @@ -31,6 +33,7 @@ module QA def self.visit(address, page = nil, &block) new.visit(address, page, &block) + page.validate_elements_present! end def self.configure! @@ -74,6 +77,9 @@ module QA # https://developers.google.com/web/updates/2017/04/headless-chrome#cli options.add_argument("disable-gpu") end + + # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252 + options.add_argument("disable-dev-shm-usage") if QA::Runtime::Env.running_in_ci? end # Use the same profile on QA runs if CHROME_REUSE_PROFILE is true. @@ -83,9 +89,6 @@ module QA options.add_argument("user-data-dir=#{qa_profile_dir}") end - # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252 - options.add_argument("disable-dev-shm-usage") if QA::Runtime::Env.running_in_ci? - selenium_options = { browser: QA::Runtime::Env.browser, clear_local_storage: true, diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index dd0ddbdbd6b..82510dfa03c 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -53,7 +53,7 @@ module QA # specifies token that can be used for the api def personal_access_token - @personal_access_token ||= ENV['PERSONAL_ACCESS_TOKEN'] + @personal_access_token ||= ENV['GITLAB_QA_ACCESS_TOKEN'] end def remote_grid @@ -136,6 +136,10 @@ module QA ENV['GITLAB_QA_PASSWORD_2'] end + def knapsack? + !!(ENV['KNAPSACK_GENERATE_REPORT'] || ENV['KNAPSACK_REPORT_PATH'] || ENV['KNAPSACK_TEST_FILE_PATTERN']) + end + def ldap_username @ldap_username ||= ENV['GITLAB_LDAP_USERNAME'] end diff --git a/qa/qa/runtime/feature.rb b/qa/qa/runtime/feature.rb new file mode 100644 index 00000000000..1b4ae7adbbe --- /dev/null +++ b/qa/qa/runtime/feature.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module QA + module Runtime + module Feature + extend self + extend Support::Api + + SetFeatureError = Class.new(RuntimeError) + + def enable(key) + QA::Runtime::Logger.info("Enabling feature: #{key}") + set_feature(key, true) + end + + def disable(key) + QA::Runtime::Logger.info("Disabling feature: #{key}") + set_feature(key, false) + end + + private + + def api_client + @api_client ||= Runtime::API::Client.new(:gitlab) + end + + def set_feature(key, value) + request = Runtime::API::Request.new(api_client, "/features/#{key}") + response = post(request.url, { value: value }) + unless response.code == QA::Support::Api::HTTP_STATUS_CREATED + raise SetFeatureError, "Setting feature flag #{key} to #{value} failed with `#{response}`." + end + end + end + end +end diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb index 67a992e2115..1281eceaff0 100644 --- a/qa/qa/runtime/key/base.rb +++ b/qa/qa/runtime/key/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime module Key diff --git a/qa/qa/runtime/key/ecdsa.rb b/qa/qa/runtime/key/ecdsa.rb index 20adad45913..46a1e5f54cf 100644 --- a/qa/qa/runtime/key/ecdsa.rb +++ b/qa/qa/runtime/key/ecdsa.rb @@ -1,4 +1,5 @@ -# rubocop:disable Naming/FileName +# frozen_string_literal: true + module QA module Runtime module Key diff --git a/qa/qa/runtime/key/ed25519.rb b/qa/qa/runtime/key/ed25519.rb index 63865c1cee5..3a3567d55da 100644 --- a/qa/qa/runtime/key/ed25519.rb +++ b/qa/qa/runtime/key/ed25519.rb @@ -1,4 +1,5 @@ -# rubocop:disable Naming/FileName +# frozen_string_literal: true + module QA module Runtime module Key diff --git a/qa/qa/runtime/key/rsa.rb b/qa/qa/runtime/key/rsa.rb index d94bde52325..d2bd72e5710 100644 --- a/qa/qa/runtime/key/rsa.rb +++ b/qa/qa/runtime/key/rsa.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime module Key diff --git a/qa/qa/runtime/namespace.rb b/qa/qa/runtime/namespace.rb index 9d7c1aea508..565bfd43f12 100644 --- a/qa/qa/runtime/namespace.rb +++ b/qa/qa/runtime/namespace.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime module Namespace diff --git a/qa/qa/runtime/release.rb b/qa/qa/runtime/release.rb index b1f7ec482c8..4f96e0cf44b 100644 --- a/qa/qa/runtime/release.rb +++ b/qa/qa/runtime/release.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime ## diff --git a/qa/qa/runtime/scenario.rb b/qa/qa/runtime/scenario.rb index 15d4112d347..5067322804b 100644 --- a/qa/qa/runtime/scenario.rb +++ b/qa/qa/runtime/scenario.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime ## diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb index e8bcb8a9f50..011e4a548a5 100644 --- a/qa/qa/runtime/user.rb +++ b/qa/qa/runtime/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Runtime module User |