Skip to content

Commit

Permalink
Improve MemoryPipelineChannelTest for nightly CI (#29677)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandynz authored Jan 8, 2024
1 parent 419a7fd commit a05bdd8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

import java.util.Collections;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

class MemoryPipelineChannelTest {

Expand All @@ -38,10 +41,14 @@ class MemoryPipelineChannelTest {
void assertZeroQueueSizeWorks() {
MemoryPipelineChannel channel = new MemoryPipelineChannel(0, new InventoryTaskAckCallback(new AtomicReference<>()));
List<Record> records = Collections.singletonList(new PlaceholderRecord(new IngestFinishedPosition()));
Thread thread = new Thread(() -> channel.push(records));
Semaphore semaphore = new Semaphore(1);
Thread thread = new Thread(() -> {
semaphore.release();
channel.push(records);
});
thread.start();
assertThat(channel.fetch(1, 5L), is(records));
thread.join();
assertTrue(semaphore.tryAcquire(1L, TimeUnit.SECONDS));
assertThat(channel.fetch(1, 50L), is(records));
}

@Test
Expand Down

0 comments on commit a05bdd8

Please sign in to comment.