Merge pull request 'test(persistence-jpa): 동시 writer 시험이 replay 순서를 받은 위치 순서로 본다' (#39) from claude/r9-live-event-order into main
main / main (push) Failing after 23m6s
main / build-logic (push) Successful in 1m43s
main / links (push) Successful in 10s
main / vulnerabilities (push) Successful in 2m11s
main / http3-experimental (push) Successful in 44s
main / jpa-postgresql (16) (push) Skipped
main / redis-topology (push) Skipped
main / fileserver-nfs-ambiguity (push) Skipped
main / notification-chaos (push) Skipped
main / configuration-cache (push) Successful in 1m32s
main / jpa-postgresql (17) (push) Skipped
main / jpa-postgresql (18) (push) Skipped
main / httpclient-transport (push) Skipped
main / jpa-next (hibernate-8, Hibernate 8 is not resolvable from this build, so nothing has been compiled or run against it, Hibernate 8, *Hibernate8CompatibilityTest) (push) Skipped
main / jpa-next (jakarta-persistence-4, the JPA 4 API is not on any configuration this build resolves, so nothing has been compiled against it, Jakarta Persistence 4, *Jpa4CompatibilityTest) (push) Skipped
main / jpa-next (postgresql-19, no PostgreSQL 19 image is published yet, so no container of that major has ever been started by this lane, PostgreSQL 19, *PostgreSql19CompatibilityTest) (push) Skipped
main / object-storage-aws (push) Skipped
main / compose-smoke (push) Skipped
main / done (push) Skipped
main / performance (push) Skipped

This commit was merged in pull request #39.
This commit is contained in:
2026-11-13 11:43:52 +00:00
@@ -17,6 +17,8 @@ import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -87,23 +89,28 @@ class LiveEventLogContractTest {
}
@Test
@DisplayName("two concurrent writers receive different positions and both commit")
@DisplayName("두 writer가 동시에 쓰면 서로 다른 위치 1·2를 받고, replay는 받은 위치 순서대로 둘 다 돌려준다")
void concurrentWritersAllocateDistinctPositions() throws Exception {
// given
CountDownLatch start = new CountDownLatch(1);
// Which writer reaches the allocator first is up to the scheduler, so the expected replay
// order is the order of the positions the writers got back, not the order they were started.
Map<Long, String> payloadByPosition = new TreeMap<>();
// when
try (ExecutorService executor = Executors.newFixedThreadPool(2)) {
Future<Long> first =
executor.submit(() -> allocateAndAppendAfter(start, "orders", "from-first"));
Future<Long> second =
executor.submit(() -> allocateAndAppendAfter(start, "orders", "from-second"));
start.countDown();
assertThat(List.of(first.get(10, TimeUnit.SECONDS), second.get(10, TimeUnit.SECONDS)))
.containsExactlyInAnyOrder(1L, 2L);
payloadByPosition.put(first.get(10, TimeUnit.SECONDS), "from-first");
payloadByPosition.put(second.get(10, TimeUnit.SECONDS), "from-second");
}
assertThat(replayAfter("orders", 0, NOW)).containsExactly("from-first", "from-second");
// then
assertThat(payloadByPosition).containsOnlyKeys(1L, 2L);
assertThat(replayAfter("orders", 0, NOW)).containsExactlyElementsOf(payloadByPosition.values());
}
@Test