Skip to content

Commit

Permalink
Merge pull request #131 from DataDog/anmarchenko/fix_test_module_names
Browse files Browse the repository at this point in the history
use framework name as test module name to make test fingerprints stable
  • Loading branch information
anmarchenko authored Mar 7, 2024
2 parents e016c07 + 0af6423 commit 0cb187c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/datadog/ci/contrib/cucumber/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/ci/contrib/minitest/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/datadog/ci/contrib/rspec/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ 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

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
Expand Down
4 changes: 2 additions & 2 deletions spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/ci/contrib/minitest/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/ci/contrib/rspec/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0cb187c

Please sign in to comment.