Class: KnapsackPro::RegularAllocator

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/regular_allocator.rb

Defined Under Namespace

Classes: Split

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ RegularAllocator

Returns a new instance of RegularAllocator.



33
34
35
36
37
38
# File 'lib/knapsack_pro/regular_allocator.rb', line 33

def initialize(args)
  @test_suite = args.fetch(:test_suite)
  @ci_node_total = args.fetch(:ci_node_total)
  @ci_node_index = args.fetch(:ci_node_index)
  @repository_adapter = args.fetch(:repository_adapter)
end

Instance Method Details

#test_file_pathsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/knapsack_pro/regular_allocator.rb', line 40

def test_file_paths
  split = pull_tests

  return switch_to_fallback_mode if split.connection_failed?
  return normalize_test_files(split.test_files) if split.exists?

  test_files_result = test_suite.calculate_test_files

  return try_initializing_test_suite_split(test_files_result.test_files) if test_files_result.quick?

  # The tests to run were found slowly. By that time, the test suite split could have already been initialized by another CI node.
  # Attempt to pull tests to avoid the attempt to initialize the test suite split unnecessarily (test suite split initialization is an expensive request with a big test files payload).
  split = pull_tests

  return switch_to_fallback_mode if split.connection_failed?
  return normalize_test_files(split.test_files) if split.exists?

  try_initializing_test_suite_split(test_files_result.test_files)
end