Skip to content

Commit

Permalink
increase verify timeout to 2s
Browse files Browse the repository at this point in the history
Signed-off-by: Xin Li <xin.li@hedera.com>
  • Loading branch information
xin-hedera committed Jun 16, 2021
1 parent 93196fc commit d46cc3b
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
@ExtendWith(MockitoExtension.class)
class RedisEntityListenerTest {

private static final long TIMEOUT_MILLIS = 2000L;

@Mock
private RedisOperations<String, StreamMessage> redisOperations;

Expand Down Expand Up @@ -100,13 +102,13 @@ void onSlowPublish() {

//then
//Thread is blocked because queue is full, and publisher is blocked on first message.
verify(redisOperations, timeout(500).times(1))
verify(redisOperations, timeout(TIMEOUT_MILLIS).times(1))
.executePipelined(any(SessionCallback.class));
assertThat(saveCount.get()).isEqualTo(redisProperties.getQueueCapacity() + 1);

latch.countDown();
//All messages should be queued and published
verify(redisOperations, timeout(500).times(redisProperties.getQueueCapacity() + 2))
verify(redisOperations, timeout(TIMEOUT_MILLIS).times(redisProperties.getQueueCapacity() + 2))
.executePipelined(any(SessionCallback.class));
assertThat(saveCount.get()).isEqualTo(redisProperties.getQueueCapacity() + 2);
}
Expand All @@ -120,21 +122,21 @@ void onDuplicateTopicMessages() throws InterruptedException {
//submitAndSave two messages, verify publish logic called twice
submitAndSave(topicMessage1);
submitAndSave(topicMessage2);
verify(redisOperations, timeout(500).times(2))
verify(redisOperations, timeout(TIMEOUT_MILLIS).times(2))
.executePipelined(any(SessionCallback.class));

//submitAndSave two duplicate messages, verify publish was not attempted
Mockito.reset(redisOperations);
submitAndSave(topicMessage1);
submitAndSave(topicMessage2);
verify(redisOperations, timeout(500).times(0))
verify(redisOperations, timeout(TIMEOUT_MILLIS).times(0))
.executePipelined(any(SessionCallback.class));

//submitAndSave third new unique message, verify publish called once.
Mockito.reset(redisOperations);
submitAndSave(topicMessage3);
entityListener.onCleanup(new EntityBatchCleanupEvent(this));
verify(redisOperations, timeout(500).times(1))
verify(redisOperations, timeout(TIMEOUT_MILLIS).times(1))
.executePipelined(any(SessionCallback.class));
}

Expand Down

0 comments on commit d46cc3b

Please sign in to comment.