Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO TICKET] more debug logging, do not skip tests when running in forked processes #168

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/UpgradeGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@ VCR.configure do |config|
end
end
```

## Upgrade tracing auto instrumentation

If you use auto instrumenation feature from tracing you need to change the require:

```ruby
# === Before ===
require 'ddtrace/auto_instrument'

# === After ===
require 'datadog/auto_instrument'
```
3 changes: 3 additions & 0 deletions lib/datadog/ci/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def activate_ci!(settings)
# Choose user defined TraceFlush or default to CI TraceFlush
settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new

# startup logs are useless for CI visibility and create noise
settings.diagnostics.startup_logs.enabled = false

# transport creation
writer_options = settings.ci.writer_options
coverage_writer = nil
Expand Down
8 changes: 7 additions & 1 deletion lib/datadog/ci/itr/coverage/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ def write(event)
def perform(*events)
responses = transport.send_events(events)

loop_back_off! if responses.find(&:server_error?)
if responses.find(&:server_error?)
loop_back_off!
Datadog.logger.warn { "Encountered server error while sending coverage events" }
end

nil
rescue => e
Datadog.logger.warn { "Error while sending coverage events: #{e}" }
loop_back_off!
end

def stop(force_stop = false, timeout = @shutdown_timeout)
Expand Down
13 changes: 11 additions & 2 deletions lib/datadog/ci/itr/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def mark_if_skippable(test)

skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters)
if @skippable_tests.include?(skippable_test_id)
if forked?
Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
return
end

test.set_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")

Datadog.logger.debug { "Marked test as skippable: #{skippable_test_id}" }
Expand All @@ -138,13 +143,13 @@ def mark_if_skippable(test)
end

def count_skipped_test(test)
return if !test.skipped? || !test.skipped_by_itr?

if forked?
Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
return
end

return if !test.skipped? || !test.skipped_by_itr?

@mutex.synchronize do
@skipped_tests_count += 1
end
Expand All @@ -153,6 +158,9 @@ def count_skipped_test(test)
def write_test_session_tags(test_session)
return if !enabled?

Datadog.logger.debug { "Finished ITR session with test skipping enabled: #{@test_skipping_enabled}" }
Datadog.logger.debug { "#{@skipped_tests_count} tests were skipped" }

test_session.set_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, @skipped_tests_count.positive?.to_s)
test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_COUNT, @skipped_tests_count)
end
Expand Down Expand Up @@ -201,6 +209,7 @@ def fetch_skippable_tests(test_session:, git_tree_upload_worker:)
@skippable_tests = skippable_response.tests

Datadog.logger.debug { "Fetched skippable tests: \n #{@skippable_tests}" }
Datadog.logger.debug { "Found #{@skippable_tests.count} skippable tests." }
Datadog.logger.debug { "ITR correlation ID: #{@correlation_id}" }
end
end
Expand Down
Loading