Skip to content

Commit

Permalink
Make sure that suites, modules, session ids are integers
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Dec 4, 2023
1 parent f0adcbe commit 1185679
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Gemfile-*.lock
.envrc
.ruby-version
.DS_Store
/test.rb
10 changes: 7 additions & 3 deletions lib/datadog/ci/test_visibility/serializers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ def parent_id
end

def test_session_id
@span.get_tag(Ext::Test::TAG_TEST_SESSION_ID)
to_integer(@span.get_tag(Ext::Test::TAG_TEST_SESSION_ID))
end

def test_module_id
@span.get_tag(Ext::Test::TAG_TEST_MODULE_ID)
to_integer(@span.get_tag(Ext::Test::TAG_TEST_MODULE_ID))
end

def test_suite_id
@span.get_tag(Ext::Test::TAG_TEST_SUITE_ID)
to_integer(@span.get_tag(Ext::Test::TAG_TEST_SUITE_ID))
end

def type
Expand Down Expand Up @@ -181,6 +181,10 @@ def time_nano(time)
def duration_nano(duration)
(duration * 1e9).to_i
end

def to_integer(value)
value.to_i if value
end
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions sig/datadog/ci/test_visibility/serializers/base.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ module Datadog

def parent_id: () -> String

def test_session_id: () -> String?
def test_session_id: () -> Integer?

def test_module_id: () -> String?
def test_module_id: () -> Integer?

def test_suite_id: () -> String?
def test_suite_id: () -> Integer?

def type: () -> nil

Expand Down Expand Up @@ -75,6 +75,8 @@ module Datadog
def time_nano: (Time time) -> Integer
def duration_nano: (Float duration) -> Integer

def to_integer: (String? value) -> Integer?

def content_fields_count: () -> Integer
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

expect(content).to include(
{
"test_session_id" => test_session_span.id.to_s,
"test_module_id" => test_module_span.id.to_s,
"test_session_id" => test_session_span.id,
"test_module_id" => test_module_span.id,
"name" => "rspec.test_module",
"service" => "rspec-test-suite",
"type" => Datadog::CI::Ext::AppTypes::TYPE_TEST_MODULE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

expect(content).to include(
{
"test_session_id" => test_session_span.id.to_s,
"test_session_id" => test_session_span.id,
"name" => "rspec.test_session",
"service" => "rspec-test-suite",
"type" => Datadog::CI::Ext::AppTypes::TYPE_TEST_SESSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

expect(content).to include(
{
"test_session_id" => test_session_span.id.to_s,
"test_module_id" => test_module_span.id.to_s,
"test_suite_id" => test_suite_span.id.to_s,
"test_session_id" => test_session_span.id,
"test_module_id" => test_module_span.id,
"test_suite_id" => test_suite_span.id,
"name" => "rspec.test_suite",
"error" => 0,
"service" => "rspec-test-suite",
Expand Down
8 changes: 4 additions & 4 deletions spec/datadog/ci/test_visibility/serializers/test_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"service" => "rspec-test-suite",
"type" => "test",
"resource" => "calculator_tests.test_add.run.0",
"test_session_id" => test_session_span.id.to_s,
"test_module_id" => test_module_span.id.to_s,
"test_suite_id" => test_suite_span.id.to_s
"test_session_id" => test_session_span.id,
"test_module_id" => test_module_span.id,
"test_suite_id" => test_suite_span.id
}
)

Expand Down Expand Up @@ -70,7 +70,7 @@
"service" => "rspec-test-suite",
"type" => "test",
"resource" => "calculator_tests.test_add.run.#{index}",
"test_session_id" => test_session_span.id.to_s
"test_session_id" => test_session_span.id
}
)
end
Expand Down

0 comments on commit 1185679

Please sign in to comment.