ringles commented on a change in pull request #7261:
URL: https://github.com/apache/geode/pull/7261#discussion_r796093309



##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPopDUnitTest.java
##########
@@ -0,0 +1,139 @@
+/*
+ * 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.internal.commands.executor.list;
+
+import static 
org.apache.geode.test.dunit.rules.RedisClusterStartupRule.BIND_ADDRESS;
+import static 
org.apache.geode.test.dunit.rules.RedisClusterStartupRule.REDIS_CLIENT_TIMEOUT;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Supplier;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.redis.ConcurrentLoopingThreads;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+
+public class LPopDUnitTest {
+  private static final String KEY_BASE = "key";
+  private static final int NUM_LISTS = 100;
+  private static final String ELEMENT_BASE = "element-";
+  public static final int NUM_VMS = 4;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule(4);
+
+  private static final int LIST_SIZE = 100;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    MemberVM locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldDistributeDataAmongCluster_andRetainDataAfterServerCrash()
+      throws Exception {
+    List<String> elementList1 = makeElementList(0, LIST_SIZE / 2, 
ELEMENT_BASE);
+    List<String> elementList2 = makeElementList(LIST_SIZE / 2, LIST_SIZE, 
ELEMENT_BASE);
+    List<String> allElements = makeElementList(0, LIST_SIZE, ELEMENT_BASE);
+
+    new ConcurrentLoopingThreads(NUM_LISTS / 2,
+        (i) -> jedis.lpush(KEY_BASE + i, elementList1.toArray(new String[] 
{})),
+        (i) -> jedis.lpush(KEY_BASE + i, elementList2.toArray(new String[] 
{})),
+        (i) -> jedis.lpush(KEY_BASE + (i + NUM_LISTS / 2), 
elementList1.toArray(new String[] {})),
+        (i) -> jedis.lpush(KEY_BASE + (i + NUM_LISTS / 2), 
elementList2.toArray(new String[] {})))
+            .runInLockstep();
+
+    clusterStartUp.crashVM(NUM_VMS - 1);
+
+    confirmAllDataIsPresent(allElements);
+  }

Review comment:
       Have a couple tests along those lines now, instead. Had to use three 
servers for both; in the first one, if you crash the second, it fails because 
it can't ensure required redundancy.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to