|
| 1 | +package com.marklogic.client.fastfunctest.datamovement; |
| 2 | + |
| 3 | +import com.marklogic.client.datamovement.DataMovementManager; |
| 4 | +import com.marklogic.client.datamovement.QueryBatcher; |
| 5 | +import com.marklogic.client.fastfunctest.AbstractFunctionalTest; |
| 6 | +import org.junit.jupiter.api.Disabled; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | + |
| 9 | +import java.util.concurrent.atomic.AtomicInteger; |
| 10 | + |
| 11 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 12 | + |
| 13 | +@Disabled("Getting this test in place to verify that setMaxBatches does not appear to work yet.") |
| 14 | +public class SetMaxBatchesTest extends AbstractFunctionalTest { |
| 15 | + |
| 16 | + @Test |
| 17 | + void test() { |
| 18 | + writeJsonDocs(50, "max-batches-test"); |
| 19 | + |
| 20 | + DataMovementManager dmm = client.newDataMovementManager(); |
| 21 | + AtomicInteger uriCount = new AtomicInteger(); |
| 22 | + QueryBatcher queryBatcher = dmm |
| 23 | + .newQueryBatcher(client.newQueryManager().newStructuredQueryBuilder().collection("max-batches-test")) |
| 24 | + .withThreadCount(1) |
| 25 | + .withBatchSize(10) |
| 26 | + .onUrisReady(batch -> uriCount.addAndGet(batch.getItems().length)); |
| 27 | + queryBatcher.setMaxBatches(2); |
| 28 | + dmm.startJob(queryBatcher); |
| 29 | + queryBatcher.awaitCompletion(); |
| 30 | + dmm.stopJob(queryBatcher); |
| 31 | + |
| 32 | + assertEquals(20, uriCount.get(), "Because the batch size is 10 and we asked for 2 batches back, we only " + |
| 33 | + "expect 20 URIs back. But through 6.2.2 (and probably going back much further), all URIs are returned. " + |
| 34 | + "Modifying the thread count and batch size do not appear to affect this at all."); |
| 35 | + } |
| 36 | +} |
0 commit comments