ci-queue 0.20.6 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdf8ce628f8d7b21a66f614c867dbd2f568b011f22a467a6d274c51e81294a63
4
- data.tar.gz: c591e50cf510e91d6aa6d6bbf39573b38581002c2dcf2e07f1b57e9edb2abef6
3
+ metadata.gz: a9a1d5f8211c29b9993d6ef94acff329a040d7e940b28e8d51eedc01e87c106b
4
+ data.tar.gz: d584ef67d1f2036b4c8b7880099515ff2a4f0618c2813e9caee099cfe11e587f
5
5
  SHA512:
6
- metadata.gz: 9b5b2c9fe39aa132bda26cc98387349eaddcfb2074e37ed225f675a3e8fb3c50f42dab761f0620b54d1df48ae285b10d75f1b66f07456e05d4bccbfb01116414
7
- data.tar.gz: f92b07076fc21b13efe3a9587f4e57cf7d1d12b1838c37d10fcbeb8b2e4e684a101fd5d9588fa482e06cf45c0e12f1bce212b5d7e9bcf695e4ba8f5fcfdd7864
6
+ metadata.gz: 88ddaa2717da8b9a989fa6d7bf859d509c29d2cf19ade4fcab882f6dfe4b33e1969c5f89121f3b5dfb1439b03e89e41227cf9f9f8e33d7e9295e43c7a2cb8e51
7
+ data.tar.gz: e7f5753cd1bdfd0f7500ebe00be9e7caf3a342ae931b974971bc95aa8ab27e86744211036a4fe70420a80d374235e1eb1ea6ce6eee4e14da52560502f1c26413
@@ -8,6 +8,7 @@ module CI
8
8
  attr_accessor :max_test_failed
9
9
  attr_reader :circuit_breakers
10
10
  attr_writer :seed, :build_id
11
+ attr_writer :queue_init_timeout
11
12
 
12
13
  class << self
13
14
  def from_env(env)
@@ -32,7 +33,8 @@ module CI
32
33
  timeout: 30, build_id: nil, worker_id: nil, max_requeues: 0, requeue_tolerance: 0,
33
34
  namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil,
34
35
  grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil,
35
- max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil
36
+ max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil,
37
+ queue_init_timeout: nil
36
38
  )
37
39
  @build_id = build_id
38
40
  @circuit_breakers = [CircuitBreaker::Disabled]
@@ -48,12 +50,17 @@ module CI
48
50
  @seed = seed
49
51
  @statsd_endpoint = statsd_endpoint
50
52
  @timeout = timeout
53
+ @queue_init_timeout = queue_init_timeout
51
54
  @track_test_duration = track_test_duration
52
55
  @worker_id = worker_id
53
56
  self.max_consecutive_failures = max_consecutive_failures
54
57
  self.max_duration = max_duration
55
58
  end
56
59
 
60
+ def queue_init_timeout
61
+ @queue_init_timeout || timeout
62
+ end
63
+
57
64
  def max_consecutive_failures=(max)
58
65
  if max
59
66
  @circuit_breakers << CircuitBreaker::MaxConsecutiveFailures.new(max_consecutive_failures: max)
@@ -8,7 +8,7 @@ module CI
8
8
  end
9
9
 
10
10
  def total
11
- wait_for_master(timeout: config.timeout)
11
+ wait_for_master(timeout: config.queue_init_timeout)
12
12
  redis.get(key('total')).to_i
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ module CI
17
17
  end
18
18
 
19
19
  def wait_for_workers
20
- return false unless wait_for_master(timeout: config.timeout)
20
+ wait_for_master(timeout: config.queue_init_timeout)
21
21
 
22
22
  yield if block_given?
23
23
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'ci/queue/static'
3
+ require 'set'
3
4
 
4
5
  module CI
5
6
  module Queue
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.20.6'
5
+ VERSION = '0.21.0'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
@@ -7,6 +7,8 @@ require 'fileutils'
7
7
  module Minitest
8
8
  module Queue
9
9
  class JUnitReporter < Minitest::Reporters::BaseReporter
10
+ include ::CI::Queue::OutputHelpers
11
+
10
12
  def initialize(report_path = 'log/junit.xml', options = {})
11
13
  super({})
12
14
  @report_path = File.absolute_path(report_path)
@@ -76,6 +78,8 @@ module Minitest
76
78
 
77
79
  testcase = testsuite.add_element('testcase', attributes)
78
80
  add_xml_message_for(testcase, test) unless test.passed?
81
+ rescue REXML::ParseException, RuntimeError => error
82
+ step(red("Skipping adding '#{suite}##{test.name}' to JUnit report: #{error.message}"))
79
83
  end
80
84
  end
81
85
 
@@ -352,7 +352,7 @@ module Minitest
352
352
 
353
353
  help = <<~EOS
354
354
  Specify a timeout after which if a test haven't completed, it will be picked up by another worker.
355
- It is very important to set this vlaue higher than the slowest test in the suite, otherwise performance will be impacted.
355
+ It is very important to set this value higher than the slowest test in the suite, otherwise performance will be impacted.
356
356
  Defaults to 30 seconds.
357
357
  EOS
358
358
  opts.separator ""
@@ -360,6 +360,15 @@ module Minitest
360
360
  queue_config.timeout = timeout
361
361
  end
362
362
 
363
+ help = <<~EOS
364
+ Specify a timeout to elect the leader and populate the queue.
365
+ Defaults to the value set for --timeout.
366
+ EOS
367
+ opts.separator ""
368
+ opts.on('--queue-init-timeout TIMEOUT', Float, help) do |timeout|
369
+ queue_config.queue_init_timeout = timeout
370
+ end
371
+
363
372
  help = <<~EOS
364
373
  Specify $LOAD_PATH directory, similar to Ruby's -I
365
374
  EOS
@@ -52,6 +52,14 @@ module Minitest
52
52
  @test.time
53
53
  end
54
54
 
55
+ def test_start_timestamp
56
+ @test.start_timestamp
57
+ end
58
+
59
+ def test_finish_timestamp
60
+ @test.finish_timestamp
61
+ end
62
+
55
63
  def test_file_path
56
64
  path = @test.source_location.first
57
65
  begin
@@ -82,7 +90,11 @@ module Minitest
82
90
  return nil unless @test.failure
83
91
 
84
92
  path = error_location(@test.failure).first
85
- relative_path_for(path)
93
+ begin
94
+ relative_path_for(path)
95
+ rescue ArgumentError
96
+ path # e.g. "(eval)" etc.
97
+ end
86
98
  end
87
99
 
88
100
  def error_file_number
@@ -103,6 +115,8 @@ module Minitest
103
115
  test_retried: test_retried,
104
116
  test_assertions: test_assertions,
105
117
  test_duration: test_duration,
118
+ test_start_timestamp: test_start_timestamp,
119
+ test_finish_timestamp: test_finish_timestamp,
106
120
  test_file_path: test_file_path,
107
121
  test_file_line_number: test_file_line_number,
108
122
  error_class: error_class,
@@ -102,6 +102,10 @@ module Minitest
102
102
  end
103
103
  end
104
104
 
105
+ module WithTimestamps
106
+ attr_accessor :start_timestamp, :finish_timestamp
107
+ end
108
+
105
109
  module Queue
106
110
  attr_writer :run_command_formatter, :project_root
107
111
 
@@ -159,13 +163,30 @@ module Minitest
159
163
  id <=> other.id
160
164
  end
161
165
 
166
+ def with_timestamps
167
+ start_timestamp = current_timestamp
168
+ result = yield
169
+ result
170
+ ensure
171
+ result.start_timestamp = start_timestamp
172
+ result.finish_timestamp = current_timestamp
173
+ end
174
+
162
175
  def run
163
- Minitest.run_one_method(@runnable, @method_name)
176
+ with_timestamps do
177
+ Minitest.run_one_method(@runnable, @method_name)
178
+ end
164
179
  end
165
180
 
166
181
  def flaky?
167
182
  Minitest.queue.flaky?(self)
168
183
  end
184
+
185
+ private
186
+
187
+ def current_timestamp
188
+ Time.now.to_i
189
+ end
169
190
  end
170
191
 
171
192
  attr_reader :queue
@@ -244,9 +265,11 @@ MiniTest.singleton_class.prepend(MiniTest::Queue)
244
265
  if defined? MiniTest::Result
245
266
  MiniTest::Result.prepend(MiniTest::Requeueing)
246
267
  MiniTest::Result.prepend(MiniTest::Flakiness)
268
+ MiniTest::Result.prepend(MiniTest::WithTimestamps)
247
269
  else
248
270
  MiniTest::Test.prepend(MiniTest::Requeueing)
249
271
  MiniTest::Test.prepend(MiniTest::Flakiness)
272
+ MiniTest::Test.prepend(MiniTest::WithTimestamps)
250
273
 
251
274
  module MinitestBackwardCompatibility
252
275
  def source_location
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.6
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  - !ruby/object:Gem::Version
239
239
  version: '0'
240
240
  requirements: []
241
- rubygems_version: 3.0.3
241
+ rubygems_version: 3.2.20
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Distribute tests over many workers using a queue