blob: 89519e9537ca6029b6a4b9afbc2430a4e36e9d24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# frozen_string_literal: true
module QA
module Support
module Loglinking
# Static address variables declared for mapping environment to logging URLs
STAGING_ADDRESS = 'https://staging.gitlab.com'
STAGING_REF_ADDRESS = 'https://staging-ref.gitlab.com'
PRODUCTION_ADDRESS = 'https://www.gitlab.com'
PRE_PROD_ADDRESS = 'https://pre.gitlab.com'
SENTRY_ENVIRONMENTS = {
staging: 'https://sentry.gitlab.net/gitlab/staginggitlabcom/?environment=gstg',
staging_canary: 'https://sentry.gitlab.net/gitlab/staginggitlabcom/?environment=gstg-cny',
staging_ref: 'https://sentry.gitlab.net/gitlab/staging-ref/?environment=gstg-ref',
pre: 'https://sentry.gitlab.net/gitlab/pregitlabcom/?environment=pre',
canary: 'https://sentry.gitlab.net/gitlab/gitlabcom/?environment=gprd',
production: 'https://sentry.gitlab.net/gitlab/gitlabcom/?environment=gprd-cny'
}.freeze
KIBANA_ENVIRONMENTS = {
staging: 'https://nonprod-log.gitlab.net/',
staging_canary: 'https://nonprod-log.gitlab.net/',
canary: 'https://log.gprd.gitlab.net/',
production: 'https://log.gprd.gitlab.net/'
}.freeze
def self.failure_metadata(correlation_id)
return if correlation_id.blank?
sentry_uri = sentry_url
kibana_uri = kibana_url
errors = ["Correlation Id: #{correlation_id}"]
errors << "Sentry Url: #{sentry_uri}&query=correlation_id%3A%22#{correlation_id}%22" if sentry_uri
errors << "Kibana Url: #{kibana_uri}app/discover#/?_a=(query:(language:kuery,query:'json.correlation_id%20:%20#{correlation_id}'))" if kibana_uri
errors.join("\n")
end
def self.sentry_url
return unless logging_environment?
SENTRY_ENVIRONMENTS[logging_environment]
end
def self.kibana_url
return unless logging_environment?
KIBANA_ENVIRONMENTS[logging_environment]
end
def self.logging_environment
address = QA::Runtime::Scenario.attributes[:gitlab_address]
return if address.nil?
case address
when STAGING_ADDRESS
canary? ? :staging_canary : :staging
when STAGING_REF_ADDRESS
:staging_ref
when PRODUCTION_ADDRESS
canary? ? :canary : :production
when PRE_PROD_ADDRESS
:pre
else
nil
end
end
def self.logging_environment?
!logging_environment.nil?
end
def self.cookies
browser_cookies = Capybara.current_session.driver.browser.manage.all_cookies
# rubocop:disable Rails/IndexBy
browser_cookies.each_with_object({}) do |cookie, memo|
memo[cookie[:name]] = cookie
end
# rubocop:enable Rails/IndexBy
end
def self.canary?
cookies.dig('gitlab_canary', :value) == 'true'
end
end
end
end
|