Skip to content

Commit

Permalink
GEODE-8538: Create test to validate ordering of redis pipeline comman…
Browse files Browse the repository at this point in the history
…ds (apache#5552)

Co-authored-by: Ray Ingles <[email protected]>
Co-authored-by: Darrel Schneider <[email protected]>
Co-authored-by: Jens Deppe <[email protected]>
Co-authored-by: Sarah Abbey <[email protected]>
  • Loading branch information
5 people authored Oct 6, 2020
1 parent f8dae61 commit 0c41271
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,37 @@ public void whenPipelining_commandResponsesAreNotCorrupted() {
assertThat(mockSubscriber.getReceivedMessages()).isEqualTo(expectedMessages);
}

@Test
public void should_returnResultsOfPipelinedCommands_inCorrectOrder() {
Jedis jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
final int NUMBER_OF_COMMANDS_IN_PIPELINE = 100;
int numberOfPipeLineRequests = 1000;

do {
Pipeline p = jedis.pipelined();
for (int i = 0; i < NUMBER_OF_COMMANDS_IN_PIPELINE; i++) {
p.echo(String.valueOf(i));
}

List<Object> results = p.syncAndReturnAll();

verifyResultOrder(NUMBER_OF_COMMANDS_IN_PIPELINE, results);
numberOfPipeLineRequests--;
} while (numberOfPipeLineRequests > 0);

jedis.flushAll();
jedis.close();
}

private void verifyResultOrder(final int numberOfCommandInPipeline, List<Object> results) {
for (int i = 0; i < numberOfCommandInPipeline; i++) {
String expected = String.valueOf(i);
String currentVal = (String) results.get(i);

assertThat(currentVal).isEqualTo(expected);
}
}

private void waitFor(Callable<Boolean> booleanCallable) {
GeodeAwaitility.await()
.ignoreExceptions() // ignoring socket closed exceptions
Expand Down

0 comments on commit 0c41271

Please sign in to comment.