Class: KnapsackPro::QueueAllocator

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ QueueAllocator

Returns a new instance of QueueAllocator.



3
4
5
6
7
8
9
# File 'lib/knapsack_pro/queue_allocator.rb', line 3

def initialize(args)
  @test_files = args.fetch(:test_files)
  @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)
end

Instance Method Details

#test_file_paths(can_initialize_queue, executed_test_files) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/knapsack_pro/queue_allocator.rb', line 11

def test_file_paths(can_initialize_queue, executed_test_files)
  return [] if @fallback_activated
  action = build_action(can_initialize_queue)
  connection = KnapsackPro::Client::Connection.new(action)
  response = connection.call
  if connection.success?
    raise ArgumentError.new(response) if connection.errors?
    prepare_test_files(response)
  else
    @fallback_activated = true
    KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at https://github.com/KnapsackPro/knapsack_pro-ruby#what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily")
    fallback_test_files(executed_test_files)
  end
end