@@ -36,7 +36,7 @@ def test_populate_stores_chunk_metadata_in_redis
3636 end
3737
3838 # Verify chunk metadata was stored
39- chunk_data = @redis . get ( ' build:42:chunk:TestA:chunk_0')
39+ chunk_data = @redis . get ( " build:42:chunk:#{ stored_chunk_id ( ' TestA:chunk_0') } " )
4040 refute_nil chunk_data
4141
4242 parsed = JSON . parse ( chunk_data )
@@ -100,10 +100,10 @@ def test_resolve_chunk
100100 end
101101
102102 # Manually store and resolve chunk
103- resolved = @worker . send ( :resolve_chunk , 'TestA:chunk_0' )
103+ resolved = @worker . send ( :resolve_chunk , stored_chunk_id ( 'TestA:chunk_0' ) )
104104
105105 assert_instance_of CI ::Queue ::Redis ::Worker ::ResolvedChunk , resolved
106- assert_equal 'TestA :chunk_0' , resolved . id
106+ assert_match / \A TestA :chunk_0(?::[0-9a-f]{16})? \z / , resolved . id
107107 assert_equal 'TestA' , resolved . suite_name
108108 assert_equal 3 , resolved . tests . size
109109 assert_equal test_ids , resolved . tests . map ( &:id )
@@ -120,10 +120,10 @@ def test_resolve_chunk_with_subset_of_tests
120120 @worker . populate ( tests )
121121 end
122122
123- resolved = @worker . send ( :resolve_chunk , 'TestA:chunk_0' )
123+ resolved = @worker . send ( :resolve_chunk , stored_chunk_id ( 'TestA:chunk_0' ) )
124124
125125 assert_instance_of CI ::Queue ::Redis ::Worker ::ResolvedChunk , resolved
126- assert_equal 'TestA :chunk_0' , resolved . id
126+ assert_match / \A TestA :chunk_0(?::[0-9a-f]{16})? \z / , resolved . id
127127 assert_equal 2 , resolved . tests . size
128128 assert_equal [ 'TestA#test_1' , 'TestA#test_3' ] , resolved . tests . map ( &:id )
129129 end
@@ -140,7 +140,7 @@ def test_resolved_chunk_interface
140140
141141 resolved = CI ::Queue ::Redis ::Worker ::ResolvedChunk . new ( chunk , tests )
142142
143- assert_equal 'TestA :chunk_0' , resolved . id
143+ assert_match / \A TestA :chunk_0(?::[0-9a-f]{16})? \z / , resolved . id
144144 assert_equal 'TestA' , resolved . suite_name
145145 assert_equal 2 , resolved . size
146146 assert resolved . chunk?
@@ -195,7 +195,7 @@ def test_populate_with_mixed_chunks_and_tests
195195
196196 # Check that both chunk and individual test IDs are in queue
197197 queue_items = @redis . lrange ( 'build:42:queue' , 0 , -1 )
198- assert_includes queue_items , 'TestA:chunk_0'
198+ assert_includes queue_items , stored_chunk_id ( 'TestA:chunk_0' )
199199 assert_includes queue_items , 'TestB#test_1'
200200 end
201201
@@ -210,12 +210,12 @@ def test_chunk_metadata_has_ttl
210210 @worker . populate ( tests )
211211 end
212212
213- ttl = @redis . ttl ( ' build:42:chunk:TestA:chunk_0')
213+ ttl = @redis . ttl ( " build:42:chunk:#{ stored_chunk_id ( ' TestA:chunk_0') } " )
214214 assert ttl > 0 , 'Chunk metadata should have TTL set'
215215 end
216216
217217 def test_populate_with_many_chunks_uses_batching
218- # Create 20 test chunks to verify batching works (batch size is 7 )
218+ # Create 20 test chunks to verify batching works (batch size is 5 )
219219 tests = ( 1 ..20 ) . map { |i | MockTest . new ( "TestSuite#{ i } #test_1" ) }
220220 chunks = ( 1 ..20 ) . map do |i |
221221 test_ids = [ "TestSuite#{ i } #test_1" ]
@@ -228,7 +228,7 @@ def test_populate_with_many_chunks_uses_batching
228228
229229 # Verify all chunks were stored despite batching
230230 chunks . each do |chunk |
231- chunk_data = @redis . get ( "build:42:chunk:#{ chunk . id } " )
231+ chunk_data = @redis . get ( "build:42:chunk:#{ stored_chunk_id ( chunk . id ) } " )
232232 refute_nil chunk_data , "Chunk #{ chunk . id } should be stored"
233233
234234 parsed = JSON . parse ( chunk_data )
@@ -239,7 +239,7 @@ def test_populate_with_many_chunks_uses_batching
239239 # Verify all chunk IDs are in the chunks set
240240 stored_chunks = @redis . smembers ( 'build:42:chunks' )
241241 chunks . each do |chunk |
242- assert_includes stored_chunks , chunk . id
242+ assert_includes stored_chunks , stored_chunk_id ( chunk . id )
243243 end
244244 end
245245
@@ -257,7 +257,7 @@ def test_worker_history_retry_expands_chunks_and_deduplicates_tests
257257 end
258258
259259 history_key = 'build:42:worker:1:queue'
260- [ chunk . id , tests . last . id , chunk . id , tests [ 1 ] . id ] . each do |id |
260+ [ stored_chunk_id ( chunk . id ) , tests . last . id , stored_chunk_id ( chunk . id ) , tests [ 1 ] . id ] . each do |id |
261261 @redis . lpush ( history_key , id )
262262 end
263263
@@ -304,6 +304,10 @@ def test_worker_history_retry_rejects_invalid_chunk_metadata
304304
305305 private
306306
307+ def stored_chunk_id ( original_id )
308+ @redis . smembers ( 'build:42:chunks' ) . find { |id | id . start_with? ( "#{ original_id } :" ) }
309+ end
310+
307311 def create_mock_tests ( test_ids )
308312 test_ids . map { |id | MockTest . new ( id ) }
309313 end
0 commit comments