diff --git a/lib/storage/storage_test.go b/lib/storage/storage_test.go index ca165d4ba..27129b325 100644 --- a/lib/storage/storage_test.go +++ b/lib/storage/storage_test.go @@ -988,7 +988,7 @@ func testStorageAddRows(rng *rand.Rand, s *Storage) error { const addsCount = 10 maxTimestamp := timestampFromTime(time.Now()) - minTimestamp := maxTimestamp - s.retentionMsecs + minTimestamp := maxTimestamp - s.retentionMsecs + 3600*1000 for i := 0; i < addsCount; i++ { mrs := testGenerateMetricRows(rng, rowsPerAdd, minTimestamp, maxTimestamp) if err := s.AddRows(mrs, defaultPrecisionBits); err != nil { @@ -1030,7 +1030,9 @@ func testStorageAddRows(rng *rand.Rand, s *Storage) error { return fmt.Errorf("snapshot %q must contain at least %d rows; got %d", snapshotPath, minRowsExpected, rowsCount) } - // Verify that force merge for the snapshot leaves only a single part per partition. + // Verify that force merge for the snapshot leaves at most a single part per partition. + // Zero parts are possible if the snapshot is created just after the partition has been created + // by concurrent goroutine, but it didn't put the data into it yet. if err := s1.ForceMergePartitions(""); err != nil { return fmt.Errorf("error when force merging partitions: %w", err) } @@ -1039,9 +1041,9 @@ func testStorageAddRows(rng *rand.Rand, s *Storage) error { pws := ptw.pt.GetParts(nil, true) numParts := len(pws) ptw.pt.PutParts(pws) - if numParts != 1 { + if numParts > 1 { s1.tb.PutPartitions(ptws) - return fmt.Errorf("unexpected number of parts for partition %q after force merge; got %d; want 1", ptw.pt.name, numParts) + return fmt.Errorf("unexpected number of parts for partition %q after force merge; got %d; want at most 1", ptw.pt.name, numParts) } } s1.tb.PutPartitions(ptws)