You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/05/05 15:17:42 UTC

[GitHub] [geode] sabbeyPivotal commented on a change in pull request #5036: GEODE-8058: Update implementation of EXPIRE, PEXPIRE, EXPIREAT, and PEXPIREAT to be HA

sabbeyPivotal commented on a change in pull request #5036:
URL: https://github.com/apache/geode/pull/5036#discussion_r420190842



##########
File path: geode-redis/src/distributedTest/java/org/apache/geode/redis/executors/ExpireDUnitTest.java
##########
@@ -0,0 +1,233 @@
+/*
+ * 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.executors;
+
+import static org.apache.geode.distributed.ConfigurationProperties.MAX_WAIT_TIME_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.REDIS_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.REDIS_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.redis.internal.ByteArrayWrapper;
+import org.apache.geode.redis.internal.GeodeRedisService;
+import org.apache.geode.redis.internal.executor.TTLExecutor;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+
+@Ignore("GEODE-8058: this test needs to pass to have feature parity with native redis")
+public class ExpireDUnitTest {
+
+  @ClassRule
+  public static ClusterStartupRule clusterStartUp = new ClusterStartupRule(4);
+
+  static final String LOCAL_HOST = "127.0.0.1";
+  static int[] availablePorts;
+  private static final int JEDIS_TIMEOUT =
+      Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
+  static Jedis jedis1;
+  static Jedis jedis2;
+  static Jedis jedis3;
+
+  static Properties locatorProperties;
+  static Properties serverProperties1;
+  static Properties serverProperties2;
+  static Properties serverProperties3;
+
+  static MemberVM locator;
+  static MemberVM server1;
+  static MemberVM server2;
+  static MemberVM server3;
+
+  @BeforeClass
+  public static void classSetup() {
+
+    availablePorts = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+
+    locatorProperties = new Properties();
+    serverProperties1 = new Properties();
+    serverProperties2 = new Properties();
+    serverProperties3 = new Properties();
+
+    locatorProperties.setProperty(MAX_WAIT_TIME_RECONNECT, "15000");
+
+    serverProperties1.setProperty(REDIS_PORT, Integer.toString(availablePorts[0]));
+    serverProperties1.setProperty(REDIS_BIND_ADDRESS, LOCAL_HOST);
+
+    serverProperties2.setProperty(REDIS_PORT, Integer.toString(availablePorts[1]));
+    serverProperties2.setProperty(REDIS_BIND_ADDRESS, LOCAL_HOST);
+
+    serverProperties3.setProperty(REDIS_PORT, Integer.toString(availablePorts[2]));
+    serverProperties3.setProperty(REDIS_BIND_ADDRESS, LOCAL_HOST);
+
+    locator = clusterStartUp.startLocatorVM(0, locatorProperties);
+    server1 = clusterStartUp.startServerVM(1, serverProperties1, locator.getPort());
+    server2 = clusterStartUp.startServerVM(2, serverProperties2, locator.getPort());
+    server3 = clusterStartUp.startServerVM(3, serverProperties3, locator.getPort());
+
+    jedis1 = new Jedis(LOCAL_HOST, availablePorts[0], JEDIS_TIMEOUT);
+    jedis2 = new Jedis(LOCAL_HOST, availablePorts[1], JEDIS_TIMEOUT);
+    jedis3 = new Jedis(LOCAL_HOST, availablePorts[2], JEDIS_TIMEOUT);
+  }
+
+  @After
+  public void testCleanUp() {
+    jedis1.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis1.disconnect();
+    jedis2.disconnect();
+    jedis3.disconnect();
+
+    server1.stop();
+    server2.stop();
+    server3.stop();
+  }
+
+  @Test
+  public void expireOnOneServer_shouldPropagateToAllServers() {
+    String key = "key";
+
+    jedis1.set(key, "value");
+    jedis1.expire(key, 20);
+
+    assertThat(jedis2.ttl(key)).isGreaterThan(0);
+  }
+
+  @Test
+  public void expireOnOneServer_shouldResultInKeyRemovalFromOtherServer() {

Review comment:
       They're a little different since one checks to make sure the key is removed after expiration, but we could remove the duplicate assert.




----------------------------------------------------------------
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:
users@infra.apache.org