datadog-ci 1.41.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 +43 -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/components.rb +2 -1
- data/lib/datadog/ci/configuration/extensions.rb +2 -0
- data/lib/datadog/ci/configuration/reconfiguration.rb +29 -0
- data/lib/datadog/ci/configuration/settings.rb +9 -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/runner.rb +14 -1
- 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_discovery/component.rb +7 -1
- data/lib/datadog/ci/test_discovery/null_component.rb +4 -0
- data/lib/datadog/ci/test_impact_analysis/component.rb +21 -10
- 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_suite.rb +11 -0
- data/lib/datadog/ci/test_tracing/component.rb +28 -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 +10 -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
- data/lib/datadog/ci.rb +3 -0
- metadata +4 -1
|
@@ -18,19 +18,28 @@ module Datadog
|
|
|
18
18
|
:hostname,
|
|
19
19
|
:port,
|
|
20
20
|
:timeout,
|
|
21
|
-
:ssl
|
|
21
|
+
:ssl,
|
|
22
|
+
:uds_path
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
# With uds_path, connects to the Unix domain socket at that path
|
|
25
|
+
# instead of hostname and port.
|
|
26
|
+
def initialize(hostname:, port:, ssl:, timeout_seconds:, uds_path: nil)
|
|
24
27
|
@hostname = hostname
|
|
25
28
|
@port = port
|
|
26
29
|
@timeout = timeout_seconds
|
|
27
30
|
@ssl = ssl
|
|
31
|
+
@uds_path = uds_path
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def open(&block)
|
|
31
|
-
|
|
35
|
+
path = uds_path
|
|
36
|
+
req = if path
|
|
37
|
+
NetHttpClient.unix_socket_net_http(path)
|
|
38
|
+
else
|
|
39
|
+
# Without a socket, the agent settings or the agentless intake give a host.
|
|
40
|
+
NetHttpClient.original_net_http.new(_ = hostname, port).tap { |http| http.use_ssl = ssl }
|
|
41
|
+
end
|
|
32
42
|
|
|
33
|
-
req.use_ssl = ssl
|
|
34
43
|
req.open_timeout = req.read_timeout = timeout
|
|
35
44
|
|
|
36
45
|
req.start(&block)
|
|
@@ -140,6 +149,17 @@ module Datadog
|
|
|
140
149
|
nil
|
|
141
150
|
end
|
|
142
151
|
|
|
152
|
+
# Whether the request failed with an error the transport doesn't expect,
|
|
153
|
+
# which it used to raise; see Transport::HTTP.
|
|
154
|
+
def unexpected_error?
|
|
155
|
+
false
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Whether the request failed with a server error or an unexpected transport error.
|
|
159
|
+
def system_error?
|
|
160
|
+
server_error? || unexpected_error?
|
|
161
|
+
end
|
|
162
|
+
|
|
143
163
|
def telemetry_error_type
|
|
144
164
|
return nil if ok?
|
|
145
165
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "socket"
|
|
5
|
+
require "timeout"
|
|
6
|
+
|
|
3
7
|
module Datadog
|
|
4
8
|
module CI
|
|
5
9
|
module Transport
|
|
@@ -10,6 +14,33 @@ module Datadog
|
|
|
10
14
|
|
|
11
15
|
WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP
|
|
12
16
|
end
|
|
17
|
+
|
|
18
|
+
# A Net::HTTP connection to an agent on a Unix domain socket. Like the
|
|
19
|
+
# TCP connections, it is built on original_net_http so that WebMock
|
|
20
|
+
# leaves it alone; the host and port only go in the Host header.
|
|
21
|
+
def self.unix_socket_net_http(uds_path)
|
|
22
|
+
# @type var http: Net::HTTP & UnixSocketConnection
|
|
23
|
+
http = _ = original_net_http.new("localhost", 80).extend(UnixSocketConnection)
|
|
24
|
+
http.uds_path = uds_path
|
|
25
|
+
http
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Connects a Net::HTTP to a Unix domain socket instead of a host and port.
|
|
29
|
+
module UnixSocketConnection
|
|
30
|
+
attr_accessor :uds_path
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def connect
|
|
35
|
+
unix_socket = ::Timeout.timeout(open_timeout, ::Net::OpenTimeout) { ::UNIXSocket.new(uds_path) }
|
|
36
|
+
@socket = ::Net::BufferedIO.new(
|
|
37
|
+
unix_socket,
|
|
38
|
+
read_timeout: read_timeout,
|
|
39
|
+
write_timeout: write_timeout,
|
|
40
|
+
continue_timeout: continue_timeout
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
13
44
|
end
|
|
14
45
|
end
|
|
15
46
|
end
|
|
@@ -18,7 +18,8 @@ module Datadog
|
|
|
18
18
|
:port,
|
|
19
19
|
:ssl,
|
|
20
20
|
:timeout,
|
|
21
|
-
:compress
|
|
21
|
+
:compress,
|
|
22
|
+
:uds_path
|
|
22
23
|
|
|
23
24
|
DEFAULT_TIMEOUT = 30
|
|
24
25
|
MAX_RETRIES = 3
|
|
@@ -40,9 +41,10 @@ module Datadog
|
|
|
40
41
|
SocketError # DNS/network issues
|
|
41
42
|
].freeze
|
|
42
43
|
|
|
43
|
-
def initialize(host:, port:, timeout: DEFAULT_TIMEOUT, ssl: true, compress: false)
|
|
44
|
+
def initialize(host:, port:, timeout: DEFAULT_TIMEOUT, ssl: true, compress: false, uds_path: nil)
|
|
44
45
|
@host = host
|
|
45
46
|
@port = port
|
|
47
|
+
@uds_path = uds_path
|
|
46
48
|
@timeout = timeout
|
|
47
49
|
@ssl = ssl.nil? || ssl
|
|
48
50
|
@compress = compress.nil? ? false : compress
|
|
@@ -70,7 +72,7 @@ module Datadog
|
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
Datadog.logger.debug do
|
|
73
|
-
"Sending #{verb} request: host=#{host}; port=#{port}; ssl_enabled=#{ssl}; " \
|
|
75
|
+
"Sending #{verb} request: host=#{host}; port=#{port}; uds_path=#{uds_path}; ssl_enabled=#{ssl}; " \
|
|
74
76
|
"compression_enabled=#{compress}; path=#{path}; payload_size=#{payload.size}"
|
|
75
77
|
end
|
|
76
78
|
|
|
@@ -88,6 +90,10 @@ module Datadog
|
|
|
88
90
|
response.request_size = payload.bytesize
|
|
89
91
|
response.duration_ms = duration_ms
|
|
90
92
|
|
|
93
|
+
if response.server_error?
|
|
94
|
+
Datadog.logger.warn("Failed to send request to #{path} with server error #{response.code}")
|
|
95
|
+
end
|
|
96
|
+
|
|
91
97
|
response
|
|
92
98
|
end
|
|
93
99
|
|
|
@@ -119,6 +125,11 @@ module Datadog
|
|
|
119
125
|
rescue *RETRIABLE_ERRORS => e
|
|
120
126
|
Datadog.logger.debug { "Failed to send request with retriable error #{e} (#{e.message})" }
|
|
121
127
|
response = ErrorResponse.new(e)
|
|
128
|
+
rescue => e
|
|
129
|
+
# Any other error, such as a refused connection (Errno::ECONNREFUSED) or a
|
|
130
|
+
# TLS failure, would otherwise reach the customer's test process.
|
|
131
|
+
Datadog.logger.warn("Failed to send request to #{path} with unexpected error #{e.class} (#{e.message})")
|
|
132
|
+
return ErrorResponse.new(e)
|
|
122
133
|
end
|
|
123
134
|
|
|
124
135
|
# Check if we've exceeded the maximum retry time
|
|
@@ -153,7 +164,7 @@ module Datadog
|
|
|
153
164
|
|
|
154
165
|
def adapter
|
|
155
166
|
@adapter ||= Datadog::CI::Transport::Adapters::Net.new(
|
|
156
|
-
hostname: host, port: port, ssl: ssl, timeout_seconds: timeout
|
|
167
|
+
hostname: host, port: port, ssl: ssl, timeout_seconds: timeout, uds_path: uds_path
|
|
157
168
|
)
|
|
158
169
|
end
|
|
159
170
|
|
|
@@ -164,6 +175,11 @@ module Datadog
|
|
|
164
175
|
|
|
165
176
|
attr_reader :error
|
|
166
177
|
|
|
178
|
+
def unexpected_error?
|
|
179
|
+
NON_RETRIABLE_ERRORS.none? { |type| type === error } &&
|
|
180
|
+
RETRIABLE_ERRORS.none? { |type| type === error }
|
|
181
|
+
end
|
|
182
|
+
|
|
167
183
|
def payload
|
|
168
184
|
""
|
|
169
185
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../ext/metadata"
|
|
4
|
+
|
|
5
|
+
module Datadog
|
|
6
|
+
module CI
|
|
7
|
+
module Utils
|
|
8
|
+
module ProtectedTags
|
|
9
|
+
@mutex = Mutex.new
|
|
10
|
+
@reported = {}
|
|
11
|
+
|
|
12
|
+
def self.reject?(key, operation)
|
|
13
|
+
return false unless Ext::Metadata::PROTECTED_TAGS.include?(key.to_s)
|
|
14
|
+
|
|
15
|
+
report = @mutex.synchronize do
|
|
16
|
+
id = [key.to_s.dup.freeze, operation]
|
|
17
|
+
next false if @reported.key?(id)
|
|
18
|
+
|
|
19
|
+
@reported[id] = true
|
|
20
|
+
end
|
|
21
|
+
Datadog.logger.error("Ignoring #{operation} for SDK-owned tag #{key}; use the supported configuration or instrumentation API") if report
|
|
22
|
+
true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/datadog/ci/utils/rum.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Datadog
|
|
|
23
23
|
def self.stop_rum_session(script_executor, rum_flush_wait_millis: 500)
|
|
24
24
|
return unless is_rum_active?(script_executor)
|
|
25
25
|
|
|
26
|
-
Datadog::CI.active_test&.
|
|
26
|
+
Datadog::CI.active_test&.set_internal_tag(
|
|
27
27
|
CI::Ext::Test::TAG_IS_RUM_ACTIVE,
|
|
28
28
|
"true"
|
|
29
29
|
)
|
data/lib/datadog/ci/version.rb
CHANGED
data/lib/datadog/ci.rb
CHANGED
|
@@ -24,6 +24,9 @@ module Datadog
|
|
|
24
24
|
#
|
|
25
25
|
# Returns the existing test session if one is already active. There is at most a single test session per process.
|
|
26
26
|
#
|
|
27
|
+
# Complete all `Datadog.configure` calls before starting the session.
|
|
28
|
+
# Concurrent configuration and session startup are unsupported.
|
|
29
|
+
#
|
|
27
30
|
# The {.start_test_session} method is used to mark the start of the test session:
|
|
28
31
|
# ```
|
|
29
32
|
# Datadog::CI.start_test_session(
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datadog-ci
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.43.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Datadog, Inc.
|
|
@@ -100,6 +100,7 @@ files:
|
|
|
100
100
|
- lib/datadog/ci/concurrent_span.rb
|
|
101
101
|
- lib/datadog/ci/configuration/components.rb
|
|
102
102
|
- lib/datadog/ci/configuration/extensions.rb
|
|
103
|
+
- lib/datadog/ci/configuration/reconfiguration.rb
|
|
103
104
|
- lib/datadog/ci/configuration/settings.rb
|
|
104
105
|
- lib/datadog/ci/configuration/tracing_compatibility.rb
|
|
105
106
|
- lib/datadog/ci/contrib/activesupport/configuration/settings.rb
|
|
@@ -203,6 +204,7 @@ files:
|
|
|
203
204
|
- lib/datadog/ci/ext/environment/providers/travis.rb
|
|
204
205
|
- lib/datadog/ci/ext/environment/providers/user_defined_tags.rb
|
|
205
206
|
- lib/datadog/ci/ext/git.rb
|
|
207
|
+
- lib/datadog/ci/ext/metadata.rb
|
|
206
208
|
- lib/datadog/ci/ext/rum.rb
|
|
207
209
|
- lib/datadog/ci/ext/settings.rb
|
|
208
210
|
- lib/datadog/ci/ext/telemetry.rb
|
|
@@ -316,6 +318,7 @@ files:
|
|
|
316
318
|
- lib/datadog/ci/utils/git.rb
|
|
317
319
|
- lib/datadog/ci/utils/json.rb
|
|
318
320
|
- lib/datadog/ci/utils/parsing.rb
|
|
321
|
+
- lib/datadog/ci/utils/protected_tags.rb
|
|
319
322
|
- lib/datadog/ci/utils/rum.rb
|
|
320
323
|
- lib/datadog/ci/utils/runtime_tags_overrides.rb
|
|
321
324
|
- lib/datadog/ci/utils/stateful.rb
|