-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cae355
commit 443f856
Showing
17 changed files
with
447 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../test_v2" | ||
require_relative "../test_session" | ||
require_relative "../span" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
module Factories | ||
# This factory takes care of creating citestcycle serializers when test-suite-level visibility is enabled | ||
module TestSuiteLevel | ||
module_function | ||
|
||
def serializer(trace, span) | ||
case span.type | ||
when Datadog::CI::Ext::AppTypes::TYPE_TEST | ||
Serializers::TestV2.new(trace, span) | ||
when Datadog::CI::Ext::AppTypes::TYPE_TEST_SESSION | ||
Serializers::TestSession.new(trace, span) | ||
else | ||
Serializers::Span.new(trace, span) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
59 changes: 59 additions & 0 deletions
59
lib/datadog/ci/test_visibility/serializers/test_session.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
require_relative "../../ext/test" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
class TestSession < Base | ||
CONTENT_FIELDS = [ | ||
"test_session_id", | ||
"name", "resource", "service", | ||
"error", "start", "duration", | ||
"meta", "metrics", | ||
"type" => "span_type" | ||
].freeze | ||
|
||
CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) | ||
|
||
REQUIRED_FIELDS = [ | ||
"test_session_id", | ||
"error", | ||
"name", | ||
"resource", | ||
"start", | ||
"duration" | ||
].freeze | ||
|
||
def content_fields | ||
CONTENT_FIELDS | ||
end | ||
|
||
def content_map_size | ||
CONTENT_MAP_SIZE | ||
end | ||
|
||
def type | ||
Ext::AppTypes::TYPE_TEST_SESSION | ||
end | ||
|
||
def name | ||
"#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session" | ||
end | ||
|
||
def resource | ||
"#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session.#{@span.get_tag(Ext::Test::TAG_COMMAND)}" | ||
end | ||
|
||
private | ||
|
||
def required_fields | ||
REQUIRED_FIELDS | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "test_v1" | ||
require_relative "../../ext/test" | ||
|
||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
class TestV2 < TestV1 | ||
CONTENT_FIELDS = [ | ||
"trace_id", "span_id", | ||
"name", "resource", "service", | ||
"error", "start", "duration", | ||
"meta", "metrics", "test_session_id", | ||
"type" => "span_type" | ||
].freeze | ||
|
||
CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) | ||
|
||
REQUIRED_FIELDS = [ | ||
"test_session_id", | ||
"trace_id", | ||
"span_id", | ||
"error", | ||
"name", | ||
"resource", | ||
"start", | ||
"duration" | ||
].freeze | ||
|
||
def content_fields | ||
CONTENT_FIELDS | ||
end | ||
|
||
def content_map_size | ||
CONTENT_MAP_SIZE | ||
end | ||
|
||
def version | ||
2 | ||
end | ||
|
||
private | ||
|
||
def required_fields | ||
REQUIRED_FIELDS | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
sig/datadog/ci/test_visibility/serializers/factories/test_suite_level.rbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
module Factories | ||
module TestSuiteLevel | ||
def self?.serializer: (Datadog::Tracing::TraceSegment trace, Datadog::Tracing::Span span) -> Datadog::CI::TestVisibility::Serializers::Base | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
sig/datadog/ci/test_visibility/serializers/test_session.rbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
class TestSession < Base | ||
CONTENT_FIELDS: Array[String | Hash[String, String]] | ||
CONTENT_MAP_SIZE: Integer | ||
REQUIRED_FIELDS: Array[String] | ||
|
||
def content_fields: () -> Array[String | Hash[String, String]] | ||
def content_map_size: () -> Integer | ||
|
||
def type: () -> ::String | ||
|
||
def name: () -> ::String | ||
|
||
def resource: () -> ::String | ||
|
||
private | ||
|
||
def required_fields: () -> Array[String] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Datadog | ||
module CI | ||
module TestVisibility | ||
module Serializers | ||
class TestV2 < TestV1 | ||
CONTENT_FIELDS: ::Array[String | ::Hash[::String, String]] | ||
|
||
CONTENT_MAP_SIZE: Integer | ||
|
||
REQUIRED_FIELDS: ::Array[String] | ||
|
||
def content_fields: () -> ::Array[String | ::Hash[::String, String]] | ||
|
||
def content_map_size: () -> Integer | ||
|
||
def version: () -> 2 | ||
|
||
private | ||
|
||
def required_fields: () -> Array[String] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/datadog/ci/test_visibility/serializers/factories/test_suite_level_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/factories/test_suite_level" | ||
require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/test_v2" | ||
require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/test_session" | ||
require_relative "../../../../../../lib/datadog/ci/recorder" | ||
|
||
RSpec.describe Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel do | ||
include_context "CI mode activated" do | ||
let(:integration_name) { :rspec } | ||
end | ||
|
||
before do | ||
produce_test_session_trace | ||
end | ||
|
||
subject { described_class.serializer(trace, ci_span) } | ||
|
||
describe ".convert_trace_to_serializable_events" do | ||
context "with a session span" do | ||
let(:ci_span) { test_session_span } | ||
it { is_expected.to be_kind_of(Datadog::CI::TestVisibility::Serializers::TestSession) } | ||
end | ||
|
||
context "with a test span" do | ||
let(:ci_span) { first_test_span } | ||
it { is_expected.to be_kind_of(Datadog::CI::TestVisibility::Serializers::TestV2) } | ||
end | ||
end | ||
end |
Oops, something went wrong.