@@ -825,58 +825,36 @@ TEST(ConsolidationTierTest, Defaults) {
825825
826826 irs::IndexMeta meta;
827827 AddSegment (meta, " 0" , 100 , 100 , 150 );
828- AddSegment (meta, " 1" , 100 , 100 , 100 );
829- AddSegment (meta, " 2" , 100 , 100 , 100 );
830- AddSegment (meta, " 3" , 100 , 100 , 100 );
831- AddSegment (meta, " 4" , 100 , 100 , 100 );
828+ for (uint64_t i = 1 ; i < 49 ; i++)
829+ AddSegment (meta, std::to_string (i), 100 , 100 , 100 );
830+
832831 IndexReaderMock reader{meta};
833832
834- // 1st tier
835- {
836- irs::Consolidation candidates;
837- policy (candidates, reader, consolidating_segments);
838- AssertCandidates (reader, {0 , 1 , 2 , 3 , 4 }, candidates);
839- candidates.clear ();
840- policy (candidates, reader, consolidating_segments);
841- AssertCandidates (reader, {0 , 1 , 2 , 3 , 4 }, candidates);
842- // register candidates for consolidation
843- for (const auto * candidate : candidates) {
844- consolidating_segments.emplace (candidate->Meta ().name );
845- }
846- }
847-
848- // no more segments to consolidate
833+ // no segments to consolidate since we have fewer segments than
834+ // segmentsMin (50) segments
849835 {
850836 irs::Consolidation candidates;
851837 policy (candidates, reader, consolidating_segments);
852838 ASSERT_TRUE (candidates.empty ());
853839 }
854- }
855840
856- {
857- irs::ConsolidatingSegments consolidating_segments;
858- irs::IndexMeta meta;
859- AddSegment (meta, " 0" , 100 , 100 , 150 );
860- AddSegment (meta, " 1" , 100 , 100 , 100 );
861- AddSegment (meta, " 2" , 100 , 100 , 100 );
862- AddSegment (meta, " 3" , 100 , 100 , 100 );
863- AddSegment (meta, " 4" , 100 , 100 , 100 );
864- AddSegment (meta, " 5" , 100 , 100 , 100 );
865- AddSegment (meta, " 6" , 100 , 100 , 100 );
866- AddSegment (meta, " 7" , 100 , 100 , 100 );
867- AddSegment (meta, " 8" , 100 , 100 , 100 );
868- AddSegment (meta, " 9" , 100 , 100 , 100 );
869- AddSegment (meta, " 10" , 100 , 100 , 100 );
870- IndexReaderMock reader{meta};
841+ AddSegment (meta, std::to_string (49 ), 100 , 100 , 100 );
842+ IndexReaderMock reader_with_50_segments (meta);
843+ // Add 50th segment to trigger consolidation
844+
845+ std::vector<size_t > expected (50 );
846+ for (size_t i = 0 ; i < 50 ; i++) {
847+ expected[i] = i;
848+ }
871849
872850 // 1st tier
873851 {
874852 irs::Consolidation candidates;
875- policy (candidates, reader , consolidating_segments);
876- AssertCandidates (reader, { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } , candidates);
853+ policy (candidates, reader_with_50_segments , consolidating_segments);
854+ AssertCandidates (reader_with_50_segments, expected , candidates);
877855 candidates.clear ();
878- policy (candidates, reader , consolidating_segments);
879- AssertCandidates (reader, { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } , candidates);
856+ policy (candidates, reader_with_50_segments , consolidating_segments);
857+ AssertCandidates (reader_with_50_segments, expected , candidates);
880858 // register candidates for consolidation
881859 for (const auto * candidate : candidates) {
882860 consolidating_segments.emplace (candidate->Meta ().name );
@@ -886,7 +864,7 @@ TEST(ConsolidationTierTest, Defaults) {
886864 // no more segments to consolidate
887865 {
888866 irs::Consolidation candidates;
889- policy (candidates, reader , consolidating_segments);
867+ policy (candidates, reader_with_50_segments , consolidating_segments);
890868 ASSERT_TRUE (candidates.empty ());
891869 }
892870 }
0 commit comments