Skip to content

Commit

Permalink
remove unneeded parameters from TestVisibility::Transport
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Oct 17, 2023
1 parent 8dbbf5c commit 382552f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
16 changes: 5 additions & 11 deletions lib/datadog/ci/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(settings)
end

def activate_ci!(settings)
agentless_transport = nil
test_visibility_transport = nil

if settings.ci.agentless_mode_enabled
if settings.api_key.nil?
Expand All @@ -34,7 +34,7 @@ def activate_ci!(settings)
settings.ci.enabled = false
return
else
agentless_transport = build_agentless_transport(settings)
test_visibility_transport = build_test_visibility_transport(settings)
end
end

Expand All @@ -51,8 +51,8 @@ def activate_ci!(settings)
settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Finished.new

writer_options = settings.ci.writer_options
if agentless_transport
writer_options[:transport] = agentless_transport
if test_visibility_transport
writer_options[:transport] = test_visibility_transport
writer_options[:shutdown_timeout] = 60

settings.tracing.test_mode.async = true
Expand All @@ -61,15 +61,9 @@ def activate_ci!(settings)
settings.tracing.test_mode.writer_options = writer_options
end

def build_agentless_transport(settings)
dd_site = settings.site || "datadoghq.com"
agentless_url = settings.ci.agentless_url ||
"https://#{Ext::Transport::TEST_VISIBILITY_INTAKE_HOST_PREFIX}.#{dd_site}:443"

def build_test_visibility_transport(settings)
Datadog::CI::TestVisibility::Transport.new(
api: Transport::Api::Builder.build_ci_test_cycle_api(settings),
api_key: settings.api_key,
url: agentless_url,
dd_env: settings.env
)
end
Expand Down
4 changes: 0 additions & 4 deletions lib/datadog/ci/test_visibility/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ class Transport

attr_reader :serializers_factory,
:api,
:api_key,
:max_payload_size,
:dd_env

def initialize(
api_key:,
url:,
api:,
dd_env: nil,
serializers_factory: Datadog::CI::TestVisibility::Serializers::Factories::TestLevel,
max_payload_size: DEFAULT_MAX_PAYLOAD_SIZE
)
@serializers_factory = serializers_factory
@api_key = api_key
@max_payload_size = max_payload_size
@dd_env = dd_env
@api = api
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/ci/configuration/components.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Datadog

def activate_ci!: (untyped settings) -> untyped

def build_agentless_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport
def build_test_visibility_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions sig/datadog/ci/test_visibility/transport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ module Datadog
DEFAULT_MAX_PAYLOAD_SIZE: Integer

attr_reader serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel)
attr_reader api_key: String
attr_reader dd_env: String?
attr_reader api: Datadog::CI::Transport::Api::Base
attr_reader max_payload_size: Integer

@api_key: String
@dd_env: String?
@serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel)
@max_payload_size: Integer

def initialize: (
api: Datadog::CI::Transport::Api::Base,
api_key: String,
url: ::String,
?dd_env: ::String?,
?serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel),
?max_payload_size: Integer
Expand Down
4 changes: 0 additions & 4 deletions spec/datadog/ci/test_visibility/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
subject do
described_class.new(
api: api,
api_key: api_key,
dd_env: dd_env,
url: url,
serializers_factory: serializers_factory,
max_payload_size: max_payload_size
)
end

let(:dd_env) { nil }
let(:api_key) { "api_key" }
let(:url) { "https://citestcycle-intake.datad0ghq.com:443" }
let(:serializers_factory) { Datadog::CI::TestVisibility::Serializers::Factories::TestLevel }
let(:max_payload_size) { 4 * 1024 * 1024 }

Expand Down

0 comments on commit 382552f

Please sign in to comment.