ci-queue 0.21.1 → 0.22.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: bb09b44ca70cde6218873faed3b7067295088a115b2b33ddc93b3853ad318042
4
- data.tar.gz: d0eb4a637fb89aa8c2858e5f1c363b86518cb310729d417fc6e7847c7bd261b8
3
+ metadata.gz: a727d6a5f5c01a4b5837d1f7ed629ce3f9c971fed502d6b850a43b384e72c59a
4
+ data.tar.gz: 3ab46419fd8c1932d2e94cd40bbfb087df927d9013f9d0e998f3ed60839440e6
5
5
  SHA512:
6
- metadata.gz: e3b35848df951df70cddc2bab778f5160dc0293f09cc66218b31567ce8b2fe7e7a020f5aeec9fb2b6890e53a175b70ada164b404306ee5582cc1a40601515643
7
- data.tar.gz: 8f5ffdaaad075ddcc724117f3b2414f7a15b49509d0b0df5b4415827b6452efc251974398a58b2203c776fdb70819ab53c8042ce4d3add056b245ff8cafed179
6
+ metadata.gz: f6fd6c5f71fc10b0b5085b0d5259aa25eb1b1cc969f7b182e45c975deff56e72b1bef6e133adb812db87809feda33044ad7e137f36d88c5866c34a469af4b0fd
7
+ data.tar.gz: 0415f91c5aa6c1bdfd185842ae88ee5d73ed3c553945eeacd2a095288156336f4bb00d2d49ab302f7758d7fcbb78c7fcd2b500d6265c12aa3b33dfbc2d5d7829
@@ -31,6 +31,10 @@ module CI
31
31
  Static.new(first_half + [config.failing_test], config).populate(@all_tests)
32
32
  end
33
33
 
34
+ def release!
35
+ # noop
36
+ end
37
+
34
38
  def failed!
35
39
  @tests = first_half
36
40
  end
@@ -11,6 +11,10 @@ module CI
11
11
  false
12
12
  end
13
13
 
14
+ def release!
15
+ # noop
16
+ end
17
+
14
18
  def flaky?(test)
15
19
  @config.flaky?(test)
16
20
  end
@@ -1,8 +1,10 @@
1
1
  -- AUTOGENERATED FILE DO NOT EDIT DIRECTLY
2
2
  local zset_key = KEYS[1]
3
3
  local processed_key = KEYS[2]
4
+ local owners_key = KEYS[3]
4
5
 
5
6
  local test = ARGV[1]
6
7
 
7
8
  redis.call('zrem', zset_key, test)
9
+ redis.call('hdel', owners_key, test) -- Doesn't matter if it was reclaimed by another workers
8
10
  return redis.call('sadd', processed_key, test)
@@ -0,0 +1,16 @@
1
+ -- AUTOGENERATED FILE DO NOT EDIT DIRECTLY
2
+ local zset_key = KEYS[1]
3
+ local worker_queue_key = KEYS[2]
4
+ local owners_key = KEYS[3]
5
+
6
+ -- owned_tests = {"SomeTest", "worker:1", "SomeOtherTest", "worker:2", ...}
7
+ local owned_tests = redis.call('hgetall', owners_key)
8
+ for index, owner_or_test in ipairs(owned_tests) do
9
+ if owner_or_test == worker_queue_key then -- If we owned a test
10
+ local test = owned_tests[index - 1]
11
+ redis.call('zadd', zset_key, "0", test) -- We expire the lease immediately
12
+ return nil
13
+ end
14
+ end
15
+
16
+ return nil
@@ -3,12 +3,18 @@ local processed_key = KEYS[1]
3
3
  local requeues_count_key = KEYS[2]
4
4
  local queue_key = KEYS[3]
5
5
  local zset_key = KEYS[4]
6
+ local worker_queue_key = KEYS[5]
7
+ local owners_key = KEYS[6]
6
8
 
7
9
  local max_requeues = tonumber(ARGV[1])
8
10
  local global_max_requeues = tonumber(ARGV[2])
9
11
  local test = ARGV[3]
10
12
  local offset = ARGV[4]
11
13
 
14
+ if redis.call('hget', owners_key, test) == worker_queue_key then
15
+ redis.call('hdel', owners_key, test)
16
+ end
17
+
12
18
  if redis.call('sismember', processed_key, test) == 1 then
13
19
  return false
14
20
  end
@@ -3,6 +3,7 @@ local queue_key = KEYS[1]
3
3
  local zset_key = KEYS[2]
4
4
  local processed_key = KEYS[3]
5
5
  local worker_queue_key = KEYS[4]
6
+ local owners_key = KEYS[5]
6
7
 
7
8
  local current_time = ARGV[1]
8
9
 
@@ -10,6 +11,7 @@ local test = redis.call('rpop', queue_key)
10
11
  if test then
11
12
  redis.call('zadd', zset_key, current_time, test)
12
13
  redis.call('lpush', worker_queue_key, test)
14
+ redis.call('hset', owners_key, test, worker_queue_key)
13
15
  return test
14
16
  else
15
17
  return nil
@@ -2,6 +2,7 @@
2
2
  local zset_key = KEYS[1]
3
3
  local processed_key = KEYS[2]
4
4
  local worker_queue_key = KEYS[3]
5
+ local owners_key = KEYS[4]
5
6
 
6
7
  local current_time = ARGV[1]
7
8
  local timeout = ARGV[2]
@@ -11,6 +12,7 @@ for _, test in ipairs(lost_tests) do
11
12
  if redis.call('sismember', processed_key, test) == 0 then
12
13
  redis.call('zadd', zset_key, current_time, test)
13
14
  redis.call('lpush', worker_queue_key, test)
15
+ redis.call('hset', owners_key, test, worker_queue_key) -- Take ownership
14
16
  return test
15
17
  end
16
18
  end
@@ -92,7 +92,7 @@ module CI
92
92
  raise_on_mismatching_test(test_key)
93
93
  eval_script(
94
94
  :acknowledge,
95
- keys: [key('running'), key('processed')],
95
+ keys: [key('running'), key('processed'), key('owners')],
96
96
  argv: [test_key],
97
97
  ) == 1
98
98
  end
@@ -104,7 +104,14 @@ module CI
104
104
 
105
105
  requeued = config.max_requeues > 0 && global_max_requeues > 0 && eval_script(
106
106
  :requeue,
107
- keys: [key('processed'), key('requeues-count'), key('queue'), key('running')],
107
+ keys: [
108
+ key('processed'),
109
+ key('requeues-count'),
110
+ key('queue'),
111
+ key('running'),
112
+ key('worker', worker_id, 'queue'),
113
+ key('owners'),
114
+ ],
108
115
  argv: [config.max_requeues, global_max_requeues, test_key, offset],
109
116
  ) == 1
110
117
 
@@ -112,6 +119,15 @@ module CI
112
119
  requeued
113
120
  end
114
121
 
122
+ def release!
123
+ eval_script(
124
+ :release,
125
+ keys: [key('running'), key('worker', worker_id, 'queue'), key('owners')],
126
+ argv: [],
127
+ )
128
+ nil
129
+ end
130
+
115
131
  private
116
132
 
117
133
  attr_reader :index
@@ -144,7 +160,13 @@ module CI
144
160
  def try_to_reserve_test
145
161
  eval_script(
146
162
  :reserve,
147
- keys: [key('queue'), key('running'), key('processed'), key('worker', worker_id, 'queue')],
163
+ keys: [
164
+ key('queue'),
165
+ key('running'),
166
+ key('processed'),
167
+ key('worker', worker_id, 'queue'),
168
+ key('owners'),
169
+ ],
148
170
  argv: [Time.now.to_f],
149
171
  )
150
172
  end
@@ -152,7 +174,12 @@ module CI
152
174
  def try_to_reserve_lost_test
153
175
  lost_test = eval_script(
154
176
  :reserve_lost,
155
- keys: [key('running'), key('completed'), key('worker', worker_id, 'queue')],
177
+ keys: [
178
+ key('running'),
179
+ key('completed'),
180
+ key('worker', worker_id, 'queue'),
181
+ key('owners'),
182
+ ],
156
183
  argv: [Time.now.to_f, timeout],
157
184
  )
158
185
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.21.1'
5
+ VERSION = '0.22.0'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
@@ -81,6 +81,10 @@ module Minitest
81
81
  # Let minitest's at_exit hook trigger
82
82
  end
83
83
 
84
+ def release_command
85
+ queue.release!
86
+ end
87
+
84
88
  def grind_command
85
89
  invalid_usage!('No list to grind provided') if grind_list.nil?
86
90
  invalid_usage!('No grind count provided') if grind_count.nil?
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.21.1
4
+ version: 0.22.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: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,6 +187,7 @@ files:
187
187
  - lib/ci/queue/redis/grind.rb
188
188
  - lib/ci/queue/redis/grind_record.rb
189
189
  - lib/ci/queue/redis/grind_supervisor.rb
190
+ - lib/ci/queue/redis/release.lua
190
191
  - lib/ci/queue/redis/requeue.lua
191
192
  - lib/ci/queue/redis/reserve.lua
192
193
  - lib/ci/queue/redis/reserve_lost.lua