-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathqueue.rb
More file actions
70 lines (61 loc) · 1.57 KB
/
queue.rb
File metadata and controls
70 lines (61 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# frozen_string_literal: true
require 'uri'
require 'cgi'
require 'json'
require 'ci/queue/version'
require 'ci/queue/output_helpers'
require 'ci/queue/circuit_breaker'
require 'ci/queue/configuration'
require 'ci/queue/common'
require 'ci/queue/build_record'
require 'ci/queue/static'
require 'ci/queue/file'
require 'ci/queue/grind'
require 'ci/queue/bisect'
module CI
module Queue
extend self
attr_accessor :shuffler, :requeueable
module Warnings
RESERVED_LOST_TEST = :RESERVED_LOST_TEST
end
GET_NOW = ::Time.method(:now)
private_constant :GET_NOW
def time_now
# Mocks like freeze_time should be cleaned when ci-queue runs, however,
# we experienced cases when tests were enqueued with wrong timestamps, so we
# safeguard Time.now here.
GET_NOW.call
end
def requeueable?(test_result)
requeueable.nil? || requeueable.call(test_result)
end
def shuffle(tests, random)
if shuffler
shuffler.call(tests, random)
else
tests.sort.shuffle(random: random)
end
end
def from_uri(url, config)
uri = URI(url)
implementation = case uri.scheme
when 'list'
Static
when 'file', nil
File
when 'redis', 'rediss'
require 'ci/queue/redis'
if config.multi_queue_config
require 'ci/queue/multi_queue'
MultiQueue
else
Redis
end
else
raise ArgumentError, "Don't know how to handle #{uri.scheme} URLs"
end
implementation.from_uri(uri, config)
end
end
end