Module: Datadog::CI::Contrib::ParallelTests::CLI::InstanceMethods

Defined in:
lib/datadog/ci/contrib/parallel_tests/cli.rb

Instance Method Summary collapse

Instance Method Details

#any_test_failed?(test_results) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/datadog/ci/contrib/parallel_tests/cli.rb', line 42

def any_test_failed?(test_results)
  res = super

  test_session = test_visibility_component.active_test_session
  test_module = test_visibility_component.active_test_module
  if res
    test_module&.failed!
    test_session&.failed!
  else
    test_module&.passed!
    test_session&.passed!
  end

  res
end

#datadog_configurationObject



72
73
74
# File 'lib/datadog/ci/contrib/parallel_tests/cli.rb', line 72

def datadog_configuration
  Datadog.configuration.ci[:paralleltests]
end

#datadog_extract_rspec_versionObject



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/datadog/ci/contrib/parallel_tests/cli.rb', line 58

def datadog_extract_rspec_version
  # Try to find either 'rspec' or 'rspec-core' gem
  if Gem.loaded_specs["rspec"]
    Gem.loaded_specs["rspec"].version.to_s
  elsif Gem.loaded_specs["rspec-core"]
    Gem.loaded_specs["rspec-core"].version.to_s
  else
    "0.0.0"
  end
rescue => e
  Datadog.logger.debug("Error extracting RSpec version: #{e.class.name} - #{e.message}")
  "0.0.0"
end

#run_tests_in_parallel(num_processes, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datadog/ci/contrib/parallel_tests/cli.rb', line 16

def run_tests_in_parallel(num_processes, options)
  # only rspec runner is supported for now
  return super if @runner != ::ParallelTests::RSpec::Runner

  begin
    test_session = test_visibility_component.start_test_session(
      tags: {
        CI::Ext::Test::TAG_FRAMEWORK => CI::Contrib::RSpec::Ext::FRAMEWORK,
        CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_extract_rspec_version
      },
      service: datadog_configuration[:service_name],
      estimated_total_tests_count: 10_000, # temporary value, updated by child processes
      distributed: true
    )
    test_module = test_visibility_component.start_test_module("rspec")

    options[:env] ||= {}
    options[:env][CI::Ext::Settings::ENV_TEST_VISIBILITY_DRB_SERVER_URI] = test_visibility_component.context_service_uri

    super
  ensure
    test_module&.finish
    test_session&.finish
  end
end

#test_visibility_componentObject



76
77
78
# File 'lib/datadog/ci/contrib/parallel_tests/cli.rb', line 76

def test_visibility_component
  Datadog.send(:components).test_visibility
end