Skip to content

Commit

Permalink
Merge pull request #168 from DataDog/anmarchenko/debug_skippable_tests
Browse files Browse the repository at this point in the history
[NO TICKET] more debug logging, do not skip tests when running in forked processes
  • Loading branch information
anmarchenko authored Apr 29, 2024
2 parents 4534437 + 4746426 commit 042bb0f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
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

0 comments on commit 042bb0f

Please sign in to comment.