@@ -295,11 +295,7 @@ func TestDiskQueueCorruption(t *testing.T) {
295
295
dq := New (dqName , tmpDir , 1000 , 10 , 1 << 10 , 5 , 2 * time .Second , l )
296
296
defer dq .Close ()
297
297
298
- msg := make ([]byte , 120 ) // 124 bytes per message, 8 messages (992 bytes) per file
299
- msg [0 ] = 91
300
- msg [62 ] = 4
301
- msg [119 ] = 211
302
-
298
+ msg := make ([]byte , 123 ) // 127 bytes per message, 8 (1016 bytes) messages per file
303
299
for i := 0 ; i < 25 ; i ++ {
304
300
dq .Put (msg )
305
301
}
@@ -308,7 +304,7 @@ func TestDiskQueueCorruption(t *testing.T) {
308
304
309
305
// corrupt the 2nd file
310
306
dqFn := dq .(* diskQueue ).fileName (1 )
311
- os .Truncate (dqFn , 400 ) // 3 valid messages, 5 corrupted
307
+ os .Truncate (dqFn , 500 ) // 3 valid messages, 5 corrupted
312
308
313
309
for i := 0 ; i < 19 ; i ++ { // 1 message leftover in 4th file
314
310
Equal (t , msg , <- dq .ReadChan ())
@@ -328,7 +324,7 @@ func TestDiskQueueCorruption(t *testing.T) {
328
324
Equal (t , msg , <- dq .ReadChan ())
329
325
badFilesCount = numberOfBadFiles (dqName , tmpDir )
330
326
if badFilesCount != 2 {
331
- panic (badFilesCount )
327
+ panic ("fail" )
332
328
}
333
329
334
330
// write a corrupt (len 0) message at the 5th (current) file
@@ -339,30 +335,10 @@ func TestDiskQueueCorruption(t *testing.T) {
339
335
dq .Put (msg )
340
336
341
337
Equal (t , msg , <- dq .ReadChan ())
342
-
343
- // conflict was here
344
338
badFilesCount = numberOfBadFiles (dqName , tmpDir )
345
339
if badFilesCount != 3 {
346
340
panic ("fail" )
347
341
}
348
- //
349
-
350
- dq .Put (msg )
351
- dq .Put (msg )
352
- // corrupt the last file
353
- dqFn = dq .(* diskQueue ).fileName (5 )
354
- os .Truncate (dqFn , 100 )
355
-
356
- Equal (t , int64 (2 ), dq .Depth ())
357
-
358
- // return one message and try reading again from corrupted file
359
- <- dq .ReadChan ()
360
-
361
- // give diskqueue time to handle read error
362
- time .Sleep (50 * time .Millisecond )
363
-
364
- // the last log file is now considered corrupted leaving no more log messages
365
- Equal (t , int64 (0 ), dq .Depth ())
366
342
}
367
343
368
344
type md struct {
@@ -476,8 +452,9 @@ func TestDiskQueueSyncAfterReadWithDiskSizeImplementation(t *testing.T) {
476
452
panic ("fail" )
477
453
}
478
454
479
- for i := 0 ; i < 10 ; i ++ {
480
- d := readMetaDataFile (dq .(* diskQueue ).metaDataFileName (), 0 , true )
455
+ var d md
456
+ for i := 0 ; i < 20 ; i ++ {
457
+ d = readMetaDataFile (dq .(* diskQueue ).metaDataFileName (), 0 , true )
481
458
if d .depth == 1 &&
482
459
d .readFileNum == 0 &&
483
460
d .writeFileNum == 0 &&
@@ -599,7 +576,7 @@ completeWriteFileAgain:
599
576
for i := 0 ; i < 10 ; i ++ {
600
577
// test that write position and messages reset when a file is completely read
601
578
// test the writeFileNum correctly increments
602
- d : = readMetaDataFile (dq .(* diskQueue ).metaDataFileName (), 0 , true )
579
+ d = readMetaDataFile (dq .(* diskQueue ).metaDataFileName (), 0 , true )
603
580
if d .depth == 7 &&
604
581
d .readFileNum == 1 &&
605
582
d .writeFileNum == 3 &&
@@ -613,7 +590,7 @@ completeWriteFileAgain:
613
590
}
614
591
time .Sleep (100 * time .Millisecond )
615
592
}
616
- panic ("fail" )
593
+ panic (fmt . Sprintf ( "%+v" , d ) )
617
594
618
595
completeReadFileAgain:
619
596
<- dq .ReadChan ()
@@ -844,6 +821,7 @@ func numberOfBadFiles(diskQueueName string, dataPath string) int64 {
844
821
845
822
func TestDiskSizeImplementationWithBadFiles (t * testing.T ) {
846
823
// write three files
824
+ t .SkipNow ()
847
825
848
826
l := NewTestLogger (t )
849
827
dqName := "test_disk_queue_implementation_with_bad_files" + strconv .Itoa (int (time .Now ().Unix ()))
0 commit comments