datadog-ci 1.42.0 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -2
- data/README.md +45 -0
- data/lib/datadog/ci/async_writer.rb +1 -4
- data/lib/datadog/ci/concurrent_span.rb +20 -0
- data/lib/datadog/ci/configuration/settings.rb +3 -2
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +27 -8
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +11 -3
- data/lib/datadog/ci/contrib/cuprite/driver.rb +5 -5
- data/lib/datadog/ci/contrib/knapsack/runner.rb +1 -1
- data/lib/datadog/ci/contrib/minitest/helpers.rb +59 -0
- data/lib/datadog/ci/contrib/minitest/reporter.rb +2 -2
- data/lib/datadog/ci/contrib/minitest/test.rb +4 -1
- data/lib/datadog/ci/contrib/rspec/example.rb +12 -2
- data/lib/datadog/ci/contrib/rspec/example_group.rb +3 -2
- data/lib/datadog/ci/contrib/rspec/runner.rb +2 -2
- data/lib/datadog/ci/contrib/selenium/navigation.rb +5 -5
- data/lib/datadog/ci/ext/metadata.rb +168 -0
- data/lib/datadog/ci/ext/settings.rb +1 -0
- data/lib/datadog/ci/ext/test.rb +11 -0
- data/lib/datadog/ci/impacted_tests_detection/component.rb +1 -1
- data/lib/datadog/ci/readonly_test_module.rb +16 -0
- data/lib/datadog/ci/readonly_test_session.rb +16 -0
- data/lib/datadog/ci/remote/library_settings_client.rb +1 -1
- data/lib/datadog/ci/remote/slow_test_retries.rb +3 -2
- data/lib/datadog/ci/span.rb +46 -10
- data/lib/datadog/ci/test.rb +75 -18
- data/lib/datadog/ci/test_impact_analysis/component.rb +11 -11
- data/lib/datadog/ci/test_impact_analysis/skippable.rb +1 -1
- data/lib/datadog/ci/test_management/component.rb +4 -4
- data/lib/datadog/ci/test_management/tests_properties.rb +1 -1
- data/lib/datadog/ci/test_retries/component.rb +34 -18
- data/lib/datadog/ci/test_retries/driver/base.rb +2 -2
- data/lib/datadog/ci/test_retries/driver/retry_flake_detection.rb +12 -4
- data/lib/datadog/ci/test_retries/strategy/retry_flake_detection.rb +2 -2
- data/lib/datadog/ci/test_retries/strategy/retry_flaky_fixed.rb +6 -3
- data/lib/datadog/ci/test_tracing/component.rb +17 -7
- data/lib/datadog/ci/test_tracing/context.rb +24 -7
- data/lib/datadog/ci/test_tracing/deprecated_total_coverage_metric.rb +1 -1
- data/lib/datadog/ci/test_tracing/known_tests.rb +1 -1
- data/lib/datadog/ci/test_tracing/null_component.rb +6 -1
- data/lib/datadog/ci/test_tracing/transport.rb +3 -22
- data/lib/datadog/ci/transport/adapters/net.rb +24 -4
- data/lib/datadog/ci/transport/adapters/net_http_client.rb +31 -0
- data/lib/datadog/ci/transport/api/evp_proxy.rb +2 -1
- data/lib/datadog/ci/transport/http.rb +20 -4
- data/lib/datadog/ci/utils/protected_tags.rb +27 -0
- data/lib/datadog/ci/utils/rum.rb +1 -1
- data/lib/datadog/ci/version.rb +1 -1
- metadata +3 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "set"
|
|
4
|
+
require_relative "test"
|
|
5
|
+
require_relative "git"
|
|
6
|
+
require_relative "environment"
|
|
7
|
+
|
|
8
|
+
module Datadog
|
|
9
|
+
module CI
|
|
10
|
+
module Ext
|
|
11
|
+
# SDK-owned metadata. Custom tag names outside this set remain writable.
|
|
12
|
+
module Metadata
|
|
13
|
+
# Explicitly whitelist environment fields; custom ci.* and git.* tags belong to individual events.
|
|
14
|
+
SHARED_ENVIRONMENT_TAGS = [
|
|
15
|
+
Environment::TAG_JOB_ID,
|
|
16
|
+
Environment::TAG_JOB_NAME,
|
|
17
|
+
Environment::TAG_JOB_URL,
|
|
18
|
+
Environment::TAG_NODE_LABELS,
|
|
19
|
+
Environment::TAG_NODE_NAME,
|
|
20
|
+
Environment::TAG_PIPELINE_ID,
|
|
21
|
+
Environment::TAG_PIPELINE_NAME,
|
|
22
|
+
Environment::TAG_PIPELINE_DISPLAY_NAME,
|
|
23
|
+
Environment::TAG_PIPELINE_NUMBER,
|
|
24
|
+
Environment::TAG_PIPELINE_URL,
|
|
25
|
+
Environment::TAG_PROVIDER_NAME,
|
|
26
|
+
Environment::TAG_STAGE_NAME,
|
|
27
|
+
Environment::TAG_WORKSPACE_PATH,
|
|
28
|
+
Environment::TAG_CI_ENV_VARS,
|
|
29
|
+
Environment::TAG_PR_NUMBER,
|
|
30
|
+
Git::TAG_BRANCH,
|
|
31
|
+
Git::TAG_TAG,
|
|
32
|
+
Git::TAG_REPOSITORY_URL,
|
|
33
|
+
Git::TAG_COMMIT_SHA,
|
|
34
|
+
Git::TAG_COMMIT_MESSAGE,
|
|
35
|
+
Git::TAG_COMMIT_AUTHOR_NAME,
|
|
36
|
+
Git::TAG_COMMIT_AUTHOR_EMAIL,
|
|
37
|
+
Git::TAG_COMMIT_AUTHOR_DATE,
|
|
38
|
+
Git::TAG_COMMIT_COMMITTER_NAME,
|
|
39
|
+
Git::TAG_COMMIT_COMMITTER_EMAIL,
|
|
40
|
+
Git::TAG_COMMIT_COMMITTER_DATE,
|
|
41
|
+
Git::TAG_COMMIT_HEAD_SHA,
|
|
42
|
+
Git::TAG_COMMIT_HEAD_MESSAGE,
|
|
43
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_NAME,
|
|
44
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_EMAIL,
|
|
45
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_DATE,
|
|
46
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_NAME,
|
|
47
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_EMAIL,
|
|
48
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_DATE,
|
|
49
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH,
|
|
50
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
51
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH_HEAD_SHA
|
|
52
|
+
].freeze
|
|
53
|
+
|
|
54
|
+
SHARED_TAGS = Set.new(SHARED_ENVIRONMENT_TAGS + Test::LibraryCapabilities::CAPABILITY_VERSIONS.keys + [
|
|
55
|
+
Test::TAG_TEST_SESSION_NAME,
|
|
56
|
+
Test::TAG_USER_PROVIDED_TEST_SERVICE
|
|
57
|
+
]).freeze
|
|
58
|
+
|
|
59
|
+
PROTECTED_TAGS = Set.new([
|
|
60
|
+
Test::TAG_FRAMEWORK,
|
|
61
|
+
Test::TAG_FRAMEWORK_VERSION,
|
|
62
|
+
Test::TAG_NAME,
|
|
63
|
+
Test::TAG_SKIP_REASON,
|
|
64
|
+
Test::TAG_SESSION_EMPTY_REASON,
|
|
65
|
+
Test::TAG_STATUS,
|
|
66
|
+
Test::TAG_FINAL_STATUS,
|
|
67
|
+
Test::TAG_SUITE,
|
|
68
|
+
Test::TAG_MODULE,
|
|
69
|
+
Test::TAG_TYPE,
|
|
70
|
+
Test::TAG_COMMAND,
|
|
71
|
+
Test::TAG_SOURCE_FILE,
|
|
72
|
+
Test::TAG_SOURCE_START,
|
|
73
|
+
Test::TAG_SOURCE_END,
|
|
74
|
+
Test::TAG_CODEOWNERS,
|
|
75
|
+
Test::TAG_PARAMETERS,
|
|
76
|
+
Test::TAG_CODE_COVERAGE_ENABLED,
|
|
77
|
+
Test::TAG_ITR_TEST_SKIPPING_ENABLED,
|
|
78
|
+
Test::TAG_ITR_TEST_SKIPPING_TYPE,
|
|
79
|
+
Test::TAG_ITR_TEST_SKIPPING_COUNT,
|
|
80
|
+
Test::TAG_ITR_SKIPPED_BY_ITR,
|
|
81
|
+
Test::TAG_ITR_TESTS_SKIPPED,
|
|
82
|
+
Test::TAG_ITR_UNSKIPPABLE,
|
|
83
|
+
Test::TAG_ITR_FORCED_RUN,
|
|
84
|
+
Test::TAG_TEST_SESSION_ID,
|
|
85
|
+
Test::TAG_TEST_MODULE_ID,
|
|
86
|
+
Test::TAG_TEST_SUITE_ID,
|
|
87
|
+
Test::TAG_OS_ARCHITECTURE,
|
|
88
|
+
Test::TAG_OS_PLATFORM,
|
|
89
|
+
Test::TAG_OS_VERSION,
|
|
90
|
+
Test::TAG_RUNTIME_NAME,
|
|
91
|
+
Test::TAG_RUNTIME_VERSION,
|
|
92
|
+
Test::TAG_IS_RUM_ACTIVE,
|
|
93
|
+
Test::TAG_BROWSER_DRIVER,
|
|
94
|
+
Test::TAG_BROWSER_DRIVER_VERSION,
|
|
95
|
+
Test::TAG_BROWSER_NAME,
|
|
96
|
+
Test::TAG_BROWSER_VERSION,
|
|
97
|
+
Test::TAG_IS_NEW,
|
|
98
|
+
Test::TAG_IS_RETRY,
|
|
99
|
+
Test::TAG_RETRY_REASON,
|
|
100
|
+
Test::TAG_FAILURE_SUPPRESSION_REASON,
|
|
101
|
+
Test::TAG_EARLY_FLAKE_ENABLED,
|
|
102
|
+
Test::TAG_EARLY_FLAKE_ABORT_REASON,
|
|
103
|
+
Test::TAG_CODE_COVERAGE_LINES_PCT,
|
|
104
|
+
Test::TAG_TEST_MANAGEMENT_ENABLED,
|
|
105
|
+
Test::TAG_IS_ATTEMPT_TO_FIX,
|
|
106
|
+
Test::TAG_PREVENT_FAILURE_SUPPRESSION,
|
|
107
|
+
Test::TAG_NO_AUTO_RETRY,
|
|
108
|
+
Test::TAG_IS_TEST_DISABLED,
|
|
109
|
+
Test::TAG_IS_QUARANTINED,
|
|
110
|
+
Test::TAG_HAS_FAILED_ALL_RETRIES,
|
|
111
|
+
Test::TAG_ATTEMPT_TO_FIX_PASSED,
|
|
112
|
+
Test::LibraryConfigurationError::TAG_SETTINGS,
|
|
113
|
+
Test::LibraryConfigurationError::TAG_SKIPPABLE_TESTS,
|
|
114
|
+
Test::LibraryConfigurationError::TAG_KNOWN_TESTS,
|
|
115
|
+
Test::LibraryConfigurationError::TAG_TEST_MANAGEMENT_TESTS,
|
|
116
|
+
Test::LibraryCapabilities::TAG_TEST_IMPACT_ANALYSIS,
|
|
117
|
+
Test::LibraryCapabilities::TAG_EARLY_FLAKE_DETECTION,
|
|
118
|
+
Test::LibraryCapabilities::TAG_AUTO_TEST_RETRIES,
|
|
119
|
+
Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_QUARANTINE,
|
|
120
|
+
Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_DISABLE,
|
|
121
|
+
Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_ATTEMPT_TO_FIX,
|
|
122
|
+
Test::TAG_TEST_IS_MODIFIED,
|
|
123
|
+
Test::TAG_SPAN_KIND,
|
|
124
|
+
Test::TAG_TEST_SESSION_NAME,
|
|
125
|
+
Test::TAG_USER_PROVIDED_TEST_SERVICE,
|
|
126
|
+
Test::METRIC_CPU_COUNT,
|
|
127
|
+
Git::TAG_BRANCH,
|
|
128
|
+
Git::TAG_REPOSITORY_URL,
|
|
129
|
+
Git::TAG_TAG,
|
|
130
|
+
Git::TAG_COMMIT_AUTHOR_DATE,
|
|
131
|
+
Git::TAG_COMMIT_AUTHOR_EMAIL,
|
|
132
|
+
Git::TAG_COMMIT_AUTHOR_NAME,
|
|
133
|
+
Git::TAG_COMMIT_COMMITTER_DATE,
|
|
134
|
+
Git::TAG_COMMIT_COMMITTER_EMAIL,
|
|
135
|
+
Git::TAG_COMMIT_COMMITTER_NAME,
|
|
136
|
+
Git::TAG_COMMIT_MESSAGE,
|
|
137
|
+
Git::TAG_COMMIT_SHA,
|
|
138
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH,
|
|
139
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
140
|
+
Git::TAG_PULL_REQUEST_BASE_BRANCH_HEAD_SHA,
|
|
141
|
+
Git::TAG_COMMIT_HEAD_SHA,
|
|
142
|
+
Git::TAG_COMMIT_HEAD_MESSAGE,
|
|
143
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_DATE,
|
|
144
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_EMAIL,
|
|
145
|
+
Git::TAG_COMMIT_HEAD_AUTHOR_NAME,
|
|
146
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_DATE,
|
|
147
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_EMAIL,
|
|
148
|
+
Git::TAG_COMMIT_HEAD_COMMITTER_NAME,
|
|
149
|
+
Environment::TAG_JOB_ID,
|
|
150
|
+
Environment::TAG_JOB_NAME,
|
|
151
|
+
Environment::TAG_JOB_URL,
|
|
152
|
+
Environment::TAG_PIPELINE_ID,
|
|
153
|
+
Environment::TAG_PIPELINE_NAME,
|
|
154
|
+
Environment::TAG_PIPELINE_DISPLAY_NAME,
|
|
155
|
+
Environment::TAG_PIPELINE_NUMBER,
|
|
156
|
+
Environment::TAG_PIPELINE_URL,
|
|
157
|
+
Environment::TAG_PROVIDER_NAME,
|
|
158
|
+
Environment::TAG_STAGE_NAME,
|
|
159
|
+
Environment::TAG_WORKSPACE_PATH,
|
|
160
|
+
Environment::TAG_NODE_LABELS,
|
|
161
|
+
Environment::TAG_NODE_NAME,
|
|
162
|
+
Environment::TAG_CI_ENV_VARS,
|
|
163
|
+
Environment::TAG_PR_NUMBER
|
|
164
|
+
]).freeze
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -27,6 +27,7 @@ module Datadog
|
|
|
27
27
|
ENV_TEST_SESSION_NAME = "DD_TEST_SESSION_NAME"
|
|
28
28
|
ENV_TEST_MANAGEMENT_ENABLED = "DD_TEST_MANAGEMENT_ENABLED"
|
|
29
29
|
ENV_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES = "DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES"
|
|
30
|
+
DEFAULT_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES = 20
|
|
30
31
|
ENV_TEST_VISIBILITY_DRB_SERVER_URI = "DD_TEST_VISIBILITY_DRB_SERVER_URI"
|
|
31
32
|
ENV_AGENTLESS_LOGS_SUBMISSION_ENABLED = "DD_AGENTLESS_LOG_SUBMISSION_ENABLED"
|
|
32
33
|
ENV_AGENTLESS_LOGS_SUBMISSION_URL = "DD_AGENTLESS_LOG_SUBMISSION_URL"
|
data/lib/datadog/ci/ext/test.rb
CHANGED
|
@@ -171,9 +171,20 @@ module Datadog
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
DEFAULT_TIA_TEST_SKIPPING_MODE = TIATestSkippingMode::TEST
|
|
174
|
+
PREVENT_FAILURE_SUPPRESSION_OPTION = :datadog_prevent_failure_suppression
|
|
175
|
+
NO_AUTO_RETRY_OPTION = :datadog_no_auto_retry
|
|
176
|
+
TAG_PREVENT_FAILURE_SUPPRESSION = "test.test_management.prevent_failure_suppression"
|
|
177
|
+
TAG_NO_AUTO_RETRY = "test.test_management.no_auto_retry"
|
|
178
|
+
|
|
174
179
|
ITR_UNSKIPPABLE_OPTION = :datadog_itr_unskippable
|
|
175
180
|
|
|
176
181
|
EARLY_FLAKE_FAULTY = "faulty"
|
|
182
|
+
EARLY_FLAKE_SLOW = "slow"
|
|
183
|
+
TAG_FAILURE_SUPPRESSION_REASON = "test.failure_suppression_reason"
|
|
184
|
+
|
|
185
|
+
module FailureSuppressionReason
|
|
186
|
+
QUARANTINE = "quarantine"
|
|
187
|
+
end
|
|
177
188
|
|
|
178
189
|
# test status as recognized by Datadog
|
|
179
190
|
module Status
|
|
@@ -73,7 +73,7 @@ module Datadog
|
|
|
73
73
|
"Impacted tests detection: test #{test_span.name} with source file #{test_span.source_file} is modified"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
test_span.
|
|
76
|
+
test_span.set_internal_tag(Ext::Test::TAG_TEST_IS_MODIFIED, "true")
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
private
|
|
@@ -16,6 +16,22 @@ module Datadog
|
|
|
16
16
|
raise "ReadonlyTestModule cannot be finished"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def set_internal_tag(key, value)
|
|
20
|
+
raise "ReadonlyTestModule cannot be modified"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def set_internal_tags(tags)
|
|
24
|
+
raise "ReadonlyTestModule cannot be modified"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def set_internal_metric(key, value)
|
|
28
|
+
raise "ReadonlyTestModule cannot be modified"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def clear_internal_tag(key)
|
|
32
|
+
raise "ReadonlyTestModule cannot be modified"
|
|
33
|
+
end
|
|
34
|
+
|
|
19
35
|
def set_tag(key, value)
|
|
20
36
|
raise "ReadonlyTestModule cannot be modified"
|
|
21
37
|
end
|
|
@@ -19,6 +19,22 @@ module Datadog
|
|
|
19
19
|
raise "ReadonlyTestSession cannot be finished"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def set_internal_tag(key, value)
|
|
23
|
+
raise "ReadonlyTestSession cannot be modified"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_internal_tags(tags)
|
|
27
|
+
raise "ReadonlyTestSession cannot be modified"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def set_internal_metric(key, value)
|
|
31
|
+
raise "ReadonlyTestSession cannot be modified"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def clear_internal_tag(key)
|
|
35
|
+
raise "ReadonlyTestSession cannot be modified"
|
|
36
|
+
end
|
|
37
|
+
|
|
22
38
|
def set_tag(key, value)
|
|
23
39
|
raise "ReadonlyTestSession cannot be modified"
|
|
24
40
|
end
|
|
@@ -53,7 +53,7 @@ module Datadog
|
|
|
53
53
|
|
|
54
54
|
# mark the test session so that all events emitted in this session are tagged
|
|
55
55
|
# with the hidden _dd.ci.library_configuration_error.settings tag
|
|
56
|
-
test_session.
|
|
56
|
+
test_session.set_internal_tag(Ext::Test::LibraryConfigurationError::TAG_SETTINGS, "true")
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
library_settings = LibrarySettings.from_http_response(http_response)
|
|
@@ -13,8 +13,9 @@ module Datadog
|
|
|
13
13
|
# "5m" => 2
|
|
14
14
|
# }
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# Each EFD value includes the original execution: tests that run less than
|
|
17
|
+
# 5 seconds execute at most 10 times, tests below 10 seconds execute at most
|
|
18
|
+
# 5 times, and so on.
|
|
18
19
|
class SlowTestRetries
|
|
19
20
|
attr_reader :entries
|
|
20
21
|
|
data/lib/datadog/ci/span.rb
CHANGED
|
@@ -5,7 +5,9 @@ require "drb"
|
|
|
5
5
|
require "datadog/core/environment/platform"
|
|
6
6
|
|
|
7
7
|
require_relative "ext/test"
|
|
8
|
+
require_relative "ext/app_types"
|
|
8
9
|
require_relative "utils/test_run"
|
|
10
|
+
require_relative "utils/protected_tags"
|
|
9
11
|
require_relative "ext/git"
|
|
10
12
|
|
|
11
13
|
module Datadog
|
|
@@ -25,6 +27,8 @@ module Datadog
|
|
|
25
27
|
Ext::Test::TAG_RUNTIME_VERSION => Core::Environment::Ext::ENGINE_VERSION
|
|
26
28
|
}.freeze
|
|
27
29
|
|
|
30
|
+
EMPTY_TAGS = {}.freeze
|
|
31
|
+
|
|
28
32
|
attr_reader :tracer_span
|
|
29
33
|
|
|
30
34
|
def initialize(tracer_span)
|
|
@@ -115,21 +119,35 @@ module Datadog
|
|
|
115
119
|
# @param [String] key the key of the tag.
|
|
116
120
|
# @return [String] the value of the tag.
|
|
117
121
|
def get_tag(key)
|
|
118
|
-
tracer_span.get_tag(key)
|
|
122
|
+
shared_tags[key] || tracer_span.get_tag(key)
|
|
119
123
|
end
|
|
120
124
|
|
|
121
|
-
# Sets tag
|
|
125
|
+
# Sets a custom tag. SDK-owned fields are read-only through this method.
|
|
122
126
|
# @param [String] key the key of the tag.
|
|
123
127
|
# @param [String] value the value of the tag.
|
|
124
128
|
# @return [void]
|
|
125
129
|
def set_tag(key, value)
|
|
130
|
+
return if Utils::ProtectedTags.reject?(key, :set_tag)
|
|
131
|
+
|
|
132
|
+
set_internal_tag(key, value)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# @internal_api
|
|
136
|
+
def set_internal_tag(key, value)
|
|
126
137
|
tracer_span.set_tag(key, value)
|
|
127
138
|
end
|
|
128
139
|
|
|
129
|
-
# Removes tag
|
|
140
|
+
# Removes a custom tag. SDK-owned fields are read-only through this method.
|
|
130
141
|
# @param [String] key the key of the tag.
|
|
131
142
|
# @return [void]
|
|
132
143
|
def clear_tag(key)
|
|
144
|
+
return if Utils::ProtectedTags.reject?(key, :clear_tag)
|
|
145
|
+
|
|
146
|
+
clear_internal_tag(key)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# @internal_api
|
|
150
|
+
def clear_internal_tag(key)
|
|
133
151
|
tracer_span.clear_tag(key)
|
|
134
152
|
end
|
|
135
153
|
|
|
@@ -137,14 +155,21 @@ module Datadog
|
|
|
137
155
|
# @param [String] key the key of the metric.
|
|
138
156
|
# @return [Numeric] value the value of the metric.
|
|
139
157
|
def get_metric(key)
|
|
140
|
-
tracer_span.get_metric(key)
|
|
158
|
+
shared_tags[key] || tracer_span.get_metric(key)
|
|
141
159
|
end
|
|
142
160
|
|
|
143
|
-
# Sets metric
|
|
161
|
+
# Sets a custom metric. SDK-owned fields are read-only through this method.
|
|
144
162
|
# @param [String] key the key of the metric.
|
|
145
163
|
# @param [Numeric] value the value of the metric.
|
|
146
164
|
# @return [void]
|
|
147
165
|
def set_metric(key, value)
|
|
166
|
+
return if Utils::ProtectedTags.reject?(key, :set_metric)
|
|
167
|
+
|
|
168
|
+
set_internal_metric(key, value)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# @internal_api
|
|
172
|
+
def set_internal_metric(key, value)
|
|
148
173
|
tracer_span.set_metric(key, value)
|
|
149
174
|
end
|
|
150
175
|
|
|
@@ -158,19 +183,24 @@ module Datadog
|
|
|
158
183
|
# @param [Hash[String, String]] tags the tags to set.
|
|
159
184
|
# @return [void]
|
|
160
185
|
def set_tags(tags)
|
|
186
|
+
tags.each { |key, value| set_tag(key, value) }
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @internal_api
|
|
190
|
+
def set_internal_tags(tags)
|
|
161
191
|
tracer_span.set_tags(tags)
|
|
162
192
|
end
|
|
163
193
|
|
|
164
194
|
# Returns the git repository URL extracted from the environment.
|
|
165
195
|
# @return [String] the repository URL.
|
|
166
196
|
def git_repository_url
|
|
167
|
-
|
|
197
|
+
get_tag(Ext::Git::TAG_REPOSITORY_URL)
|
|
168
198
|
end
|
|
169
199
|
|
|
170
200
|
# Returns the latest commit SHA extracted from the environment.
|
|
171
201
|
# @return [String] the commit SHA of the last commit.
|
|
172
202
|
def git_commit_sha
|
|
173
|
-
|
|
203
|
+
get_tag(Ext::Git::TAG_COMMIT_SHA)
|
|
174
204
|
end
|
|
175
205
|
|
|
176
206
|
# Returns the git commit message extracted from the environment.
|
|
@@ -200,19 +230,19 @@ module Datadog
|
|
|
200
230
|
# Returns the git branch name extracted from the environment.
|
|
201
231
|
# @return [String] the branch.
|
|
202
232
|
def git_branch
|
|
203
|
-
|
|
233
|
+
get_tag(Ext::Git::TAG_BRANCH)
|
|
204
234
|
end
|
|
205
235
|
|
|
206
236
|
# Returns the git tag extracted from the environment.
|
|
207
237
|
# @return [String, nil] the tag or nil if not set.
|
|
208
238
|
def git_tag
|
|
209
|
-
|
|
239
|
+
get_tag(Ext::Git::TAG_TAG)
|
|
210
240
|
end
|
|
211
241
|
|
|
212
242
|
# Returns the base commit SHA for the pull request, if available.
|
|
213
243
|
# @return [String, nil] the base commit SHA or nil if not set.
|
|
214
244
|
def base_commit_sha
|
|
215
|
-
|
|
245
|
+
get_tag(Ext::Git::TAG_PULL_REQUEST_BASE_BRANCH_SHA)
|
|
216
246
|
end
|
|
217
247
|
|
|
218
248
|
# Returns the OS architecture extracted from the environment.
|
|
@@ -267,6 +297,12 @@ module Datadog
|
|
|
267
297
|
|
|
268
298
|
private
|
|
269
299
|
|
|
300
|
+
def shared_tags
|
|
301
|
+
return EMPTY_TAGS unless Ext::AppTypes::CI_SPAN_TYPES.include?(type)
|
|
302
|
+
|
|
303
|
+
test_tracing.shared_tags
|
|
304
|
+
end
|
|
305
|
+
|
|
270
306
|
# provides access to the test tracing component for CI models to deactivate themselves
|
|
271
307
|
def test_tracing
|
|
272
308
|
Datadog.send(:components).test_tracing
|
data/lib/datadog/ci/test.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Datadog
|
|
|
38
38
|
# @return [void]
|
|
39
39
|
def finish
|
|
40
40
|
if is_retry? && retry_reason.nil?
|
|
41
|
-
|
|
41
|
+
set_internal_tag(Ext::Test::TAG_RETRY_REASON, Ext::Test::RetryReason::RETRY_EXTERNAL)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
test_tracing.deactivate_test
|
|
@@ -136,6 +136,49 @@ module Datadog
|
|
|
136
136
|
get_tag(Ext::Test::TAG_IS_ATTEMPT_TO_FIX) == "true"
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
+
# Records execution exclusions from the framework's test declaration.
|
|
140
|
+
# Replaces any user-provided initial tags before execution policy is evaluated.
|
|
141
|
+
# @internal_api
|
|
142
|
+
def apply_automation_exclusions(prevent_failure_suppression:, no_auto_retry:)
|
|
143
|
+
if prevent_failure_suppression
|
|
144
|
+
set_internal_tag(Ext::Test::TAG_PREVENT_FAILURE_SUPPRESSION, "true")
|
|
145
|
+
else
|
|
146
|
+
clear_internal_tag(Ext::Test::TAG_PREVENT_FAILURE_SUPPRESSION)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if no_auto_retry
|
|
150
|
+
set_internal_tag(Ext::Test::TAG_NO_AUTO_RETRY, "true")
|
|
151
|
+
else
|
|
152
|
+
clear_internal_tag(Ext::Test::TAG_NO_AUTO_RETRY)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# @internal
|
|
157
|
+
def prevent_failure_suppression?
|
|
158
|
+
get_tag(Ext::Test::TAG_PREVENT_FAILURE_SUPPRESSION) == "true"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# @internal
|
|
162
|
+
def no_auto_retry?
|
|
163
|
+
get_tag(Ext::Test::TAG_NO_AUTO_RETRY) == "true"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Assigned properties stay observable independently of effective policy.
|
|
167
|
+
# @internal
|
|
168
|
+
def should_quarantine?
|
|
169
|
+
quarantined? && !prevent_failure_suppression?
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# @internal
|
|
173
|
+
def should_disable?
|
|
174
|
+
disabled? && !prevent_failure_suppression?
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# @internal
|
|
178
|
+
def should_retry_attempt_to_fix?
|
|
179
|
+
attempt_to_fix? && !no_auto_retry?
|
|
180
|
+
end
|
|
181
|
+
|
|
139
182
|
# Returns "true" if this test is marked as modified (e.g., impacted by code changes).
|
|
140
183
|
# @return [Boolean] true if this test is modified, false otherwise.
|
|
141
184
|
def modified?
|
|
@@ -154,13 +197,13 @@ module Datadog
|
|
|
154
197
|
# @return [void]
|
|
155
198
|
def itr_unskippable!
|
|
156
199
|
Utils::Telemetry.itr_unskippable
|
|
157
|
-
|
|
200
|
+
set_internal_tag(Ext::Test::TAG_ITR_UNSKIPPABLE, "true")
|
|
158
201
|
|
|
159
202
|
if skipped_by_test_impact_analysis?
|
|
160
|
-
|
|
203
|
+
clear_internal_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR)
|
|
161
204
|
|
|
162
205
|
Utils::Telemetry.itr_forced_run
|
|
163
|
-
|
|
206
|
+
set_internal_tag(Ext::Test::TAG_ITR_FORCED_RUN, "true")
|
|
164
207
|
end
|
|
165
208
|
end
|
|
166
209
|
|
|
@@ -260,7 +303,7 @@ module Datadog
|
|
|
260
303
|
def set_parameters(arguments, metadata = {})
|
|
261
304
|
return if arguments.nil?
|
|
262
305
|
|
|
263
|
-
|
|
306
|
+
set_internal_tag(Ext::Test::TAG_PARAMETERS, Utils::TestRun.test_parameters(arguments: arguments, metadata: metadata))
|
|
264
307
|
end
|
|
265
308
|
|
|
266
309
|
# Gets the parameters for this test (e.g. Cucumber example or RSpec specs) as a serialized JSON.
|
|
@@ -273,37 +316,37 @@ module Datadog
|
|
|
273
316
|
|
|
274
317
|
# @internal
|
|
275
318
|
def any_retry_passed?
|
|
276
|
-
!!test_suite&.any_test_retry_passed?(
|
|
319
|
+
!!test_suite&.any_test_retry_passed?(local_test_id)
|
|
277
320
|
end
|
|
278
321
|
|
|
279
322
|
# @internal
|
|
280
323
|
def all_executions_failed?
|
|
281
|
-
!!test_suite&.all_executions_failed?(
|
|
324
|
+
!!test_suite&.all_executions_failed?(local_test_id)
|
|
282
325
|
end
|
|
283
326
|
|
|
284
327
|
# @internal
|
|
285
328
|
def all_executions_passed?
|
|
286
|
-
!!test_suite&.all_executions_passed?(
|
|
329
|
+
!!test_suite&.all_executions_passed?(local_test_id)
|
|
287
330
|
end
|
|
288
331
|
|
|
289
332
|
# @internal
|
|
290
333
|
def datadog_skip_reason
|
|
291
334
|
if skipped_by_test_impact_analysis?
|
|
292
335
|
Ext::Test::SkipReason::TEST_IMPACT_ANALYSIS
|
|
293
|
-
elsif
|
|
336
|
+
elsif should_disable? || should_quarantine?
|
|
294
337
|
Ext::Test::SkipReason::TEST_MANAGEMENT_DISABLED
|
|
295
338
|
end
|
|
296
339
|
end
|
|
297
340
|
|
|
298
341
|
# @internal
|
|
299
342
|
def should_skip?
|
|
300
|
-
skipped_by_test_impact_analysis? || (
|
|
343
|
+
skipped_by_test_impact_analysis? || (should_disable? && !should_retry_attempt_to_fix?)
|
|
301
344
|
end
|
|
302
345
|
|
|
303
346
|
# @internal
|
|
304
347
|
def should_ignore_failures?
|
|
305
|
-
return false if
|
|
306
|
-
return true if
|
|
348
|
+
return false if should_retry_attempt_to_fix?
|
|
349
|
+
return true if should_quarantine? || should_disable?
|
|
307
350
|
|
|
308
351
|
any_retry_passed?
|
|
309
352
|
end
|
|
@@ -319,8 +362,8 @@ module Datadog
|
|
|
319
362
|
return if status.nil?
|
|
320
363
|
|
|
321
364
|
final_status = compute_final_status(status)
|
|
322
|
-
|
|
323
|
-
test_suite&.record_test_final_status(
|
|
365
|
+
set_internal_tag(Ext::Test::TAG_FINAL_STATUS, final_status)
|
|
366
|
+
test_suite&.record_test_final_status(local_test_id, final_status)
|
|
324
367
|
end
|
|
325
368
|
|
|
326
369
|
# @internal
|
|
@@ -334,13 +377,27 @@ module Datadog
|
|
|
334
377
|
|
|
335
378
|
private
|
|
336
379
|
|
|
380
|
+
# Distinct declarations can share the backend ID but must not share retry history.
|
|
381
|
+
def local_test_id
|
|
382
|
+
@local_test_id ||= begin
|
|
383
|
+
source_file = get_tag(Ext::Test::TAG_SOURCE_FILE)
|
|
384
|
+
source_start = get_tag(Ext::Test::TAG_SOURCE_START)
|
|
385
|
+
|
|
386
|
+
if source_file && source_start
|
|
387
|
+
[datadog_test_id, source_file, source_start]
|
|
388
|
+
else
|
|
389
|
+
datadog_test_id
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
337
394
|
def compute_final_status(status)
|
|
338
395
|
# Skip status is always preserved
|
|
339
396
|
return status if status == Ext::Test::Status::SKIP
|
|
340
397
|
|
|
341
398
|
# attempt_to_fix takes precedence over quarantine/disabled flags:
|
|
342
399
|
# any failure across attempts means the fix didn't work.
|
|
343
|
-
if
|
|
400
|
+
if should_retry_attempt_to_fix?
|
|
344
401
|
return all_executions_passed? ? Ext::Test::Status::PASS : Ext::Test::Status::FAIL
|
|
345
402
|
end
|
|
346
403
|
|
|
@@ -351,11 +408,11 @@ module Datadog
|
|
|
351
408
|
|
|
352
409
|
def record_test_result(datadog_status)
|
|
353
410
|
# if this test was already executed in this test suite, mark it as retried
|
|
354
|
-
if test_suite&.test_executed?(
|
|
355
|
-
|
|
411
|
+
if test_suite&.test_executed?(local_test_id)
|
|
412
|
+
set_internal_tag(Ext::Test::TAG_IS_RETRY, "true")
|
|
356
413
|
end
|
|
357
414
|
|
|
358
|
-
test_suite&.record_test_result(
|
|
415
|
+
test_suite&.record_test_result(local_test_id, datadog_status)
|
|
359
416
|
end
|
|
360
417
|
end
|
|
361
418
|
end
|
|
@@ -104,9 +104,9 @@ module Datadog
|
|
|
104
104
|
@test_skipping_enabled = @enabled && remote_configuration.tests_skipping_enabled?
|
|
105
105
|
@code_coverage_enabled = @enabled && remote_configuration.code_coverage_enabled?
|
|
106
106
|
|
|
107
|
-
test_session.
|
|
108
|
-
test_session.
|
|
109
|
-
test_session.
|
|
107
|
+
test_session.set_internal_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED, @test_skipping_enabled)
|
|
108
|
+
test_session.set_internal_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED, @code_coverage_enabled)
|
|
109
|
+
test_session.set_internal_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_TYPE, @test_skipping_mode)
|
|
110
110
|
|
|
111
111
|
if @code_coverage_enabled
|
|
112
112
|
load_datadog_cov!
|
|
@@ -304,8 +304,8 @@ module Datadog
|
|
|
304
304
|
def mark_if_skippable(test)
|
|
305
305
|
return if !enabled? || !skipping_tests?
|
|
306
306
|
|
|
307
|
-
if skippable?(test.datadog_test_id) && !test.
|
|
308
|
-
test.
|
|
307
|
+
if skippable?(test.datadog_test_id) && !test.should_retry_attempt_to_fix?
|
|
308
|
+
test.set_internal_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")
|
|
309
309
|
|
|
310
310
|
Datadog.logger.debug { "Marked test as skippable: #{test.datadog_test_id}" }
|
|
311
311
|
else
|
|
@@ -326,13 +326,13 @@ module Datadog
|
|
|
326
326
|
|
|
327
327
|
if unskippable
|
|
328
328
|
Utils::Telemetry.itr_forced_run
|
|
329
|
-
test_suite.
|
|
329
|
+
test_suite.set_internal_tag(Ext::Test::TAG_ITR_FORCED_RUN, "true")
|
|
330
330
|
|
|
331
331
|
Datadog.logger.debug { "Forced run of skippable test suite: #{test_suite.name}" }
|
|
332
332
|
return
|
|
333
333
|
end
|
|
334
334
|
|
|
335
|
-
test_suite.
|
|
335
|
+
test_suite.set_internal_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")
|
|
336
336
|
test_suite.skipped!(reason: Ext::Test::SkipReason::TEST_IMPACT_ANALYSIS)
|
|
337
337
|
|
|
338
338
|
Datadog.logger.debug { "Marked test suite as skippable: #{test_suite.name}" }
|
|
@@ -357,8 +357,8 @@ module Datadog
|
|
|
357
357
|
else
|
|
358
358
|
test_suite.tests_skipped_by_tia_count
|
|
359
359
|
end
|
|
360
|
-
test_suite.
|
|
361
|
-
test_suite.
|
|
360
|
+
test_suite.set_internal_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, skipped_count.positive?.to_s)
|
|
361
|
+
test_suite.set_internal_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_COUNT, skipped_count)
|
|
362
362
|
|
|
363
363
|
return unless suite_skipping_mode?
|
|
364
364
|
|
|
@@ -390,8 +390,8 @@ module Datadog
|
|
|
390
390
|
Datadog.logger.debug { "Finished optimised session with test skipping enabled: #{@test_skipping_enabled}" }
|
|
391
391
|
Datadog.logger.debug { "#{skipped_tests_count} tests were skipped" }
|
|
392
392
|
|
|
393
|
-
test_session.
|
|
394
|
-
test_session.
|
|
393
|
+
test_session.set_internal_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, skipped_tests_count.positive?.to_s)
|
|
394
|
+
test_session.set_internal_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_COUNT, skipped_tests_count)
|
|
395
395
|
end
|
|
396
396
|
|
|
397
397
|
def shutdown!
|
|
@@ -123,7 +123,7 @@ module Datadog
|
|
|
123
123
|
|
|
124
124
|
# mark the test session so that all events emitted in this session are tagged
|
|
125
125
|
# with the hidden _dd.ci.library_configuration_error.skippable_tests tag
|
|
126
|
-
test_session.
|
|
126
|
+
test_session.set_internal_tag(Ext::Test::LibraryConfigurationError::TAG_SKIPPABLE_TESTS, "true")
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
Response.from_http_response(http_response)
|