@@ -136,6 +136,7 @@ public void testMergeSourceWithFollowUpMergesRunSequentially() throws Exception
136136 when (oneMerge .getMergeProgress ()).thenReturn (new MergePolicy .OneMergeProgress ());
137137 followUpMerges [i ] = oneMerge ;
138138 }
139+ // the merge source with follow-up merges
139140 when (mergeSource .getNextMerge ()).thenReturn (firstMerge , followUpMerges );
140141 AtomicBoolean isMergeInProgress = new AtomicBoolean ();
141142 AtomicInteger runMergeIdx = new AtomicInteger ();
@@ -146,7 +147,7 @@ public void testMergeSourceWithFollowUpMergesRunSequentially() throws Exception
146147 assertTrue (isMergeInProgress .compareAndSet (false , true ));
147148 OneMerge mergeInvocation = (OneMerge ) invocation .getArguments ()[0 ];
148149 assertFalse (mergeInvocation .isAborted ());
149- // assert merges run in the order they are submitted
150+ // assert merges run in the order they are produced by the merge source
150151 if (runMergeIdx .get () == 0 ) {
151152 assertThat (mergeInvocation , is (firstMerge ));
152153 } else {
@@ -159,8 +160,10 @@ public void testMergeSourceWithFollowUpMergesRunSequentially() throws Exception
159160 assertTrue (isMergeInProgress .compareAndSet (true , false ));
160161 return null ;
161162 }).when (mergeSource ).merge (any (OneMerge .class ));
163+ // trigger run merges on the merge source
162164 threadPoolMergeScheduler .merge (mergeSource , randomFrom (MergeTrigger .values ()));
163165 do {
166+ // let merges run, but wait for the in-progress one to signal it is running
164167 nextMergeSemaphore .acquire ();
165168 runMergeSemaphore .release ();
166169 } while (runMergeIdx .get () < followUpMergeCount );
0 commit comments