Skip to content

Commit

Permalink
additional constants for new test retries, rename skippable_test_id t…
Browse files Browse the repository at this point in the history
…o datadog_test_id
  • Loading branch information
anmarchenko committed Aug 30, 2024
1 parent 080014c commit a99a46a
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 12 deletions.
6 changes: 6 additions & 0 deletions lib/datadog/ci/ext/telemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ module Telemetry
METRIC_CODE_COVERAGE_IS_EMPTY = "code_coverage.is_empty"
METRIC_CODE_COVERAGE_FILES = "code_coverage.files"

METRIC_EFD_UNIQUE_TESTS_REQUEST = "early_flake_detection.request"
METRIC_EFD_UNIQUE_TESTS_REQUEST_MS = "early_flake_detection.request_ms"
METRIC_EFD_UNIQUE_TESTS_REQUEST_ERRORS = "early_flake_detection.request_errors"
METRIC_EFD_UNIQUE_TESTS_RESPONSE_BYTES = "early_flake_detection.response_bytes"
METRIC_EFD_UNIQUE_TESTS_RESPONSE_TESTS = "early_flake_detection.response_tests"

METRIC_TEST_SESSION = "test_session"

TAG_TEST_FRAMEWORK = "test_framework"
Expand Down
3 changes: 3 additions & 0 deletions lib/datadog/ci/ext/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ module Transport
DD_API_SKIPPABLE_TESTS_PATH = "/api/v2/ci/tests/skippable"
DD_API_SKIPPABLE_TESTS_TYPE = "test_params"

DD_API_UNIQUE_TESTS_PATH = "/api/v2/ci/libraries/tests"
DD_API_UNIQUE_TESTS_TYPE = "ci_app_libraries_tests_request"

CONTENT_TYPE_MESSAGEPACK = "application/msgpack"
CONTENT_TYPE_JSON = "application/json"
CONTENT_TYPE_MULTIPART_FORM_DATA = "multipart/form-data"
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/remote/slow_test_retries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def max_attempts_for_duration(duration)
return entry.max_attempts if duration < entry.duration
end

1
0
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def parameters
private

def record_test_result(datadog_status)
test_id = Utils::TestRun.skippable_test_id(name, test_suite_name, parameters)
test_id = Utils::TestRun.datadog_test_id(name, test_suite_name, parameters)

# if this test was already executed in this test suite, mark it as retried
if test_suite&.test_executed?(test_id)
Expand Down
8 changes: 4 additions & 4 deletions lib/datadog/ci/test_optimisation/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ def stop_coverage(test)
def mark_if_skippable(test)
return if !enabled? || !skipping_tests?

skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters)
if @skippable_tests.include?(skippable_test_id)
datadog_test_id = Utils::TestRun.datadog_test_id(test.name, test.test_suite_name, test.parameters)
if @skippable_tests.include?(datadog_test_id)
if forked?
Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" }
return
end

test.set_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")

Datadog.logger.debug { "Marked test as skippable: #{skippable_test_id}" }
Datadog.logger.debug { "Marked test as skippable: #{datadog_test_id}" }
else
Datadog.logger.debug { "Test is not skippable: #{skippable_test_id}" }
Datadog.logger.debug { "Test is not skippable: #{datadog_test_id}" }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/test_optimisation/skippable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def tests
next unless test_data["type"] == Ext::Test::ITR_TEST_SKIPPING_MODE

attrs = test_data["attributes"] || {}
res << Utils::TestRun.skippable_test_id(attrs["name"], attrs["suite"], attrs["parameters"])
res << Utils::TestRun.datadog_test_id(attrs["name"], attrs["suite"], attrs["parameters"])
end

res
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/utils/test_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.command
@command = "#{$0} #{ARGV.join(" ")}"
end

def self.skippable_test_id(test_name, suite, parameters = nil)
def self.datadog_test_id(test_name, suite, parameters = nil)
"#{suite}.#{test_name}.#{parameters}"
end

Expand Down
10 changes: 10 additions & 0 deletions sig/datadog/ci/ext/telemetry.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ module Datadog

METRIC_ITR_SKIPPABLE_TESTS_RESPONSE_TESTS: "itr_skippable_tests.response_tests"

METRIC_EFD_UNIQUE_TESTS_REQUEST: "early_flake_detection.request"

METRIC_EFD_UNIQUE_TESTS_REQUEST_MS: "early_flake_detection.request_ms"

METRIC_EFD_UNIQUE_TESTS_REQUEST_ERRORS: "early_flake_detection.request_errors"

METRIC_EFD_UNIQUE_TESTS_RESPONSE_BYTES: "early_flake_detection.response_bytes"

METRIC_EFD_UNIQUE_TESTS_RESPONSE_TESTS: "early_flake_detection.response_tests"

METRIC_ITR_SKIPPED: "itr_skipped"

METRIC_ITR_UNSKIPPABLE: "itr_unskippable"
Expand Down
4 changes: 4 additions & 0 deletions sig/datadog/ci/ext/transport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ module Datadog

DD_API_SKIPPABLE_TESTS_TYPE: "test_params"

DD_API_UNIQUE_TESTS_PATH: "/api/v2/ci/libraries/tests"

DD_API_UNIQUE_TESTS_TYPE: "ci_app_libraries_tests_request"

CONTENT_TYPE_MESSAGEPACK: "application/msgpack"

CONTENT_TYPE_JSON: "application/json"
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/ci/utils/test_run.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Datadog

def self.command: () -> String

def self.skippable_test_id: (String test_name, String? test_suite, ?String? parameters) -> String
def self.datadog_test_id: (String test_name, String? test_suite, ?String? parameters) -> String

def self.test_parameters: (?arguments: Hash[untyped, untyped], ?metadata: Hash[untyped, untyped]) -> String

Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/ci/remote/slow_test_retries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
context "when the duration is more than 10 minutes" do
let(:duration) { 600.1 }

it { is_expected.to eq(1) }
it { is_expected.to eq(0) }
end
end
end
4 changes: 2 additions & 2 deletions spec/datadog/ci/utils/test_run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
it { is_expected.to eq("#{$0} #{ARGV.join(" ")}") }
end

describe ".skippable_test_id" do
subject { described_class.skippable_test_id(test_name, suite, parameters) }
describe ".datadog_test_id" do
subject { described_class.datadog_test_id(test_name, suite, parameters) }

let(:test_name) { "test_name" }
let(:suite) { "suite" }
Expand Down

0 comments on commit a99a46a

Please sign in to comment.