[
https://issues.apache.org/jira/browse/GEODE-8936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17283074#comment-17283074
]
ASF GitHub Bot commented on GEODE-8936:
---------------------------------------
sabbey37 commented on a change in pull request #6025:
URL: https://github.com/apache/geode/pull/6025#discussion_r574569469
##########
File path:
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/string/AbstractStringIntegrationTest.java
##########
@@ -128,6 +130,62 @@ public void testStrlen_withFloatData() {
assertThat(jedis.strlen(key)).isEqualTo(value.length);
}
+ @Test
+ public void testIncr_ErrorsWithWrongNumberOfArguments() {
+ assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR))
+ .hasMessageContaining("ERR wrong number of arguments for 'incr'
command");
+ assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR, "1",
"2"))
+ .hasMessageContaining("ERR wrong number of arguments for 'incr'
command");
+ assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR, "1",
"2", "3"))
+ .hasMessageContaining("ERR wrong number of arguments for 'incr'
command");
+ }
+
+ @Test
+ public void testIncr_errorsGivenWrongType() {
+ String key1 = "hashKey";
+ String key2 = "key";
+
+ jedis.hset(key1, "field", "non-int value");
+ jedis.set(key2, "non-int value");
+
+ assertThatThrownBy(() -> jedis.incr(key1))
+ .isInstanceOf(JedisDataException.class)
+ .hasMessageContaining(RedisConstants.ERROR_WRONG_TYPE);
+ assertThatThrownBy(() -> jedis.incr(key2))
+ .isInstanceOf(JedisDataException.class)
+ .hasMessageContaining(RedisConstants.ERROR_NOT_INTEGER);
+ }
+
+ @Test
+ public void testIncr_incrementsPositiveAndNegativeIntegerValues() {
+ String key1 = "positiveKey";
+ String key2 = "negativeKey";
+
+ jedis.set(key1, "10");
+ jedis.set(key2, "-10");
+
+ jedis.incr(key1);
+ jedis.incr(key2);
+
+ assertThat(Long.parseLong(jedis.get(key1))).isEqualTo(11L);
+ assertThat(Long.parseLong(jedis.get(key2))).isEqualTo(-9L);
+ }
+
+ @Test
+ public void testConcurrentIncr_performsAllIncrs() {
+ Jedis jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ String key = "key";
+ int expectedValue = NUM_ITERATIONS * 2;
+
+ jedis.set(key, "0");
+
+ new ConcurrentLoopingThreads(NUM_ITERATIONS,
+ (i) -> jedis.incr(key),
+ (i) -> jedis2.incr(key)).run();
+
+ assertThat(Integer.parseInt(jedis.get(key))).isEqualTo(expectedValue);
+ }
+
Review comment:
There's actually an `AbstractIncrIntegrationTest` file. Some of these
could be merged into that file. Others are duplicates. A couple tests that
aren't in either file: performing `INCR` on a key that doesn't exist, and we
test the max 64 bit signed integer value, but it would be interesting to do an
incr with the min value as well (min value is -9,223,372,036,854,775,808, so
maybe doing an INCR on -9,223,372,036,854,775,809 to see if we'll return the
minimum value, and doing an INCR on -9,223,372,036,854,775,810 to make sure we
still get the OVERFLOW error when an INCR is performed).
----------------------------------------------------------------
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:
[email protected]
> Redis: **INCR** command supported
> ---------------------------------
>
> Key: GEODE-8936
> URL: https://issues.apache.org/jira/browse/GEODE-8936
> Project: Geode
> Issue Type: Test
> Components: redis
> Reporter: Hale Bales
> Assignee: Hale Bales
> Priority: Major
> Labels: pull-request-available
>
> Write unit/integration tests that run against both Geode Redis and native
> Redis, and dunit tests which test multiple concurrent clients accessing
> different servers for the following command:
> INCR
> A.C.
> Unit/integration tests for both Geode and native Redis passing
> DUNIT tests passing
> README/redis_api_for_geode.html.md.erb updated to make command "supported"
> or
> Stories in the backlog to fix the identified issues (with JIRA tickets)
> and problem tests ignoredMGET
--
This message was sent by Atlassian Jira
(v8.3.4#803005)