ezoerner commented on a change in pull request #6877:
URL: https://github.com/apache/geode/pull/6877#discussion_r719724158
##########
File path:
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractRenameIntegrationTest.java
##########
@@ -188,38 +245,39 @@ public void
shouldNotDeadlock_concurrentRenames_givenStripeContention()
}
@Test
- public void shouldThrowError_givenKeyDeletedDuringRename()
- throws ExecutionException, InterruptedException {
- CyclicBarrier startCyclicBarrier = new CyclicBarrier(2);
- ExecutorService pool = Executors.newFixedThreadPool(2);
-
- for (int i = 0; i < 100; i++) {
- jedis.set("{user1}oldKey", "foo");
+ public void shouldError_givenKeyDeletedDuringRename() {
+ int iterations = 2000;
- Runnable renameOldKeyToNewKey = () -> {
- cyclicBarrierAwait(startCyclicBarrier);
+ final AtomicReference<RuntimeException> renameException = new
AtomicReference<>(null);
- jedis.rename("{user1}oldKey", "{user1}newKey");
- };
+ jedis.set("{user1}oldKey", "foo");
- Runnable deleteOldKey = () -> {
- cyclicBarrierAwait(startCyclicBarrier);
- jedis.del("{user1}oldKey");
- };
-
- Future<?> future1 = pool.submit(renameOldKeyToNewKey);
- Future<?> future2 = pool.submit(deleteOldKey);
-
- try {
- future1.get();
- assertThat(jedis.get("{user1}newKey")).isEqualTo("foo");
- } catch (Exception e) {
- assertThat(e).hasMessageContaining("no such key");
- }
- future2.get();
-
- assertThat(jedis.get("{user1}oldKey")).isNull();
+ try {
+ new ConcurrentLoopingThreads(iterations,
Review comment:
His interpretation of the original test was that the point was to get
the error to be thrown and that's it so the test can exit with success as soon
as that exception is thrown. The test does not necessarily only run a single
iteration because the rename can occur before the delete in which case the next
iteration is executed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]