ci-queue 0.27.0 → 0.28.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: 87d167da0bbe9a7b2eceb992452c71f0fa2ab54c5da53232a5aecbe26426ae8f
4
- data.tar.gz: f5130f7ed97545937b5964a92fb107eb462c10eba31fac8d164619ed2351b381
3
+ metadata.gz: 69405c017a257d343855d189dd70454f06c6c1a397283572da4809f762b1caa8
4
+ data.tar.gz: eae3446d02e921cdbd9757cec7d63bcefd72d57394cbb19d15b732655b110ef3
5
5
  SHA512:
6
- metadata.gz: 6304f21d394e7e67f8715d891d77673db0bcd5e0ff6742ec5324b3341982678edb3b7533815cad10ca9aa791f1ee6a84305b9e4390072034a7179a4bf3bece8e
7
- data.tar.gz: e49255e12db5ce36f3c1d76376488dd7597b171a4c124b8de7b8c828412be8ffb15e226d16b5b87574eb4631007b3dc868062ec5a8144b5519c1c2beda79cbce
6
+ metadata.gz: f5feb44c4cfc61e8a460bc637b75b32a2c463b0223ce8b70c4137ad764db974c4cca2bd95c288c90a16d9add30366c775474dd68b5a38180a1b6c90e927b20da
7
+ data.tar.gz: 296bbaaf6116ec1e6512323f905151ad1345cf1087d0da66c6bdd89e8ed3b8dfc221aaabaabdd4e01fd68d9c5ca5eb5eb72c3431717b9db75254a9bb38a28407
data/Rakefile CHANGED
@@ -6,7 +6,9 @@ require 'ci/queue/version'
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << 'test'
8
8
  t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb'] - FileList['test/fixtures/**/*_test.rb']
9
+ selected_files = ENV["TEST_FILES"].to_s.strip.split(/\s+/)
10
+ selected_files = nil if selected_files.empty?
11
+ t.test_files = selected_files || FileList['test/**/*_test.rb'] - FileList['test/fixtures/**/*_test.rb']
10
12
  end
11
13
 
12
14
  task :default => :test
data/dev.yml CHANGED
@@ -8,4 +8,4 @@ up:
8
8
  - isogun
9
9
 
10
10
  commands:
11
- test: REDIS_URL=${REDIS_URL:-redis://ci-queue.railgun/0} bundle exec rake test
11
+ test: REDIS_URL=${REDIS_URL:-redis://ci-queue.railgun/0} bundle exec rake test TEST_FILES="$*"
@@ -2,7 +2,7 @@
2
2
  module CI
3
3
  module Queue
4
4
  class Configuration
5
- attr_accessor :timeout, :worker_id, :max_requeues, :grind_count, :failure_file
5
+ attr_accessor :timeout, :worker_id, :max_requeues, :grind_count, :failure_file, :export_flaky_tests_file
6
6
  attr_accessor :requeue_tolerance, :namespace, :failing_test, :statsd_endpoint
7
7
  attr_accessor :max_test_duration, :max_test_duration_percentile, :track_test_duration
8
8
  attr_accessor :max_test_failed, :redis_ttl
@@ -35,7 +35,8 @@ module CI
35
35
  namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil,
36
36
  grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil,
37
37
  max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil,
38
- queue_init_timeout: nil, redis_ttl: 8 * 60 * 60, report_timeout: nil, inactive_workers_timeout: nil
38
+ queue_init_timeout: nil, redis_ttl: 8 * 60 * 60, report_timeout: nil, inactive_workers_timeout: nil,
39
+ export_flaky_tests_file: nil
39
40
  )
40
41
  @build_id = build_id
41
42
  @circuit_breakers = [CircuitBreaker::Disabled]
@@ -59,6 +60,7 @@ module CI
59
60
  @redis_ttl = redis_ttl
60
61
  @report_timeout = report_timeout
61
62
  @inactive_workers_timeout = inactive_workers_timeout
63
+ @export_flaky_tests_file = export_flaky_tests_file
62
64
  end
63
65
 
64
66
  def queue_init_timeout
@@ -48,10 +48,23 @@ module CI
48
48
  end
49
49
 
50
50
  def record_success(id, stats: nil)
51
- redis.pipelined do |pipeline|
51
+ error_reports_deleted_count, requeued_count, _ = redis.pipelined do |pipeline|
52
52
  pipeline.hdel(key('error-reports'), id.dup.force_encoding(Encoding::BINARY))
53
+ pipeline.hget(key('requeues-count'), id.b)
53
54
  record_stats(stats, pipeline: pipeline)
54
55
  end
56
+ record_flaky(id) if error_reports_deleted_count.to_i > 0 || requeued_count.to_i > 0
57
+ nil
58
+ end
59
+
60
+ def record_flaky(id, stats: nil)
61
+ redis.pipelined do |pipeline|
62
+ pipeline.sadd(
63
+ key('flaky-reports'),
64
+ id.b
65
+ )
66
+ pipeline.expire(key('flaky-reports'), config.redis_ttl)
67
+ end
55
68
  nil
56
69
  end
57
70
 
@@ -65,6 +78,10 @@ module CI
65
78
  redis.hgetall(key('error-reports'))
66
79
  end
67
80
 
81
+ def flaky_reports
82
+ redis.smembers(key('flaky-reports'))
83
+ end
84
+
68
85
  def fetch_stats(stat_names)
69
86
  counts = redis.pipelined do |pipeline|
70
87
  stat_names.each { |c| pipeline.hvals(key(c)) }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.27.0'
5
+ VERSION = '0.28.0'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
@@ -17,6 +17,10 @@ module Minitest
17
17
  build.error_reports.sort_by(&:first).map { |k, v| ErrorReport.load(v) }
18
18
  end
19
19
 
20
+ def flaky_reports
21
+ build.flaky_reports
22
+ end
23
+
20
24
  def report
21
25
  puts aggregates
22
26
  errors = error_reports
@@ -213,6 +213,11 @@ module Minitest
213
213
  File.write(queue_config.failure_file, failures)
214
214
  end
215
215
 
216
+ if queue_config.export_flaky_tests_file
217
+ failures = reporter.flaky_reports.to_json
218
+ File.write(queue_config.export_flaky_tests_file, failures)
219
+ end
220
+
216
221
  reporter.report
217
222
  exit! reporter.success? ? 0 : 1
218
223
  end
@@ -481,6 +486,15 @@ module Minitest
481
486
  queue_config.failure_file = file
482
487
  end
483
488
 
489
+ help = <<~EOS
490
+ Defines a file where flaky tests during the execution are written to in json format.
491
+ Defaults to disabled.
492
+ EOS
493
+ opts.separator ""
494
+ opts.on('--export-flaky-tests-file FILE', help) do |file|
495
+ queue_config.export_flaky_tests_file = file
496
+ end
497
+
484
498
  help = <<~EOS
485
499
  Defines after how many consecutive failures the worker will be considered unhealthy and terminate itself.
486
500
  Defaults to disabled.
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.27.0
4
+ version: 0.28.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: 2023-05-03 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.4.12
242
+ rubygems_version: 3.4.13
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Distribute tests over many workers using a queue