From f9561f902944cf16fcd88b5fa62cfc22e228bb12 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 6 Mar 2024 19:27:46 +0100 Subject: [PATCH 1/2] use framework name as test module name to make test fingerprints stable --- lib/datadog/ci/contrib/cucumber/formatter.rb | 4 ++-- lib/datadog/ci/contrib/minitest/runner.rb | 4 ++-- lib/datadog/ci/contrib/rspec/runner.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/datadog/ci/contrib/cucumber/formatter.rb b/lib/datadog/ci/contrib/cucumber/formatter.rb index 1ab2e4e1..885534ef 100644 --- a/lib/datadog/ci/contrib/cucumber/formatter.rb +++ b/lib/datadog/ci/contrib/cucumber/formatter.rb @@ -34,14 +34,14 @@ def bind_events(config) end def on_test_run_started(event) - test_session = CI.start_test_session( + CI.start_test_session( tags: { CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK, CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s }, service: configuration[:service_name] ) - CI.start_test_module(test_session.name) if test_session + CI.start_test_module(Ext::FRAMEWORK) end def on_test_run_finished(event) diff --git a/lib/datadog/ci/contrib/minitest/runner.rb b/lib/datadog/ci/contrib/minitest/runner.rb index f4ebbcad..cc65f276 100644 --- a/lib/datadog/ci/contrib/minitest/runner.rb +++ b/lib/datadog/ci/contrib/minitest/runner.rb @@ -18,14 +18,14 @@ def init_plugins(*) return unless datadog_configuration[:enabled] - test_session = CI.start_test_session( + CI.start_test_session( tags: { CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK, CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s }, service: datadog_configuration[:service_name] ) - CI.start_test_module(test_session.name) if test_session + CI.start_test_module(Ext::FRAMEWORK) end private diff --git a/lib/datadog/ci/contrib/rspec/runner.rb b/lib/datadog/ci/contrib/rspec/runner.rb index b9aed9c1..1c8a1776 100644 --- a/lib/datadog/ci/contrib/rspec/runner.rb +++ b/lib/datadog/ci/contrib/rspec/runner.rb @@ -25,7 +25,7 @@ def run_specs(*) service: datadog_configuration[:service_name] ) - test_module = CI.start_test_module(test_session.name) if test_session + test_module = CI.start_test_module(Ext::FRAMEWORK) result = super return result unless test_module && test_session From 0af64239248c0d18b376e6a424bac7546e0428d6 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Thu, 7 Mar 2024 12:17:07 +0100 Subject: [PATCH 2/2] fix test suite to reflect test module name changes --- lib/datadog/ci/contrib/rspec/runner.rb | 1 - spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb | 4 ++-- spec/datadog/ci/contrib/minitest/instrumentation_spec.rb | 2 +- spec/datadog/ci/contrib/rspec/instrumentation_spec.rb | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/datadog/ci/contrib/rspec/runner.rb b/lib/datadog/ci/contrib/rspec/runner.rb index 1c8a1776..29d4c692 100644 --- a/lib/datadog/ci/contrib/rspec/runner.rb +++ b/lib/datadog/ci/contrib/rspec/runner.rb @@ -31,7 +31,6 @@ def run_specs(*) return result unless test_module && test_session if result != 0 - # TODO: repeating this twice feels clunky, we need to remove test_module API before GA test_module.failed! test_session.failed! else diff --git a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb index 581e40aa..b4099f2a 100644 --- a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb @@ -145,7 +145,7 @@ it "creates test module span" do expect(test_module_span).not_to be_nil - expect(test_module_span.name).to eq(test_command) + expect(test_module_span.name).to eq("cucumber") expect(test_module_span.service).to eq("jalapenos") expect(test_module_span).to have_test_tag(:span_kind, "test") expect(test_module_span).to have_test_tag(:framework, "cucumber") @@ -171,7 +171,7 @@ it "connects test span to test session, test module, and test suite" do expect(first_test_span).to have_test_tag(:test_module_id, test_module_span.id.to_s) - expect(first_test_span).to have_test_tag(:module, test_command) + expect(first_test_span).to have_test_tag(:module, "cucumber") expect(first_test_span).to have_test_tag(:test_session_id, test_session_span.id.to_s) expect(first_test_span).to have_test_tag(:test_suite_id, first_test_suite_span.id.to_s) expect(first_test_span).to have_test_tag(:suite, first_test_suite_span.name) diff --git a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb index c3e019dc..b92e2492 100644 --- a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb @@ -425,7 +425,7 @@ def test_pass_other expect(test_module_span).not_to be_nil expect(test_module_span.type).to eq("test_module_end") - expect(test_module_span.name).to eq(test_command) + expect(test_module_span.name).to eq("minitest") expect(test_module_span).to have_test_tag(:span_kind, "test") expect(test_module_span).to have_test_tag(:framework, "minitest") diff --git a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb index 83d23894..2337400c 100644 --- a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb @@ -469,7 +469,7 @@ def rspec_session_run(with_failed_test: false, with_shared_test: false) expect(test_module_span).not_to be_nil expect(test_module_span.type).to eq("test_module_end") - expect(test_module_span.name).to eq(test_command) + expect(test_module_span.name).to eq("rspec") expect(test_module_span).to have_test_tag(:span_kind, "test") expect(test_module_span).to have_test_tag(:framework, "rspec")