@@ -1513,15 +1513,20 @@ func TestLogSplitStrategy(t *testing.T) {
1513
1513
// Create a split client with the mock PD client.
1514
1514
client := split .NewClient (mockPDCli , nil , nil , 100 , 4 )
1515
1515
1516
+ // these files should skip accumulation
1517
+ smallFiles := make ([]* backuppb.DataFileInfo , 0 , 10 )
1518
+ for j := 0 ; j < 20 ; j ++ {
1519
+ smallFiles = append (smallFiles , fakeFile (1 , 100 , 1024 * 1024 , 100 ))
1520
+ }
1521
+
1516
1522
// Define a mock iterator with sample data files.
1517
- mockIter := iter .FromSlice ([]* backuppb.DataFileInfo {
1518
- fakeFile (1 , 100 , 100 , 100 ),
1523
+ mockIter := iter .FromSlice (append (smallFiles , []* backuppb.DataFileInfo {
1519
1524
fakeFile (1 , 200 , 2 * units .MiB , 200 ),
1520
1525
fakeFile (2 , 100 , 3 * units .MiB , 300 ),
1521
1526
fakeFile (3 , 100 , 10 * units .MiB , 100000 ),
1522
1527
fakeFile (1 , 300 , 3 * units .MiB , 10 ),
1523
1528
fakeFile (1 , 400 , 4 * units .MiB , 10 ),
1524
- })
1529
+ }... ) )
1525
1530
logIter := toLogDataFileInfoIter (mockIter )
1526
1531
1527
1532
// Initialize a wrapper for the file restorer with a region splitter.
@@ -1548,7 +1553,7 @@ func TestLogSplitStrategy(t *testing.T) {
1548
1553
count := 0
1549
1554
for i := helper .TryNext (ctx ); ! i .Finished ; i = helper .TryNext (ctx ) {
1550
1555
require .NoError (t , i .Err )
1551
- if count == expectSplitCount {
1556
+ if count == len ( smallFiles ) + expectSplitCount {
1552
1557
// Verify that no split occurs initially due to insufficient data.
1553
1558
regions , err := mockPDCli .ScanRegions (ctx , []byte {}, []byte {}, 0 )
1554
1559
require .NoError (t , err )
@@ -1562,6 +1567,9 @@ func TestLogSplitStrategy(t *testing.T) {
1562
1567
count += 1
1563
1568
}
1564
1569
1570
+ // iterate 20 small files + 4 valid files
1571
+ require .Equal (t , len (smallFiles )+ 4 , count )
1572
+
1565
1573
// Verify that a split occurs on the second region due to excess data.
1566
1574
regions , err := mockPDCli .ScanRegions (ctx , []byte {}, []byte {}, 0 )
1567
1575
require .NoError (t , err )
0 commit comments