You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2020/03/31 13:14:26 UTC
[geode] branch develop updated: GEODE-7897: Run Redis integration
tests against native Redis via Docker (#4834)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 17e1d12 GEODE-7897: Run Redis integration tests against native Redis via Docker (#4834)
17e1d12 is described below
commit 17e1d122e4ce72f336c83941ea698c2c97761bde
Author: Ray Ingles <ri...@pivotal.io>
AuthorDate: Tue Mar 31 09:13:55 2020 -0400
GEODE-7897: Run Redis integration tests against native Redis via Docker (#4834)
Co-authored-by: Sarah Abbey <sa...@pivotal.io>
Co-authored-by: Jens Deppe <jd...@pivotal.io>
---
.../src/test/resources/expected-pom.xml | 94 +++++++++++----------
.../gradle/plugins/DependencyConstraints.groovy | 18 ++--
geode-redis/build.gradle | 8 +-
.../geode/redis/GeoDockerAcceptanceTest.java | 85 +++++++++++++++++++
.../geode/redis/HashesDockerAcceptanceTest.java | 52 ++++++++++++
.../geode/redis/ListsDockerAcceptanceTest.java | 48 +++++++++++
.../geode/redis/PubSubDockerAcceptanceTest.java | 58 +++++++++++++
.../geode/redis/RenameDockerAcceptanceTest.java | 66 +++++++++++++++
.../geode/redis/SetsDockerAcceptanceTest.java | 50 ++++++++++++
.../redis/SortedSetsDockerAcceptanceTest.java | 47 +++++++++++
.../geode/redis/StringsDockerAcceptanceTest.java | 63 ++++++++++++++
.../org/apache/geode/redis/GeoIntegrationTest.java | 53 ++++++------
.../apache/geode/redis/HashesIntegrationTest.java | 36 ++++----
.../apache/geode/redis/ListsIntegrationTest.java | 6 +-
.../apache/geode/redis/PubSubIntegrationTest.java | 14 ++--
...{RenameTest.java => RenameIntegrationTest.java} | 95 ++++++++++++----------
.../SetCommandNegativeCaseIntegrationTest.java | 90 --------------------
.../apache/geode/redis/SetsIntegrationTest.java | 14 +---
.../geode/redis/SortedSetsIntegrationTest.java | 5 +-
.../apache/geode/redis/StringsIntegrationTest.java | 28 +++++--
.../org/apache/geode/redis/internal/Coder.java | 6 +-
.../geode/redis/internal/RedisConstants.java | 3 +
.../redis/internal/executor/RenameExecutor.java | 3 +-
.../internal/executor/string/IncrExecutor.java | 8 +-
.../geode/redis/internal/GeoCoderJUnitTest.java} | 12 ++-
25 files changed, 692 insertions(+), 270 deletions(-)
diff --git a/boms/geode-all-bom/src/test/resources/expected-pom.xml b/boms/geode-all-bom/src/test/resources/expected-pom.xml
index f46957c..ddfe4d2 100644
--- a/boms/geode-all-bom/src/test/resources/expected-pom.xml
+++ b/boms/geode-all-bom/src/test/resources/expected-pom.xml
@@ -38,18 +38,6 @@
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.3.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.3.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
@@ -62,12 +50,24 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>com.arakelian</groupId>
+ <artifactId>java-jq</artifactId>
+ <version>0.10.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<version>2.7.3</version>
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-joda</artifactId>
+ <version>2.9.8</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.10</artifactId>
<version>2.10.0</version>
@@ -140,6 +140,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.3.2</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit4</artifactId>
<version>0.12.0</version>
@@ -230,6 +236,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.5.23</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.3.0</version>
@@ -272,6 +284,18 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.9.8</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
@@ -399,13 +423,13 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
+ <artifactId>jetty-server</artifactId>
<version>9.4.21.v20190926</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
+ <artifactId>jetty-webapp</artifactId>
<version>9.4.21.v20190926</version>
<scope>compile</scope>
</dependency>
@@ -470,12 +494,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>1.5.23</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>1.0.1.RELEASE</version>
@@ -494,6 +512,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.13.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.1.0</version>
@@ -512,30 +536,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>com.arakelian</groupId>
- <artifactId>java-jq</artifactId>
- <version>0.10.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-joda</artifactId>
- <version>2.9.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.9.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.nimbusds</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>8.11</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.0</version>
@@ -566,6 +566,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>com.nimbusds</groupId>
+ <artifactId>nimbus-jose-jwt</artifactId>
+ <version>8.11</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-core</artifactId>
<version>0.31.1</version>
diff --git a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
index 4ebae93..37beb88 100644
--- a/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
+++ b/buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
@@ -83,12 +83,11 @@ class DependencyConstraints implements Plugin<Project> {
project.dependencies {
constraints {
// informal, inter-group dependencySet
- api('com.sun.xml.bind:jaxb-impl:2.3.2')
- api('javax.xml.bind:jaxb-api:2.3.1')
-
api(group: 'antlr', name: 'antlr', version: get('antlr.version'))
api(group: 'cglib', name: 'cglib', version: get('cglib.version'))
+ api(group: 'com.arakelian', name: 'java-jq', version: '0.10.1')
api(group: 'com.carrotsearch.randomizedtesting', name: 'randomizedtesting-runner', version: '2.7.3')
+ api(group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda', version: '2.9.8')
api(group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.10', version: '2.10.0')
api(group: 'com.github.davidmoten', name: 'geo', version: '0.7.1')
api(group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0')
@@ -99,8 +98,10 @@ class DependencyConstraints implements Plugin<Project> {
api(group: 'com.google.protobuf', name: 'protobuf-java', version: get('protobuf-java.version'))
api(group: 'com.healthmarketscience.rmiio', name: 'rmiio', version: '2.1.2')
api(group: 'com.mockrunner', name: 'mockrunner-servlet', version: '2.0.1')
+ api(group: 'com.nimbusds', name:'nimbus-jose-jwt', version:'8.11')
api(group: 'com.sun.activation', name: 'javax.activation', version: '1.2.0')
api(group: 'com.sun.istack', name: 'istack-commons-runtime', version: '3.0.9')
+ api(group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.2')
api(group: 'com.tngtech.archunit', name:'archunit-junit4', version: '0.12.0')
api(group: 'com.zaxxer', name: 'HikariCP', version: '3.4.1')
api(group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4')
@@ -116,6 +117,7 @@ class DependencyConstraints implements Plugin<Project> {
api(group: 'io.github.classgraph', name: 'classgraph', version: '4.8.52')
api(group: 'io.micrometer', name: 'micrometer-core', version: get('micrometer.version'))
api(group: 'io.netty', name: 'netty-all', version: '4.1.45.Final')
+ api(group: 'io.swagger', name: 'swagger-annotations', version: '1.5.23')
api(group: 'it.unimi.dsi', name: 'fastutil', version: get('fastutil.version'))
api(group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2')
api(group: 'javax.annotation', name: 'jsr250-api', version: '1.0')
@@ -123,6 +125,8 @@ class DependencyConstraints implements Plugin<Project> {
api(group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2')
api(group: 'javax.resource', name: 'javax.resource-api', version: '1.7.1')
api(group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0')
+ api(group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1')
+ api(group: 'joda-time', name: 'joda-time', version: '2.9.8')
api(group: 'junit', name: 'junit', version: get('junit.version'))
api(group: 'mx4j', name: 'mx4j-tools', version: '3.0.1')
api(group: 'mysql', name: 'mysql-connector-java', version: '5.1.46')
@@ -144,8 +148,8 @@ class DependencyConstraints implements Plugin<Project> {
api(group: 'org.awaitility', name: 'awaitility', version: '3.1.6')
api(group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.63')
api(group: 'org.codehaus.cargo', name: 'cargo-core-uberjar', version: '1.7.7')
- api(group: 'org.eclipse.jetty', name: 'jetty-webapp', version: get('jetty.version'))
api(group: 'org.eclipse.jetty', name: 'jetty-server', version: get('jetty.version'))
+ api(group: 'org.eclipse.jetty', name: 'jetty-webapp', version: get('jetty.version'))
api(group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.2.1')
api(group: 'org.httpunit', name: 'httpunit', version: '1.7.3')
api(group: 'org.iq80.snappy', name: 'snappy', version: '0.4')
@@ -156,17 +160,13 @@ class DependencyConstraints implements Plugin<Project> {
api(group: 'org.postgresql', name: 'postgresql', version: '42.2.8')
api(group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.0')
api(group: 'org.slf4j', name: 'slf4j-api', version: get('slf4j-api.version'))
- api(group: 'io.swagger', name: 'swagger-annotations', version: '1.5.23')
api(group: 'org.springframework.hateoas', name: 'spring-hateoas', version: '1.0.1.RELEASE')
api(group: 'org.springframework.ldap', name: 'spring-ldap-core', version: '2.3.2.RELEASE')
api(group: 'org.springframework.shell', name: 'spring-shell', version: '1.2.0.RELEASE')
+ api(group: 'org.testcontainers', name: 'testcontainers', version: '1.13.0')
api(group: 'pl.pragmatists', name: 'JUnitParams', version: '1.1.0')
api(group: 'redis.clients', name: 'jedis', version: '3.2.0')
api(group: 'xerces', name: 'xercesImpl', version: '2.12.0')
- api(group: 'com.arakelian', name: 'java-jq', version: '0.10.1')
- api(group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda', version: '2.9.8')
- api(group: 'joda-time', name: 'joda-time', version: '2.9.8')
- api(group: 'com.nimbusds', name:'nimbus-jose-jwt', version:'8.11')
}
}
diff --git a/geode-redis/build.gradle b/geode-redis/build.gradle
index a8118cc..3bbcf01 100644
--- a/geode-redis/build.gradle
+++ b/geode-redis/build.gradle
@@ -37,9 +37,15 @@ dependencies {
integrationTestImplementation(project(':geode-dunit'))
integrationTestImplementation(project(':geode-junit'))
integrationTestImplementation('redis.clients:jedis')
-
integrationTestRuntime(project(':geode-log4j'))
+ acceptanceTestImplementation(sourceSets.integrationTest.output)
+ acceptanceTestImplementation(project(':geode-dunit'))
+ acceptanceTestImplementation(project(':geode-junit'))
+ acceptanceTestImplementation('redis.clients:jedis')
+ acceptanceTestImplementation('org.testcontainers:testcontainers')
+ acceptanceTestRuntime(project(':geode-log4j'))
+
distributedTestImplementation(project(':geode-dunit'))
distributedTestImplementation('redis.clients:jedis')
}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/GeoDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/GeoDockerAcceptanceTest.java
new file mode 100755
index 0000000..d816455
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/GeoDockerAcceptanceTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class GeoDockerAcceptanceTest extends GeoIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ }
+
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+
+ @Test
+ public void testGeoHash() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoRadiusByMemberWithCoord() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoRadiusByMemberFull() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoRadiusByMemberBasic() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoRadiusByMemberNorth() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoPos() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testGeoRadiusByMemberWithDist() {
+ // TODO: See JIRA GEODE-7909 Update Geo* commands in Geode Redis to match native Redis
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/HashesDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/HashesDockerAcceptanceTest.java
new file mode 100755
index 0000000..8e694e6
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/HashesDockerAcceptanceTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+import java.util.Random;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class HashesDockerAcceptanceTest extends HashesIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ rand = new Random();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ jedis2 = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ jedis2.close();
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/ListsDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/ListsDockerAcceptanceTest.java
new file mode 100755
index 0000000..0cb8cfb
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/ListsDockerAcceptanceTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class ListsDockerAcceptanceTest extends ListsIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/PubSubDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/PubSubDockerAcceptanceTest.java
new file mode 100644
index 0000000..ef92e1f
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/PubSubDockerAcceptanceTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis;
+
+
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class PubSubDockerAcceptanceTest extends PubSubIntegrationTest {
+
+ private static GenericContainer redisContainer;
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ subscriber = new Jedis("localhost", redisContainer.getFirstMappedPort(), REDIS_CLIENT_TIMEOUT);
+ publisher = new Jedis("localhost", redisContainer.getFirstMappedPort(), REDIS_CLIENT_TIMEOUT);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ subscriber.close();
+ publisher.close();
+ }
+
+ public int getPort() {
+ return redisContainer.getFirstMappedPort();
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/RenameDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/RenameDockerAcceptanceTest.java
new file mode 100644
index 0000000..ee0583b
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/RenameDockerAcceptanceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis;
+
+
+import java.util.Random;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+
+@Category({RedisTest.class})
+public class RenameDockerAcceptanceTest extends RenameIntegrationTest {
+
+ private static GenericContainer redisContainer;
+
+ @BeforeClass
+ public static void setUp() {
+ rand = new Random();
+ redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), REDIS_CLIENT_TIMEOUT);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ }
+
+ public int getPort() {
+ return redisContainer.getFirstMappedPort();
+ }
+
+ @Test
+ public void testSortedSet() {
+ // TODO: GEODE-7910 Update RENAME command in Geode Redis to match native Redis
+ }
+
+ @Test
+ public void testList() {
+ // TODO: GEODE-7910 Update RENAME command in Geode Redis to match native Redis
+ }
+
+ @Test
+ @Ignore("Test only applies to Geode Redis, ignored for native Redis")
+ public void testProtectedString() {}
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SetsDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SetsDockerAcceptanceTest.java
new file mode 100755
index 0000000..cfa3e17
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SetsDockerAcceptanceTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class SetsDockerAcceptanceTest extends SetsIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ jedis2 = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ jedis2.close();
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SortedSetsDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SortedSetsDockerAcceptanceTest.java
new file mode 100755
index 0000000..3a5e31b
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/SortedSetsDockerAcceptanceTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class SortedSetsDockerAcceptanceTest extends SortedSetsIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ }
+}
diff --git a/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/StringsDockerAcceptanceTest.java b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/StringsDockerAcceptanceTest.java
new file mode 100755
index 0000000..40ed25f
--- /dev/null
+++ b/geode-redis/src/acceptanceTest/java/org/apache/geode/redis/StringsDockerAcceptanceTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.redis;
+
+import java.util.Random;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
+import org.testcontainers.containers.GenericContainer;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.test.junit.categories.RedisTest;
+import org.apache.geode.test.junit.rules.IgnoreOnWindowsRule;
+
+@Category({RedisTest.class})
+public class StringsDockerAcceptanceTest extends StringsIntegrationTest {
+
+ // Docker compose does not work on windows in CI. Ignore this test on windows
+ // Using a RuleChain to make sure we ignore the test before the rule comes into play
+ @ClassRule
+ public static TestRule ignoreOnWindowsRule = new IgnoreOnWindowsRule();
+
+ @BeforeClass
+ public static void setUp() {
+ GenericContainer redisContainer = new GenericContainer("redis:5.0.6").withExposedPorts(6379);
+ redisContainer.start();
+ rand = new Random();
+ jedis = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ jedis2 = new Jedis("localhost", redisContainer.getFirstMappedPort(), 10000000);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ jedis2.close();
+ }
+
+ @Test
+ public void testSet_keyExistsWithDifferentDataType_returnsRedisDataTypeMismatchException() {
+ // TODO: Fix implementation of SET to always succeed regardless of data type, like Native Redis
+ }
+
+ @Test
+ public void testSet_protectedRedisDataType_throwsRedisDataTypeMismatchException() {
+ // There are no protected data types in Native Redis
+ }
+}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
index 8124a58..b38e17f 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
@@ -17,6 +17,7 @@ package org.apache.geode.redis;
import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -40,14 +41,12 @@ import redis.clients.jedis.params.GeoRadiusParam;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.cache.Region;
import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.redis.internal.ByteArrayWrapper;
import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class GeoIntegrationTest {
- private static Jedis jedis;
+ static Jedis jedis;
private static GeodeRedisServer server;
private static GemFireCache cache;
private static int port = 6379;
@@ -69,9 +68,19 @@ public class GeoIntegrationTest {
@After
public void cleanup() {
+ // TODO: GEODE-7909 Correct implementation of flushAll so it deletes Geo* keys properly and this
+ // zrem is
+ // not needed
jedis.zrem("Sicily", "Palermo", "Catania");
+ jedis.flushAll();
}
+ @AfterClass
+ public static void tearDown() {
+ jedis.close();
+ cache.close();
+ server.shutdown();
+ }
@Test
public void testGeoAdd() {
@@ -80,17 +89,18 @@ public class GeoIntegrationTest {
memberCoordinateMap.put("Catania", new GeoCoordinate(15.087269, 37.502669));
Long l = jedis.geoadd("Sicily", memberCoordinateMap);
assertTrue(l == 2L);
-
- Region<ByteArrayWrapper, ByteArrayWrapper> sicilyRegion = cache.getRegion("Sicily");
- assertNotNull("Expected region to be not NULL", sicilyRegion);
-
- // Check GeoHash
- String hash =
- sicilyRegion.get(new ByteArrayWrapper(new String("Palermo").getBytes())).toString();
- assertEquals("sqc8b49rnyte", hash);
-
- hash = sicilyRegion.get(new ByteArrayWrapper(new String("Catania").getBytes())).toString();
- assertEquals("sqdtr74hyu5n", hash);
+ // TODO: make sure GEOADD is tested sufficiently without needing to get the region/Geode
+ // internals and properly implemented
+ // Region<ByteArrayWrapper, ByteArrayWrapper> sicilyRegion = cache.getRegion("Sicily");
+ // assertNotNull("Expected region to be not NULL", sicilyRegion);
+ //
+ // // Check GeoHash
+ // String hash =
+ // sicilyRegion.get(new ByteArrayWrapper(new String("Palermo").getBytes())).toString();
+ // assertEquals("sqc8b49rnyte", hash);
+ //
+ // hash = sicilyRegion.get(new ByteArrayWrapper(new String("Catania").getBytes())).toString();
+ // assertEquals("sqdtr74hyu5n", hash);
}
@Test
@@ -154,11 +164,12 @@ public class GeoIntegrationTest {
@Test
public void testGeoRadiusBasic() {
+ // jedis.flushAll();
Map<String, GeoCoordinate> memberCoordinateMap = new HashMap<>();
memberCoordinateMap.put("Palermo", new GeoCoordinate(13.361389, 38.115556));
memberCoordinateMap.put("Catania", new GeoCoordinate(15.087269, 37.502669));
Long l = jedis.geoadd("Sicily", memberCoordinateMap);
- assertTrue(l == 2L);
+ assertThat(l).isEqualTo(2L);
List<GeoRadiusResponse> gr = jedis.georadius("Sicily", 15.0, 37.0, 100000, GeoUnit.M);
assertEquals(1, gr.size());
@@ -409,16 +420,4 @@ public class GeoIntegrationTest {
assertNotNull(ex);
assertTrue(ex.getMessage().contains("could not decode requested zset member"));
}
-
- @After
- public void flushAll() {
- jedis.flushAll();
- }
-
- @AfterClass
- public static void tearDown() {
- jedis.close();
- cache.close();
- server.shutdown();
- }
}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java
index 5a865a3..47e42b2 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/HashesIntegrationTest.java
@@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.offset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -26,6 +27,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -59,10 +61,11 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class HashesIntegrationTest {
- private static Jedis jedis;
+ static Random rand;
+ static Jedis jedis;
+ static Jedis jedis2;
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Random rand;
private static int port = 6379;
private static int ITERATION_COUNT = 4000;
@@ -83,6 +86,7 @@ public class HashesIntegrationTest {
server.start();
jedis = new Jedis("localhost", port, 10000000);
+ jedis2 = new Jedis("localhost", port, 10000000);
}
@Test
@@ -194,24 +198,27 @@ public class HashesIntegrationTest {
String key = randString();
String field = randString();
+ DecimalFormat decimalFormat = new DecimalFormat("#.#####");
double incr = rand.nextDouble();
+ String incrAsString = decimalFormat.format(incr);
+ incr = Double.valueOf(incrAsString);
if (incr == 0) {
incr = incr + 1;
}
Double response1 = jedis.hincrByFloat(key, field, incr);
- assertTrue(response1 == incr);
+ assertThat(response1).isEqualTo(incr, offset(.00001));
- assertEquals(response1, Double.valueOf(jedis.hget(key, field)));
+ assertThat(response1).isEqualTo(Double.valueOf(jedis.hget(key, field)), offset(.00001));
double response2 = jedis.hincrByFloat(randString(), randString(), incr);
- assertTrue(response2 == incr);
+ assertThat(response2).isEqualTo(incr, offset(.00001));
Double response3 = jedis.hincrByFloat(key, field, incr);
- assertTrue(response3 + "=" + 2 * incr, response3 == 2 * incr);
+ assertThat(response3).isEqualTo(2 * incr, offset(.00001));
- assertEquals(response3, Double.valueOf(jedis.hget(key, field)));
+ assertThat(response3).isEqualTo(Double.valueOf(jedis.hget(key, field)), offset(.00001));
}
@@ -253,7 +260,7 @@ public class HashesIntegrationTest {
ScanResult<Entry<String, String>> results = null;
try {
- results = jedis.hscan(key, "0");
+ results = jedis.hscan(key, "this cursor is non-numeric and so completely invalid");
fail("Must throw exception for invalid cursor");
} catch (Exception e) {
}
@@ -473,7 +480,6 @@ public class HashesIntegrationTest {
String key2 = "HMSET" + randString();
Map<String, String> record1 = new HashMap<String, String>();
Map<String, String> record2 = new HashMap<String, String>();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Runnable runnable1 = () -> doABunchOfHMSets(key1, record1, jedis);
Runnable runnable2 = () -> doABunchOfHMSets(key2, record2, jedis2);
@@ -500,7 +506,6 @@ public class HashesIntegrationTest {
String key = "HMSET" + randString();
Map<String, String> record1 = new HashMap<String, String>();
Map<String, String> record2 = new HashMap<String, String>();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Runnable runnable1 = () -> doABunchOfHMSets(key, record1, jedis);
Runnable runnable2 = () -> doABunchOfHMSets(key, record2, jedis2);
@@ -529,7 +534,6 @@ public class HashesIntegrationTest {
fields.add(randString());
}
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
CountDownLatch latch = new CountDownLatch(1);
ExecutorService pool = Executors.newFixedThreadPool(2);
@@ -564,7 +568,6 @@ public class HashesIntegrationTest {
String key2 = "HSET" + randString();
Map<String, String> record1 = new HashMap<String, String>();
Map<String, String> record2 = new HashMap<String, String>();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Runnable runnable1 = () -> doABunchOfHSets(key1, record1, jedis);
Runnable runnable2 = () -> doABunchOfHSets(key2, record2, jedis2);
@@ -591,7 +594,6 @@ public class HashesIntegrationTest {
String key1 = "HSET" + randString();
Map<String, String> record1 = new HashMap<String, String>();
Map<String, String> record2 = new HashMap<String, String>();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Runnable runnable1 = () -> doABunchOfHSets(key1, record1, jedis);
Runnable runnable2 = () -> doABunchOfHSets(key1, record2, jedis2);
@@ -615,7 +617,6 @@ public class HashesIntegrationTest {
String key1 = "HSET" + randString();
String field = "FIELD" + randString();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
jedis.hset(key1, field, "0");
@@ -643,7 +644,6 @@ public class HashesIntegrationTest {
String key = "HSET" + randString();
String field = "FIELD" + randString();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
jedis.hset(key, field, "0");
@@ -658,7 +658,7 @@ public class HashesIntegrationTest {
thread2.join();
String value = jedis.hget(key, field);
- assertThat(value).isEqualTo(String.format("%.1f", ITERATION_COUNT * 0.75));
+ assertThat(value).isEqualTo(String.format("%.0f", ITERATION_COUNT * 0.75));
}
private void doABunchOfHIncrByFloats(String key, String field, int incrCount, double incrValue,
@@ -674,7 +674,6 @@ public class HashesIntegrationTest {
String key1 = "HSET" + randString();
ArrayBlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(ITERATION_COUNT);
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Runnable runnable1 = () -> doABunchOfHSetsWithBlockingQueue(key1, blockingQueue, jedis);
Runnable runnable2 = () -> doABunchOfHDelsWithBlockingQueue(key1, blockingQueue, jedis2);
@@ -694,7 +693,6 @@ public class HashesIntegrationTest {
String key1 = "HSET" + randString();
HashMap<String, String> record = new HashMap<>();
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
doABunchOfHSets(key1, record, jedis);
ExecutorService pool = Executors.newFixedThreadPool(2);
@@ -788,11 +786,13 @@ public class HashesIntegrationTest {
@After
public void flushAll() {
jedis.flushAll();
+ jedis2.flushAll();
}
@AfterClass
public static void tearDown() {
jedis.close();
+ jedis2.close();
cache.close();
server.shutdown();
}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java
index 9f21d3a..bfc0e69 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/ListsIntegrationTest.java
@@ -38,16 +38,14 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class ListsIntegrationTest {
-
- private static Jedis jedis;
+ static Jedis jedis;
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Random rand;
+ private static Random rand = new Random();
private static int port = 6379;
@BeforeClass
public static void setUp() {
- rand = new Random();
CacheFactory cf = new CacheFactory();
cf.set(LOG_LEVEL, "error");
cf.set(MCAST_PORT, "0");
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java
index 52e9eb8..35c01bc 100644
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/PubSubIntegrationTest.java
@@ -41,11 +41,11 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class PubSubIntegrationTest {
- private static final int REDIS_CLIENT_TIMEOUT = 100000;
+ static Jedis publisher;
+ static Jedis subscriber;
+ static final int REDIS_CLIENT_TIMEOUT = 100000;
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Jedis publisher;
- private static Jedis subscriber;
private static int port = 6379;
@BeforeClass
@@ -72,6 +72,10 @@ public class PubSubIntegrationTest {
server.shutdown();
}
+ public int getPort() {
+ return port;
+ }
+
@Test
public void testOneSubscriberOneChannel() {
List<String> expectedMessages = Arrays.asList("hello");
@@ -151,7 +155,7 @@ public class PubSubIntegrationTest {
@Test
public void testTwoSubscribersOneChannel() {
- Jedis subscriber2 = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT);
+ Jedis subscriber2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
MockSubscriber mockSubscriber1 = new MockSubscriber();
MockSubscriber mockSubscriber2 = new MockSubscriber();
@@ -213,7 +217,7 @@ public class PubSubIntegrationTest {
@Test
public void testDeadSubscriber() {
- Jedis deadSubscriber = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT);
+ Jedis deadSubscriber = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
MockSubscriber mockSubscriber = new MockSubscriber();
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java
similarity index 66%
rename from geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameTest.java
rename to geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java
index 71e64ab..65745a3 100644
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/RenameIntegrationTest.java
@@ -36,19 +36,22 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import redis.clients.jedis.Jedis;
+import redis.clients.jedis.exceptions.JedisDataException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.internal.AvailablePortHelper;
import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator;
+import org.apache.geode.redis.internal.RedisConstants;
import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
-public class RenameTest {
+public class RenameIntegrationTest {
+ static Jedis jedis;
+ static final int REDIS_CLIENT_TIMEOUT = 100000;
+ static Random rand;
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Random rand;
- private static Jedis client;
private static int port = 6379;
private static ThreePhraseGenerator generator = new ThreePhraseGenerator();
@@ -62,73 +65,80 @@ public class RenameTest {
cache = cacheFactory.create();
port = AvailablePortHelper.getRandomAvailableTCPPort();
server = new GeodeRedisServer("localhost", port);
- client = new Jedis("localhost", port, 100000);
+ jedis = new Jedis("localhost", port, REDIS_CLIENT_TIMEOUT);
server.start();
}
@AfterClass
public static void tearDown() {
- client.close();
+ jedis.close();
cache.close();
server.shutdown();
}
+ public int getPort() {
+ return port;
+ }
+
@After
public void flush() {
- client.flushAll();
+ jedis.flushAll();
}
@Test
public void testNewKey() {
- client.set("foo", "bar");
- client.rename("foo", "newfoo");
- assertThat(client.get("newfoo")).isEqualTo("bar");
+ jedis.set("foo", "bar");
+ jedis.rename("foo", "newfoo");
+ assertThat(jedis.get("newfoo")).isEqualTo("bar");
}
@Test
public void testOldKeyIsDeleted() {
- client.set("foo", "bar");
- client.rename("foo", "newfoo");
- assertThat(client.get("foo")).isNull();
+ jedis.set("foo", "bar");
+ jedis.rename("foo", "newfoo");
+ assertThat(jedis.get("foo")).isNull();
}
@Test
public void testRenameKeyThatDoesNotExist() {
- String renameResult = client.rename("foo", "newfoo");
- assertThat(renameResult).isNull();
+ try {
+ jedis.rename("foo", "newfoo");
+ } catch (JedisDataException e) {
+ assertThat(e.getMessage()).contains(RedisConstants.ERROR_NO_SUCH_KEY);
+ }
}
@Test
public void testProtectedString() {
- client.set("foo", "bar");
- assertThatThrownBy(() -> client.rename("foo", GeodeRedisServer.STRING_REGION));
+ jedis.set("foo", "bar");
+ assertThatThrownBy(() -> jedis.rename("foo", GeodeRedisServer.STRING_REGION));
}
@Test
public void testHashMap() {
- client.hset("foo", "field", "va");
- client.rename("foo", "newfoo");
- assertThat(client.hget("newfoo", "field")).isEqualTo("va");
+ jedis.hset("foo", "field", "va");
+ jedis.rename("foo", "newfoo");
+ assertThat(jedis.hget("newfoo", "field")).isEqualTo("va");
}
@Test
public void testSet() {
- client.sadd("foo", "data");
- client.rename("foo", "newfoo");
- assertThat(client.smembers("newfoo")).contains("data");
+ jedis.sadd("foo", "data");
+ jedis.rename("foo", "newfoo");
+ assertThat(jedis.smembers("newfoo")).contains("data");
}
@Test
public void testSortedSet() {
- client.zadd("foo", 1.0, "data");
- assertThatThrownBy(() -> client.rename("foo", "newfoo"));
+ jedis.zadd("foo", 1.0, "data");
+ assertThatThrownBy(() -> jedis.rename("foo", "newfoo"));
}
@Test
public void testList() {
- client.lpush("person", "Bern");
- assertThatThrownBy(() -> client.rename("person", "newPerson"));
+ jedis.lpush("person", "Bern");
+ assertThatThrownBy(() -> jedis.rename("person", "newPerson"));
}
@Test
@@ -136,34 +146,37 @@ public class RenameTest {
Set<String> stringsForK1 = new HashSet<String>();
Set<String> stringsForK2 = new HashSet<String>();
- Jedis client2 = new Jedis("localhost", port, 10000000);
- Jedis client3 = new Jedis("localhost", port, 10000000);
+ Jedis jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ Jedis jedis3 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
int numOfStrings = 500000;
- Callable<Long> callable1 = () -> {
- return addStringsToKeys(stringsForK1, "k1", numOfStrings, client);
- };
+ Callable<Long> callable1 =
+ () -> addStringsToKeys(stringsForK1, "k1", numOfStrings, jedis);
int numOfStringsForSecondKey = 30000;
Callable<Long> callable2 =
- () -> addStringsToKeys(stringsForK2, "k2", numOfStringsForSecondKey, client2);
- Callable<String> callable3 = () -> renameKeys(client3);
+ () -> addStringsToKeys(stringsForK2, "k2", numOfStringsForSecondKey, jedis2);
+ Callable<String> callable3 = () -> renameKeys(jedis3);
ExecutorService pool = Executors.newFixedThreadPool(4);
Future<Long> future1 = pool.submit(callable1);
Future<Long> future2 = pool.submit(callable2);
+ Thread.sleep(rand.nextInt(1000));
Future<String> future3 = pool.submit(callable3);
future1.get();
future2.get();
- String renameResult = future3.get();
-
- if (renameResult == null) {
- assertThat(client.scard("k1")).isEqualTo(numOfStrings);
- assertThat(client.scard("k2")).isEqualTo(numOfStringsForSecondKey);
- } else {
- assertThat(client.scard("k2")).isEqualTo(numOfStrings);
- assertThat(client.get("k1")).isEqualTo(null);
+ try {
+ future3.get();
+ assertThat(jedis.scard("k2")).isEqualTo(numOfStrings);
+ assertThat(jedis.get("k1")).isEqualTo(null);
+ } catch (Exception e) {
+ assertThat(e.getMessage()).contains(RedisConstants.ERROR_NO_SUCH_KEY);
+ assertThat(jedis.scard("k1")).isEqualTo(numOfStrings);
+ assertThat(jedis.scard("k2")).isEqualTo(numOfStringsForSecondKey);
}
+
+ jedis2.close();
+ jedis3.close();
}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetCommandNegativeCaseIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetCommandNegativeCaseIntegrationTest.java
deleted file mode 100644
index 788a2f7..0000000
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetCommandNegativeCaseIntegrationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.redis;
-
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.redis.GeodeRedisServer.REDIS_META_DATA_REGION;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.util.Random;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.exceptions.JedisDataException;
-
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.test.junit.categories.RedisTest;
-
-@Category({RedisTest.class})
-public class SetCommandNegativeCaseIntegrationTest {
- private static Jedis jedis;
- private static GeodeRedisServer server;
- private static GemFireCache cache;
- private static Random rand;
- private static int port = 6379;
-
- @BeforeClass
- public static void setUp() {
- rand = new Random();
- CacheFactory cf = new CacheFactory();
- cf.set(LOG_LEVEL, "error");
- cf.set(MCAST_PORT, "0");
- cf.set(LOCATORS, "");
- cache = cf.create();
- port = AvailablePortHelper.getRandomAvailableTCPPort();
- server = new GeodeRedisServer("localhost", port);
-
- server.start();
- jedis = new Jedis("localhost", port, 10000000);
- }
-
-
- @After
- public void flushAll() {
- jedis.flushAll();
- }
-
- @AfterClass
- public static void tearDown() {
- jedis.close();
- cache.close();
- server.shutdown();
- }
-
- @Test
- public void Should_Throw_RedisDataTypeMismatchException_Given_Key_Already_Exists_With_Different_RedisDataType() {
- jedis.hset("key", "field", "value");
-
- assertThatThrownBy(
- () -> jedis.set("key", "something else")).isInstanceOf(JedisDataException.class)
- .hasMessageContaining("WRONGTYPE");
- }
-
- @Test
- public void Should_Throw_RedisDataTypeMismatchException_Given_RedisDataType_REDIS_PROTECTED() {
- assertThatThrownBy(
- () -> jedis.set(REDIS_META_DATA_REGION, "something else"))
- .isInstanceOf(JedisDataException.class)
- .hasMessageContaining("protected");
- }
-}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
index 8833cc2..c0cb97d 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
@@ -46,12 +46,12 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class SetsIntegrationTest {
- private static Jedis jedis;
+ static Jedis jedis;
+ static Jedis jedis2;
private static GeodeRedisServer server;
private static GemFireCache cache;
private static ThreePhraseGenerator generator = new ThreePhraseGenerator();
private static int port = 6379;
- private static int ITERATIONS = 1000;
@BeforeClass
public static void setUp() throws IOException {
@@ -65,11 +65,13 @@ public class SetsIntegrationTest {
server.start();
jedis = new Jedis("localhost", port, 10000000);
+ jedis2 = new Jedis("localhost", port, 10000000);
}
@AfterClass
public static void tearDown() {
jedis.close();
+ jedis2.close();
cache.close();
server.shutdown();
}
@@ -100,7 +102,6 @@ public class SetsIntegrationTest {
public void testConcurrentSAddSCard_sameKeyPerClient()
throws InterruptedException, ExecutionException {
int elements = 1000;
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Set<String> strings1 = new HashSet<String>();
Set<String> strings2 = new HashSet<String>();
String key = generator.generate('x');
@@ -128,7 +129,6 @@ public class SetsIntegrationTest {
public void testConcurrentSAddSCard_differentKeyPerClient()
throws InterruptedException, ExecutionException {
int elements = 1000;
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Set<String> strings = new HashSet<String>();
String key1 = generator.generate('x');
String key2 = generator.generate('y');
@@ -242,7 +242,6 @@ public class SetsIntegrationTest {
public void testConcurrentSMove() throws ExecutionException, InterruptedException {
String source = generator.generate('x');
String dest = generator.generate('y');
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
int elements = 1000;
Set<String> strings = new HashSet<String>();
generateStrings(elements, strings, 'x');
@@ -335,7 +334,6 @@ public class SetsIntegrationTest {
public void testConcurrentSDiffStore() throws InterruptedException {
int ENTRIES = 100;
int SUBSET_SIZE = 100;
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Set<String> masterSet = new HashSet<>();
for (int i = 0; i < ENTRIES; i++) {
@@ -448,7 +446,6 @@ public class SetsIntegrationTest {
public void testConcurrentSInterStore() throws InterruptedException {
int ENTRIES = 100;
int SUBSET_SIZE = 100;
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Set<String> masterSet = new HashSet<>();
for (int i = 0; i < ENTRIES; i++) {
@@ -553,7 +550,6 @@ public class SetsIntegrationTest {
public void testConcurrentSUnionStore() throws InterruptedException {
int ENTRIES = 100;
int SUBSET_SIZE = 100;
- Jedis jedis2 = new Jedis("localhost", port, 10000000);
Set<String> masterSet = new HashSet<>();
for (int i = 0; i < ENTRIES; i++) {
@@ -660,7 +656,6 @@ public class SetsIntegrationTest {
@Test
public void testConcurrentSPops() throws InterruptedException {
- Jedis jedis2 = new Jedis("localhost", port, 100000);
int ENTRIES = 1000;
List<String> masterSet = new ArrayList<>();
@@ -716,7 +711,6 @@ public class SetsIntegrationTest {
@Test
public void testConcurrentSRems() throws InterruptedException {
- Jedis jedis2 = new Jedis("localhost", port, 100000);
int ENTRIES = 1000;
List<String> masterSet = new ArrayList<>();
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java
index 8bea004..8017146 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SortedSetsIntegrationTest.java
@@ -48,15 +48,14 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class SortedSetsIntegrationTest {
- private static Jedis jedis;
+ static Jedis jedis;
+ private static Random rand = new Random();
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Random rand;
private static int port = 6379;
@BeforeClass
public static void setUp() {
- rand = new Random();
CacheFactory cf = new CacheFactory();
cf.set(LOG_LEVEL, "error");
cf.set(MCAST_PORT, "0");
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java
index f6b7694..94413b3 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/StringsIntegrationTest.java
@@ -18,6 +18,7 @@ import static java.lang.Integer.parseInt;
import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.redis.GeodeRedisServer.REDIS_META_DATA_REGION;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -53,11 +54,11 @@ import org.apache.geode.test.junit.categories.RedisTest;
@Category({RedisTest.class})
public class StringsIntegrationTest {
- private static Jedis jedis;
- private static Jedis jedis2;
+ static Jedis jedis;
+ static Jedis jedis2;
+ static Random rand;
private static GeodeRedisServer server;
private static GemFireCache cache;
- private static Random rand;
private static int port = 6379;
private static int ITERATION_COUNT = 4000;
@@ -268,6 +269,23 @@ public class StringsIntegrationTest {
}
@Test
+ public void testSet_keyExistsWithDifferentDataType_returnsRedisDataTypeMismatchException() {
+ jedis.hset("key", "field", "value");
+
+ assertThatThrownBy(
+ () -> jedis.set("key", "something else")).isInstanceOf(JedisDataException.class)
+ .hasMessageContaining("WRONGTYPE");
+ }
+
+ @Test
+ public void testSet_protectedRedisDataType_throwsRedisDataTypeMismatchException() {
+ assertThatThrownBy(
+ () -> jedis.set(REDIS_META_DATA_REGION, "something else"))
+ .isInstanceOf(JedisDataException.class)
+ .hasMessageContaining("protected");
+ }
+
+ @Test
public void testGetSet_shouldBeAtomic()
throws ExecutionException, InterruptedException, TimeoutException {
jedis.set("contestedKey", "0");
@@ -585,7 +603,7 @@ public class StringsIntegrationTest {
try {
jedis.incr(key);
} catch (JedisDataException e) {
- assertThat(e.getMessage()).contains("value is not an integer or out of range");
+ assertThat(e.getMessage()).contains(RedisConstants.ERROR_OVERFLOW);
}
assertThat(jedis.get(key)).isEqualTo(max64BitIntegerValue);
}
@@ -599,7 +617,7 @@ public class StringsIntegrationTest {
try {
jedis.incr(key);
} catch (JedisDataException e) {
- assertThat(e.getMessage()).contains(RedisConstants.ERROR_WRONG_TYPE);
+ assertThat(e.getMessage()).contains(RedisConstants.ERROR_NOT_INTEGER);
}
assertThat(jedis.get(key)).isEqualTo(nonIntegerValue);
}
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/Coder.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/Coder.java
index 3a40eb0..f8a537f 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/Coder.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/Coder.java
@@ -475,7 +475,11 @@ public class Coder {
return "-Infinity";
}
- return String.valueOf(d);
+ String stringValue = String.valueOf(d);
+ if (stringValue.endsWith(".0")) {
+ return (stringValue.substring(0, stringValue.length() - 2));
+ }
+ return stringValue;
}
public static byte[] stringToBytes(String string) {
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
index e8c0fd1..2d38a8f 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
@@ -65,6 +65,9 @@ public class RedisConstants {
public static final String ERROR_ZSET_MEMBER_NOT_FOUND = "could not decode requested zset member";
public static final String ERROR_WRONG_TYPE =
"WRONGTYPE Operation against a key holding the wrong kind of value";
+ public static final String ERROR_NOT_INTEGER = "value is not an integer or out of range";
+ public static final String ERROR_OVERFLOW = "increment or decrement would overflow";
+ public static final String ERROR_NO_SUCH_KEY = "no such key";
public static class ArityDef {
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
index 7458ba0..d3c2a20 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
@@ -41,7 +41,8 @@ public class RenameExecutor extends StringExecutor {
ByteArrayWrapper newKey = new ByteArrayWrapper(commandElems.get(2));
if (!context.getKeyRegistrar().isRegistered(key)) {
- command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
+ command.setResponse(
+ Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_NO_SUCH_KEY));
return;
}
diff --git a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/string/IncrExecutor.java b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/string/IncrExecutor.java
index f497bf1..352e558 100755
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/string/IncrExecutor.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/string/IncrExecutor.java
@@ -27,8 +27,6 @@ import org.apache.geode.redis.internal.RedisConstants;
import org.apache.geode.redis.internal.RedisConstants.ArityDef;
public class IncrExecutor extends StringExecutor {
- private final String ERROR_OVERFLOW = "value is not an integer or out of range";
-
private final int INIT_VALUE_INT = 1;
@Override
@@ -72,12 +70,14 @@ public class IncrExecutor extends StringExecutor {
value = Long.parseLong(stringValue);
} catch (NumberFormatException e) {
command.setResponse(
- Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_WRONG_TYPE));
+ Coder.getErrorResponse(context.getByteBufAllocator(),
+ RedisConstants.ERROR_NOT_INTEGER));
return;
}
if (value == Long.MAX_VALUE) {
- command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ERROR_OVERFLOW));
+ command.setResponse(
+ Coder.getErrorResponse(context.getByteBufAllocator(), RedisConstants.ERROR_OVERFLOW));
return;
}
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoCoderIntegrationTest.java b/geode-redis/src/test/java/org/apache/geode/redis/internal/GeoCoderJUnitTest.java
old mode 100755
new mode 100644
similarity index 81%
rename from geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoCoderIntegrationTest.java
rename to geode-redis/src/test/java/org/apache/geode/redis/internal/GeoCoderJUnitTest.java
index 74614e9..4bef6b0
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoCoderIntegrationTest.java
+++ b/geode-redis/src/test/java/org/apache/geode/redis/internal/GeoCoderJUnitTest.java
@@ -11,27 +11,25 @@
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
+ *
*/
-package org.apache.geode.redis;
+package org.apache.geode.redis.internal;
import static org.junit.Assert.assertEquals;
import com.github.davidmoten.geo.LatLong;
import org.junit.Test;
-import org.apache.geode.redis.internal.CoderException;
-import org.apache.geode.redis.internal.GeoCoder;
-
-public class GeoCoderIntegrationTest {
+public class GeoCoderJUnitTest {
@Test
- public void testGeoHash() throws CoderException {
+ public void testGeoHash() {
String hash = GeoCoder.geohash(Double.toString(13.361389).getBytes(),
Double.toString(38.115556).getBytes());
assertEquals("sqc8b49rnyte", hash);
}
@Test
- public void testGeoPos() throws CoderException {
+ public void testGeoPos() {
LatLong pos = GeoCoder.geoPos("sqc8b49rnyte");
assertEquals(13.361389, pos.getLon(), 0.000001);
assertEquals(38.115556, pos.getLat(), 0.000001);