Class: KnapsackPro::QueueAllocator
- Inherits:
-
Object
- Object
- KnapsackPro::QueueAllocator
- Defined in:
- lib/knapsack_pro/queue_allocator.rb
Defined Under Namespace
Classes: Batch
Constant Summary collapse
- FallbackModeError =
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(args) ⇒ QueueAllocator
constructor
A new instance of QueueAllocator.
- #test_file_paths(can_initialize_queue, executed_test_files) ⇒ Object
Constructor Details
#initialize(args) ⇒ QueueAllocator
Returns a new instance of QueueAllocator.
35 36 37 38 39 40 41 42 |
# File 'lib/knapsack_pro/queue_allocator.rb', line 35 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) @ci_node_build_id = args.fetch(:ci_node_build_id) @repository_adapter = args.fetch(:repository_adapter) @fallback_mode = false end |
Instance Method Details
#test_file_paths(can_initialize_queue, executed_test_files) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/knapsack_pro/queue_allocator.rb', line 44 def test_file_paths(can_initialize_queue, executed_test_files) return [] if @fallback_mode batch = pull_tests_from_queue(can_initialize_queue) return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed? return normalize_test_files(batch.test_files) if batch.queue_exists? test_files_result = test_suite.calculate_test_files return try_initializing_queue(test_files_result.test_files) if test_files_result.quick? # The tests to run were found slowly. By that time, the queue could have already been initialized by another CI node. # Attempt to pull tests from the queue to avoid the attempt to initialize the queue unnecessarily (queue initialization is an expensive request with a big test files payload). batch = pull_tests_from_queue(can_initialize_queue) return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed? return normalize_test_files(batch.test_files) if batch.queue_exists? try_initializing_queue(test_files_result.test_files) end |