sabbey37 commented on a change in pull request #5954: URL: https://github.com/apache/geode/pull/5954#discussion_r583788608
########## File path: geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/hash/AbstractHScanIntegrationTest.java ########## @@ -36,58 +38,86 @@ import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanResult; +import org.apache.geode.redis.ConcurrentLoopingThreads; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.rules.RedisPortSupplier; public abstract class AbstractHScanIntegrationTest implements RedisPortSupplier { protected Jedis jedis; + private static Jedis jedis2; + private static Jedis jedis3; + private static final int REDIS_CLIENT_TIMEOUT = Math.toIntExact(GeodeAwaitility.getTimeout().toMillis()); @Before public void setUp() { jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT); + jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT); + jedis3 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT); } @After public void flushAll() { jedis.flushAll(); + jedis2.flushAll(); + jedis3.flushAll(); } @After public void tearDown() { jedis.close(); + jedis2.close(); + jedis3.close(); } + /********* Parameter Checks **************/ + @Test - public void givenNoKeyArgument_returnsWrongNumberOfArgumentsError() { + public void givenLessThanTwoArguments_returnsWrongNumberOfArgumentsError() { assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSCAN)) .hasMessageContaining("ERR wrong number of arguments for 'hscan' command"); - } - @Test - public void givenNoCursorArgument_returnsWrongNumberOfArgumentsError() { assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSCAN, "key!")) .hasMessageContaining("ERR wrong number of arguments for 'hscan' command"); } @Test - public void givenArgumentsAreNotOddAndKeyExists_returnsSyntaxError() { + public void givenMatchArgumentWithoutPatternOnExistingKey_returnsSyntaxError() { + jedis.hset("key", "b", "1"); + + assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSCAN, "key", "0", "Match")) + .hasMessageContaining(ERROR_SYNTAX); + } + + @Test + @SuppressWarnings("unchecked") + public void givenMatchArgumentWithoutPatternOnNonExistentKey_returnsEmptyArray() { + + List<Object> result = + (List<Object>) jedis.sendCommand(Protocol.Command.HSCAN, "key1", "0", "Match"); + + assertThat((List<String>) result.get(1)).isEmpty(); + } + + @Test + public void givenCountArgumentWithoutNumberOnExistingKey_returnsSyntaxError() { jedis.hset("a", "b", "1"); - assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSCAN, "a", "0", "a*")) + assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSCAN, "a", "0", "Count")) .hasMessageContaining(ERROR_SYNTAX); } @Test @SuppressWarnings("unchecked") - public void givenArgumentsAreNotOddAndKeyDoesNotExist_returnsEmptyArray() { + public void givenCountArgumentWithoutNumberOnNonExistentKey_returnsEmptyArray() { + jedis.hset("a", "b", "1"); Review comment: According to the test name, the key **should not exist** before the HSCAN is done. The HSCAN on the line below it is done on a completely different key from the hset (the hset is done on key `a` vs. the hscan is done on key `b`)... so there should be no need to do an `hset` beforehand. I commented out the hset and ran it on my local machine.... it passed on both native Redis and Geode Redis. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org