Module: Gitlab::QA::Runtime::Env
Constant Summary collapse
- ENV_VARIABLES =
{ 'QA_REMOTE_GRID' => :remote_grid, 'QA_REMOTE_GRID_USERNAME' => :remote_grid_username, 'QA_REMOTE_GRID_ACCESS_KEY' => :remote_grid_access_key, 'QA_REMOTE_GRID_PROTOCOL' => :remote_grid_protocol, 'QA_BROWSER' => :browser, 'GITLAB_API_BASE' => :api_base, 'GITLAB_ADMIN_USERNAME' => :admin_username, 'GITLAB_ADMIN_PASSWORD' => :admin_password, 'GITLAB_USERNAME' => :user_username, 'GITLAB_PASSWORD' => :user_password, 'GITLAB_LDAP_USERNAME' => :ldap_username, 'GITLAB_LDAP_PASSWORD' => :ldap_password, 'GITLAB_FORKER_USERNAME' => :forker_username, 'GITLAB_FORKER_PASSWORD' => :forker_password, 'GITLAB_USER_TYPE' => :user_type, 'GITLAB_SANDBOX_NAME' => :gitlab_sandbox_name, 'GITLAB_QA_ADMIN_ACCESS_TOKEN' => :qa_admin_access_token, 'GITHUB_ACCESS_TOKEN' => :github_access_token, 'GITLAB_URL' => :gitlab_url, 'SIMPLE_SAML_HOSTNAME' => :simple_saml_hostname, 'SIMPLE_SAML_FINGERPRINT' => :simple_saml_fingerprint, 'ACCEPT_INSECURE_CERTS' => :accept_insecure_certs, 'EE_LICENSE' => :ee_license, 'GCLOUD_ACCOUNT_EMAIL' => :gcloud_account_email, 'GCLOUD_ACCOUNT_KEY' => :gcloud_account_key, 'CLOUDSDK_CORE_PROJECT' => :cloudsdk_core_project, 'GCLOUD_REGION' => :gcloud_region, 'SIGNUP_DISABLED' => :signup_disabled, 'QA_ADDITIONAL_REPOSITORY_STORAGE' => :qa_additional_repository_storage, 'QA_COOKIES' => :qa_cookie, 'QA_DEBUG' => :qa_debug, 'QA_LOG_PATH' => :qa_log_path, 'QA_CAN_TEST_GIT_PROTOCOL_V2' => :qa_can_test_git_protocol_v2, 'QA_DISABLE_RSPEC_RETRY' => :qa_disable_rspec_retry, 'QA_SIMULATE_SLOW_CONNECTION' => :qa_simulate_slow_connection, 'QA_SLOW_CONNECTION_LATENCY_MS' => :qa_slow_connection_latency_ms, 'QA_SLOW_CONNECTION_THROUGHPUT_KBPS' => :qa_slow_connection_throughput_kbps, 'GITLAB_QA_USERNAME_1' => :gitlab_qa_username_1, 'GITLAB_QA_PASSWORD_1' => :gitlab_qa_password_1, 'GITLAB_QA_USERNAME_2' => :gitlab_qa_username_2, 'GITLAB_QA_PASSWORD_2' => :gitlab_qa_password_2, 'GITHUB_OAUTH_APP_ID' => :github_oauth_app_id, 'GITHUB_OAUTH_APP_SECRET' => :github_oauth_app_secret, 'GITHUB_USERNAME' => :github_username, 'GITHUB_PASSWORD' => :github_password, 'KNAPSACK_GENERATE_REPORT' => :knapsack_generate_report, 'KNAPSACK_REPORT_PATH' => :knapsack_report_path, 'KNAPSACK_TEST_FILE_PATTERN' => :knapsack_test_file_pattern, 'KNAPSACK_TEST_DIR' => :knapsack_test_dir, 'CI' => :ci, 'CI_RUNNER_ID' => :ci_runner_id, 'CI_SERVER_HOST' => :ci_server_host, 'CI_SERVER_PERSONAL_ACCESS_TOKEN' => :ci_server_personal_access_token, 'CI_NODE_INDEX' => :ci_node_index, 'CI_NODE_TOTAL' => :ci_node_total, 'GITLAB_CI' => :gitlab_ci, 'QA_SKIP_PULL' => :qa_skip_pull, 'ELASTIC_URL' => :elastic_url, 'GITLAB_QA_1P_EMAIL' => :gitlab_qa_1p_email, 'GITLAB_QA_1P_PASSWORD' => :gitlab_qa_1p_password, 'GITLAB_QA_1P_SECRET' => :gitlab_qa_1p_secret, 'GITLAB_QA_1P_GITHUB_UUID' => :gitlab_qa_1p_github_uuid, 'GITLAB_QA_LOOP_RUNNER_MINUTES' => :gitlab_qa_loop_runner_minutes, 'QA_CAN_TEST_ADMIN_FEATURES' => :qa_can_test_admin_features, 'MAILHOG_HOSTNAME' => :mailhog_hostname, 'SLACK_QA_CHANNEL' => :slack_qa_channel, 'CI_SLACK_WEBHOOK_URL' => :ci_slack_webhook_url, 'SLACK_ICON_EMOJI' => :slack_icon_emoji }.freeze
Instance Method Summary collapse
- #ci_job_name ⇒ Object
- #ci_job_url ⇒ Object
- #ci_project_name ⇒ Object
- #ci_slack_webhook_url ⇒ Object
- #dev_access_token_variable ⇒ Object
- #gitlab_api_base ⇒ Object
- #host_artifacts_dir ⇒ Object
- #qa_access_token ⇒ Object
- #qa_dev_access_token ⇒ Object
- #require_ci_slack_webhook_url! ⇒ Object
- #require_kubernetes_environment! ⇒ Object
- #require_license! ⇒ Object
- #require_no_license! ⇒ Object
- #require_oauth_environment! ⇒ Object
- #require_qa_access_token! ⇒ Object
- #require_qa_dev_access_token! ⇒ Object
- #require_slack_qa_channel! ⇒ Object
- #run_id ⇒ Object
- #skip_pull? ⇒ Boolean
- #slack_icon_emoji ⇒ Object
- #slack_qa_channel ⇒ Object
- #variables ⇒ Object
Instance Method Details
#ci_job_name ⇒ Object
88 89 90 |
# File 'lib/gitlab/qa/runtime/env.rb', line 88 def ci_job_name ENV['CI_JOB_NAME'] end |
#ci_job_url ⇒ Object
92 93 94 |
# File 'lib/gitlab/qa/runtime/env.rb', line 92 def ci_job_url ENV['CI_JOB_URL'] end |
#ci_project_name ⇒ Object
96 97 98 |
# File 'lib/gitlab/qa/runtime/env.rb', line 96 def ci_project_name ENV['CI_PROJECT_NAME'] end |
#ci_slack_webhook_url ⇒ Object
100 101 102 |
# File 'lib/gitlab/qa/runtime/env.rb', line 100 def ci_slack_webhook_url ENV['CI_SLACK_WEBHOOK_URL'] end |
#dev_access_token_variable ⇒ Object
120 121 122 |
# File 'lib/gitlab/qa/runtime/env.rb', line 120 def dev_access_token_variable env_value_if_defined('GITLAB_QA_DEV_ACCESS_TOKEN') end |
#gitlab_api_base ⇒ Object
84 85 86 |
# File 'lib/gitlab/qa/runtime/env.rb', line 84 def gitlab_api_base ENV['GITLAB_API_BASE'] || 'https://gitlab.com/api/v4' end |
#host_artifacts_dir ⇒ Object
128 129 130 |
# File 'lib/gitlab/qa/runtime/env.rb', line 128 def host_artifacts_dir @host_artifacts_dir ||= File.join(ENV['QA_ARTIFACTS_DIR'] || '/tmp/gitlab-qa', Runtime::Env.run_id) end |
#qa_access_token ⇒ Object
116 117 118 |
# File 'lib/gitlab/qa/runtime/env.rb', line 116 def qa_access_token ENV['GITLAB_QA_ACCESS_TOKEN'] end |
#qa_dev_access_token ⇒ Object
124 125 126 |
# File 'lib/gitlab/qa/runtime/env.rb', line 124 def qa_dev_access_token ENV['GITLAB_QA_DEV_ACCESS_TOKEN'] end |
#require_ci_slack_webhook_url! ⇒ Object
181 182 183 184 185 |
# File 'lib/gitlab/qa/runtime/env.rb', line 181 def require_ci_slack_webhook_url! return unless ENV['CI_SLACK_WEBHOOK_URL'].to_s.strip.empty? raise ArgumentError, "Please provide CI_SLACK_WEBHOOK_URL" end |
#require_kubernetes_environment! ⇒ Object
187 188 189 190 191 |
# File 'lib/gitlab/qa/runtime/env.rb', line 187 def require_kubernetes_environment! %w[GCLOUD_ACCOUNT_EMAIL GCLOUD_ACCOUNT_KEY CLOUDSDK_CORE_PROJECT].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run kubernetes specs" unless ENV.key?(env_key) end end |
#require_license! ⇒ Object
145 146 147 148 149 |
# File 'lib/gitlab/qa/runtime/env.rb', line 145 def require_license! return if ENV.include?('EE_LICENSE') raise ArgumentError, 'GitLab License is not available. Please load a license into EE_LICENSE env variable.' end |
#require_no_license! ⇒ Object
151 152 153 154 155 |
# File 'lib/gitlab/qa/runtime/env.rb', line 151 def require_no_license! return unless ENV.include?('EE_LICENSE') raise ArgumentError, "Unexpected EE_LICENSE provided. Please unset it to continue." end |
#require_oauth_environment! ⇒ Object
169 170 171 172 173 |
# File 'lib/gitlab/qa/runtime/env.rb', line 169 def require_oauth_environment! %w[GITHUB_OAUTH_APP_ID GITHUB_OAUTH_APP_SECRET GITHUB_USERNAME GITHUB_PASSWORD GITLAB_QA_1P_EMAIL GITLAB_QA_1P_PASSWORD GITLAB_QA_1P_SECRET GITLAB_QA_1P_GITHUB_UUID].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run OAuth specs" unless ENV.key?(env_key) end end |
#require_qa_access_token! ⇒ Object
157 158 159 160 161 |
# File 'lib/gitlab/qa/runtime/env.rb', line 157 def require_qa_access_token! return unless ENV['GITLAB_QA_ACCESS_TOKEN'].to_s.strip.empty? raise ArgumentError, "Please provide GITLAB_QA_ACCESS_TOKEN" end |
#require_qa_dev_access_token! ⇒ Object
163 164 165 166 167 |
# File 'lib/gitlab/qa/runtime/env.rb', line 163 def require_qa_dev_access_token! return unless ENV['GITLAB_QA_DEV_ACCESS_TOKEN'].to_s.strip.empty? raise ArgumentError, "Please provide GITLAB_QA_DEV_ACCESS_TOKEN" end |
#require_slack_qa_channel! ⇒ Object
175 176 177 178 179 |
# File 'lib/gitlab/qa/runtime/env.rb', line 175 def require_slack_qa_channel! return unless ENV['SLACK_QA_CHANNEL'].to_s.strip.empty? raise ArgumentError, "Please provide SLACK_QA_CHANNEL" end |
#run_id ⇒ Object
112 113 114 |
# File 'lib/gitlab/qa/runtime/env.rb', line 112 def run_id @run_id ||= "gitlab-qa-run-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(4)}" end |
#skip_pull? ⇒ Boolean
193 194 195 |
# File 'lib/gitlab/qa/runtime/env.rb', line 193 def skip_pull? (ENV['QA_SKIP_PULL'] =~ /^(false|no|0)$/i) != 0 end |
#slack_icon_emoji ⇒ Object
108 109 110 |
# File 'lib/gitlab/qa/runtime/env.rb', line 108 def slack_icon_emoji ENV['SLACK_ICON_EMOJI'] end |
#slack_qa_channel ⇒ Object
104 105 106 |
# File 'lib/gitlab/qa/runtime/env.rb', line 104 def slack_qa_channel ENV['SLACK_QA_CHANNEL'] end |
#variables ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/gitlab/qa/runtime/env.rb', line 132 def variables vars = {} ENV_VARIABLES.each do |name, attribute| # Variables that are overridden in the environment take precedence # over the defaults specified by the QA runtime. value = env_value_if_defined(name) || send(attribute) # rubocop:disable GitlabSecurity/PublicSend vars[name] = value if value end vars end |