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



##########
File path: 
geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/list/AbstractLPopIntegrationTest.java
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.redis.RedisCommandArgumentsTestHelper.assertAtMostNArgs;
+import static org.apache.geode.redis.internal.RedisConstants.ERROR_WRONG_TYPE;
+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 static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.ConcurrentLoopingThreads;
+import org.apache.geode.redis.RedisIntegrationTest;
+
+public abstract class AbstractLPopIntegrationTest implements 
RedisIntegrationTest {
+  public static final String KEY = "key";
+  public static final String PREEXISTING_VALUE = "preexistingValue";
+  // TODO: make private when we implement Redis 6.2+ behavior for LPOP
+  protected JedisCluster jedis;
+
+  @Before
+  public void setUp() {
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, getPort()), 
REDIS_CLIENT_TIMEOUT);
+  }
+
+  @After
+  public void tearDown() {
+    flushAll();
+    jedis.close();
+  }
+
+  // Overridden in LPopIntegrationTest until we implement Redis 6.2+ semantics
+  @Test
+  public void lpop_givenWrongNumOfArgs_returnsError() {
+    assertAtMostNArgs(jedis, Protocol.Command.LPOP, 2);
+  }
+
+  @Test
+  public void lpop_withNonListKey_Fails() {
+    jedis.set("string", PREEXISTING_VALUE);
+    assertThatThrownBy(() -> 
jedis.lpop("string")).hasMessageContaining(ERROR_WRONG_TYPE);

Review comment:
       Could this assertion be changed to be `hasMessage()` so as to be more 
explicit please?

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPopDUnitTest.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPopDUnitTest {
+  public static final int MINIMUM_ITERATIONS = 10000;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @After
+  public void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldDistributeDataAmongCluster_andRetainDataAfterServerCrash() 
{
+    String key = makeListKeyWithHashtag(1, 
clusterStartUp.getKeyOnServer("lpop", 1));
+    List<String> elementList = makeElementList(key, MINIMUM_ITERATIONS);
+    lpushPerformAndVerify(key, elementList);
+
+    // Remove all but last element
+    for (int i = MINIMUM_ITERATIONS - 1; i > 0; i--) {
+      assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, i));
+    }
+    clusterStartUp.crashVM(1); // kill primary server
+
+    assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, 0));

Review comment:
       Could this be changed to 
   ```
   assertThat(jedis.lpop(key)).isEqualTo(elementList.get(0));
   ```
   since we already have the list of elements we added, so we don't need to 
create a new element to check here.

##########
File path: 
geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/list/AbstractLPopIntegrationTest.java
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.redis.RedisCommandArgumentsTestHelper.assertAtMostNArgs;
+import static org.apache.geode.redis.internal.RedisConstants.ERROR_WRONG_TYPE;
+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 static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.ConcurrentLoopingThreads;
+import org.apache.geode.redis.RedisIntegrationTest;
+
+public abstract class AbstractLPopIntegrationTest implements 
RedisIntegrationTest {
+  public static final String KEY = "key";
+  public static final String PREEXISTING_VALUE = "preexistingValue";
+  // TODO: make private when we implement Redis 6.2+ behavior for LPOP
+  protected JedisCluster jedis;
+
+  @Before
+  public void setUp() {
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, getPort()), 
REDIS_CLIENT_TIMEOUT);
+  }
+
+  @After
+  public void tearDown() {
+    flushAll();
+    jedis.close();
+  }
+
+  // Overridden in LPopIntegrationTest until we implement Redis 6.2+ semantics
+  @Test
+  public void lpop_givenWrongNumOfArgs_returnsError() {
+    assertAtMostNArgs(jedis, Protocol.Command.LPOP, 2);
+  }
+
+  @Test
+  public void lpop_withNonListKey_Fails() {
+    jedis.set("string", PREEXISTING_VALUE);
+    assertThatThrownBy(() -> 
jedis.lpop("string")).hasMessageContaining(ERROR_WRONG_TYPE);
+  }
+
+  @Test
+  public void lpop_withNonExistentKey_returnsNull() {
+    assertThat(jedis.lpop("nonexistent")).isNull();
+  }
+
+  @Test
+  public void lpop_returnsLeftmostMember() {
+    jedis.lpush(KEY, "e1", "e2");
+    String result = jedis.lpop(KEY);
+    assertThat(result).isEqualTo("e2");
+  }
+
+  @Test
+  public void lpop_removesKey_whenLastElementRemoved() {
+    final String keyWithTagForKeysCommand = "{tag}" + KEY;
+
+    jedis.lpush(keyWithTagForKeysCommand, "e1");
+    jedis.lpop(keyWithTagForKeysCommand);
+    assertThat(jedis.keys(keyWithTagForKeysCommand)).isEmpty();
+  }
+
+  @Test
+  public void lpop_removesKey_whenLastElementRemoved_multipleTimes() {
+    final String key = KEY;
+
+    jedis.lpush(key, "e1");
+    assertThat(jedis.lpop(key)).isEqualTo("e1");
+    assertThat(jedis.lpop(key)).isNull();
+    assertThat(jedis.lpop(key)).isNull();
+    assertThat(jedis.exists(key)).isFalse();
+  }
+
+  @Test
+  public void lpop_withConcurrentLPush_returnsCorrectValue() {
+    String[] valuesInitial = new String[] {"un", "deux", "troix"};
+    String[] valuesToAdd = new String[] {"plum", "peach", "orange"};
+    jedis.lpush(KEY, valuesInitial);
+
+    final AtomicReference<String> lpopReference = new AtomicReference<>();
+    new ConcurrentLoopingThreads(1000,
+        i -> jedis.lpush(KEY, valuesToAdd),
+        i -> lpopReference.set(jedis.lpop(KEY)))
+            .runWithAction(() -> {
+              assertThat(lpopReference).satisfiesAnyOf(
+                  lpopResult -> 
assertThat(lpopReference.get()).isEqualTo("orange"),
+                  lpopResult -> 
assertThat(lpopReference.get()).isEqualTo("troix"),
+                  lpopResult -> assertThat(lpopReference.get()).isNull());

Review comment:
       I'm not sure under what circumstances we would ever expect LPOP to 
return null in this test, since the list always contains something. If we ever 
do return null, then something is wrong.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();

Review comment:
       Compiler warnings here and elsewhere in the file can be fixed by using 
`Future<Void>`

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }

Review comment:
       Since we create the JedisCluster in the `@Before` method, we should 
probably call `close()` on it in an `@After` rather than an `@AfterClass` 
method.

##########
File path: 
geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/list/AbstractLPushIntegrationTest.java
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+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 static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+import redis.clients.jedis.exceptions.JedisDataException;
+
+import org.apache.geode.redis.RedisIntegrationTest;
+
+public abstract class AbstractLPushIntegrationTest implements 
RedisIntegrationTest {
+  public static final String KEY = "key";
+  public static final String PREEXISTING_VALUE = "preexistingValue";
+  private JedisCluster jedis;
+
+  @Before
+  public void setUp() {
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, getPort()), 
REDIS_CLIENT_TIMEOUT);
+  }
+
+  @After
+  public void tearDown() {
+    flushAll();
+    jedis.close();
+  }
+
+  @Test
+  public void lpushErrors_givenTooFewArguments() {
+    assertAtLeastNArgs(jedis, Protocol.Command.LPUSH, 2);
+  }
+
+  @Test
+  public void 
lpush_withExistingKey_ofWrongType_returnsWrongTypeError_shouldNotOverWriteExistingKey()
 {
+    String elementValue = "list element value that should never get added";
+
+    jedis.set(KEY, PREEXISTING_VALUE);
+
+    assertThatThrownBy(() -> jedis.lpush(KEY, 
elementValue)).isInstanceOf(JedisDataException.class);

Review comment:
       Could we also assert on the message returned with the error here, using 
`hasMessage()`?

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }
+    assertThat(totalLength)
+        .isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * PUSHER_COUNT * 
PUSH_LIST_SIZE);
+    clusterStartUp.crashVM(1); // kill primary server, just in case test order 
is reversed

Review comment:
       Rather than adding this line here, it would be better to move all 
cluster set-up to the `@Before` method and make the `RedisClusterStartupRule` a 
`@Rule` rather than a `@ClassRule`. This will make the tests take a little 
longer, since we have to recreate the cluster every time rather than just 
server1, but it means that the `RedisClusterStartupRule` will handle shutting 
down all the members at the end of each test, so there's no chance of test 
order mucking things up. This also applies to LPopDUnitTest, which has a 
similar potential issue around test ordering.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPopDUnitTest.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPopDUnitTest {
+  public static final int MINIMUM_ITERATIONS = 10000;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @After
+  public void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldDistributeDataAmongCluster_andRetainDataAfterServerCrash() 
{
+    String key = makeListKeyWithHashtag(1, 
clusterStartUp.getKeyOnServer("lpop", 1));
+    List<String> elementList = makeElementList(key, MINIMUM_ITERATIONS);
+    lpushPerformAndVerify(key, elementList);
+
+    // Remove all but last element
+    for (int i = MINIMUM_ITERATIONS - 1; i > 0; i--) {
+      assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, i));
+    }
+    clusterStartUp.crashVM(1); // kill primary server
+
+    assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, 0));
+    assertThat(jedis.exists(key)).isFalse();
+  }
+
+  @Test
+  public void givenBucketsMoveDuringLpop_thenOperationsAreNotLost() throws 
Exception {
+    AtomicLong runningCount = new AtomicLong(3);
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+
+    List<String> elementList1 = makeElementList(keys.get(0), 
MINIMUM_ITERATIONS);
+    List<String> elementList2 = makeElementList(keys.get(1), 
MINIMUM_ITERATIONS);
+    List<String> elementList3 = makeElementList(keys.get(2), 
MINIMUM_ITERATIONS);
+
+    lpushPerformAndVerify(keys.get(0), elementList1);
+    lpushPerformAndVerify(keys.get(1), elementList2);
+    lpushPerformAndVerify(keys.get(2), elementList3);
+
+    Runnable task1 =
+        () -> lpopPerformAndVerify(keys.get(0), runningCount);
+    Runnable task2 =
+        () -> lpopPerformAndVerify(keys.get(1), runningCount);
+    Runnable task3 =
+        () -> lpopPerformAndVerify(keys.get(2), runningCount);
+
+    Future<Void> future1 = executor.runAsync(task1);
+    Future<Void> future2 = executor.runAsync(task2);
+    Future<Void> future3 = executor.runAsync(task3);
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);

Review comment:
       This is kind of a misuse of `await()` since nothing's actually being 
awaited on. It would be better to just explicitly use a `Thread.sleep()` since 
that's what ends up getting called under the covers anyway, but makes it more 
obvious what the code is trying to achieve. Either that, or find something 
specific to assert on that ensures we're not moving buckets too quickly.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()

Review comment:
       This test might be better named something like 
"givenBucketsMovedDuringLPush_elementsAreAddedAtomically" since the buckets 
moving part is integral to triggering the potential issues.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }
+    assertThat(totalLength)
+        .isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * PUSHER_COUNT * 
PUSH_LIST_SIZE);

Review comment:
       This assertion is redundant, since it's not possible for all three keys 
to have lengths greater than or equal to `MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE` but the sum of those three values to be less than 
`MINIMUM_ITERATIONS * PUSHER_COUNT * PUSH_LIST_SIZE`.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPopDUnitTest.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPopDUnitTest {
+  public static final int MINIMUM_ITERATIONS = 10000;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @After
+  public void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldDistributeDataAmongCluster_andRetainDataAfterServerCrash() 
{
+    String key = makeListKeyWithHashtag(1, 
clusterStartUp.getKeyOnServer("lpop", 1));
+    List<String> elementList = makeElementList(key, MINIMUM_ITERATIONS);
+    lpushPerformAndVerify(key, elementList);
+
+    // Remove all but last element
+    for (int i = MINIMUM_ITERATIONS - 1; i > 0; i--) {
+      assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, i));
+    }
+    clusterStartUp.crashVM(1); // kill primary server
+
+    assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, 0));
+    assertThat(jedis.exists(key)).isFalse();
+  }
+
+  @Test
+  public void givenBucketsMoveDuringLpop_thenOperationsAreNotLost() throws 
Exception {
+    AtomicLong runningCount = new AtomicLong(3);
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+
+    List<String> elementList1 = makeElementList(keys.get(0), 
MINIMUM_ITERATIONS);
+    List<String> elementList2 = makeElementList(keys.get(1), 
MINIMUM_ITERATIONS);
+    List<String> elementList3 = makeElementList(keys.get(2), 
MINIMUM_ITERATIONS);
+
+    lpushPerformAndVerify(keys.get(0), elementList1);
+    lpushPerformAndVerify(keys.get(1), elementList2);
+    lpushPerformAndVerify(keys.get(2), elementList3);
+
+    Runnable task1 =
+        () -> lpopPerformAndVerify(keys.get(0), runningCount);
+    Runnable task2 =
+        () -> lpopPerformAndVerify(keys.get(1), runningCount);
+    Runnable task3 =
+        () -> lpopPerformAndVerify(keys.get(2), runningCount);
+
+    Future<Void> future1 = executor.runAsync(task1);
+    Future<Void> future2 = executor.runAsync(task2);
+    Future<Void> future3 = executor.runAsync(task3);
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    runningCount.set(0);
+
+    future1.get();
+    future2.get();
+    future3.get();
+  }
+
+  private List<String> makeListHashtags() {
+    List<String> listHashtags = new ArrayList<>();
+    listHashtags.add(clusterStartUp.getKeyOnServer("lpop", 1));
+    listHashtags.add(clusterStartUp.getKeyOnServer("lpop", 2));
+    listHashtags.add(clusterStartUp.getKeyOnServer("lpop", 3));
+    return listHashtags;
+  }
+
+  private List<String> makeListKeys(List<String> listHashtags) {
+    List<String> keys = new ArrayList<>();
+    keys.add(makeListKeyWithHashtag(1, listHashtags.get(0)));
+    keys.add(makeListKeyWithHashtag(2, listHashtags.get(1)));
+    keys.add(makeListKeyWithHashtag(3, listHashtags.get(2)));
+    return keys;
+  }
+
+
+  private void lpushPerformAndVerify(String key, List<String> elementList) {
+    jedis.lpush(key, elementList.toArray(new String[] {}));
+
+    Long listLength = jedis.llen(key);
+    assertThat(listLength).isEqualTo(elementList.size())
+        .as("Initial list lengths not equal for key %s'", key);

Review comment:
       The `as()` needs to come after the `assertThat()` rather than the 
`isEqualTo()`. From the JavaDoc for `as()`:
   ```
      * Sets the description of the assertion that is going to be called after.
      * <p>
      * You must set it <b>before</b> calling the assertion otherwise it is 
ignored as the failing assertion breaks
      * the chained call by throwing an AssertionError.
   ```

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }

Review comment:
       It's not clear to me how this test is verifying that list elements are 
added atomically, since it doesn't verify the contents of the lists, just their 
lengths. We could have a situation where we do two LPUSH operations with 
elements `1, 1, 1` and `a, a, a`, and end up with a list `1, 1, a, a, a, 1` and 
the test wouldn't mind. Would it be possible to add validation that every three 
consecutive elements of the list correspond to one single LPUSH operation? To 
make it easier, you could push three identical but distinct elements each time, 
like the example I gave, then just check that every three list elements are 
equal to each other to make sure nothing got applied out of order.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }
+    assertThat(totalLength)
+        .isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * PUSHER_COUNT * 
PUSH_LIST_SIZE);
+    clusterStartUp.crashVM(1); // kill primary server, just in case test order 
is reversed
+  }
+
+  private void lpushPerformAndVerify(String key, List<String> elementList,
+      AtomicLong runningCount) {
+    for (int i = 0; i < MINIMUM_ITERATIONS; i++) {
+      long listLength = jedis.llen(key);
+      long newLength = jedis.lpush(key, elementList.toArray(new String[] {}));
+      assertThat((newLength - listLength) % 3).as("LPUSH, list length %s not 
multiple of 3",
+          newLength).isEqualTo(0);
+    }
+    runningCount.decrementAndGet();
+  }
+
+  @Test
+  public void shouldDistributeElementsAcrossCluster()

Review comment:
       This test would be better named something like 
"shouldNotLoseData_givenPrimaryServerCrashesDuringOperations" since that's what 
we're really trying to test here.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);

Review comment:
       See comment in `LPopDUnitTest` about using `Thread.sleep()` or asserting 
on something meaningful here.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPopDUnitTest.java
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPopDUnitTest {
+  public static final int MINIMUM_ITERATIONS = 10000;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @After
+  public void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldDistributeDataAmongCluster_andRetainDataAfterServerCrash() 
{
+    String key = makeListKeyWithHashtag(1, 
clusterStartUp.getKeyOnServer("lpop", 1));
+    List<String> elementList = makeElementList(key, MINIMUM_ITERATIONS);
+    lpushPerformAndVerify(key, elementList);
+
+    // Remove all but last element
+    for (int i = MINIMUM_ITERATIONS - 1; i > 0; i--) {
+      assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, i));
+    }
+    clusterStartUp.crashVM(1); // kill primary server
+
+    assertThat(jedis.lpop(key)).isEqualTo(makeElementString(key, 0));
+    assertThat(jedis.exists(key)).isFalse();
+  }
+
+  @Test
+  public void givenBucketsMoveDuringLpop_thenOperationsAreNotLost() throws 
Exception {
+    AtomicLong runningCount = new AtomicLong(3);
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+
+    List<String> elementList1 = makeElementList(keys.get(0), 
MINIMUM_ITERATIONS);
+    List<String> elementList2 = makeElementList(keys.get(1), 
MINIMUM_ITERATIONS);
+    List<String> elementList3 = makeElementList(keys.get(2), 
MINIMUM_ITERATIONS);

Review comment:
       The name `MINIMUM_ITERATIONS` is a bit misleading, since we actually add 
exactly that many elements to the list every time. It should probably be 
renamed to something like "INITIAL_LIST_SIZE" and any assertions on it using 
`.isGreaterThanOrEqualTo()` should be changed to `.isEqualTo()`

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }
+    assertThat(totalLength)
+        .isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * PUSHER_COUNT * 
PUSH_LIST_SIZE);
+    clusterStartUp.crashVM(1); // kill primary server, just in case test order 
is reversed
+  }
+
+  private void lpushPerformAndVerify(String key, List<String> elementList,
+      AtomicLong runningCount) {
+    for (int i = 0; i < MINIMUM_ITERATIONS; i++) {
+      long listLength = jedis.llen(key);
+      long newLength = jedis.lpush(key, elementList.toArray(new String[] {}));
+      assertThat((newLength - listLength) % 3).as("LPUSH, list length %s not 
multiple of 3",
+          newLength).isEqualTo(0);
+    }
+    runningCount.decrementAndGet();
+  }
+
+  @Test
+  public void shouldDistributeElementsAcrossCluster()
+      throws ExecutionException, InterruptedException {
+    final int pusherCount = 6;
+    final int pushListSize = 3;
+    AtomicLong runningCount = new AtomicLong(pusherCount);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(pushListSize, "element1-");
+    List<String> elements2 = makeElementList(pushListSize, "element2-");
+    List<String> elements3 = makeElementList(pushListSize, "element2-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    GeodeAwaitility.await().during(Duration.ofMillis(200)).until(() -> true);

Review comment:
       This await should be on something meaningful, such as the length of the 
lists in the test (making sure we've added some minimum number of elements, for 
example) as otherwise the test could become flaky.

##########
File path: 
geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/commands/executor/list/LPushDUnitTest.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.rules.RedisClusterStartupRule;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+
+public class LPushDUnitTest {
+  public static final int PUSHER_COUNT = 6;
+  public static final int PUSH_LIST_SIZE = 3;
+  private static MemberVM locator;
+
+  @ClassRule
+  public static RedisClusterStartupRule clusterStartUp = new 
RedisClusterStartupRule();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  private static final int MINIMUM_ITERATIONS = 10000;
+  private static JedisCluster jedis;
+
+  @BeforeClass
+  public static void classSetup() {
+    locator = clusterStartUp.startLocatorVM(0);
+    clusterStartUp.startRedisVM(2, locator.getPort());
+    clusterStartUp.startRedisVM(3, locator.getPort());
+  }
+
+  @Before
+  public void testSetup() {
+    clusterStartUp.startRedisVM(1, locator.getPort());
+    clusterStartUp.rebalanceAllRegions();
+    int redisServerPort = clusterStartUp.getRedisPort(1);
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, redisServerPort), 
REDIS_CLIENT_TIMEOUT);
+    clusterStartUp.flushAll();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    jedis.close();
+  }
+
+  @Test
+  public void shouldPushMultipleElementsAtomically()
+      throws ExecutionException, InterruptedException {
+    AtomicLong runningCount = new AtomicLong(PUSHER_COUNT);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(PUSH_LIST_SIZE, "element1-");
+    List<String> elements2 = makeElementList(PUSH_LIST_SIZE, "element2-");
+    List<String> elements3 = makeElementList(PUSH_LIST_SIZE, "element3-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    for (int i = 0; i < 50 && runningCount.get() > 0; i++) {
+      clusterStartUp.moveBucketForKey(listHashtags.get(i % 
listHashtags.size()));
+      GeodeAwaitility.await().during(Duration.ofMillis(500)).until(() -> true);
+    }
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    int totalLength = 0;
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
PUSH_LIST_SIZE);
+      totalLength += length;
+    }
+    assertThat(totalLength)
+        .isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * PUSHER_COUNT * 
PUSH_LIST_SIZE);
+    clusterStartUp.crashVM(1); // kill primary server, just in case test order 
is reversed
+  }
+
+  private void lpushPerformAndVerify(String key, List<String> elementList,
+      AtomicLong runningCount) {
+    for (int i = 0; i < MINIMUM_ITERATIONS; i++) {
+      long listLength = jedis.llen(key);
+      long newLength = jedis.lpush(key, elementList.toArray(new String[] {}));
+      assertThat((newLength - listLength) % 3).as("LPUSH, list length %s not 
multiple of 3",
+          newLength).isEqualTo(0);
+    }
+    runningCount.decrementAndGet();
+  }
+
+  @Test
+  public void shouldDistributeElementsAcrossCluster()
+      throws ExecutionException, InterruptedException {
+    final int pusherCount = 6;
+    final int pushListSize = 3;
+    AtomicLong runningCount = new AtomicLong(pusherCount);
+
+    List<String> listHashtags = makeListHashtags();
+    List<String> keys = makeListKeys(listHashtags);
+    List<String> elements1 = makeElementList(pushListSize, "element1-");
+    List<String> elements2 = makeElementList(pushListSize, "element2-");
+    List<String> elements3 = makeElementList(pushListSize, "element2-");
+
+    List<Runnable> taskList = new ArrayList<>();
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(0), elements1, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(1), elements2, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> lpushPerformAndVerify(keys.get(2), elements3, 
runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(0), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(1), runningCount));
+    taskList.add(() -> verifyListLengthCondition(keys.get(2), runningCount));
+
+    List<Future> futureList = new ArrayList<>();
+    for (Runnable task : taskList) {
+      futureList.add(executor.runAsync(task));
+    }
+
+    GeodeAwaitility.await().during(Duration.ofMillis(200)).until(() -> true);
+    clusterStartUp.crashVM(1); // kill primary server
+
+    for (Future future : futureList) {
+      future.get();
+    }
+
+    Long length;
+    for (String key : keys) {
+      length = jedis.llen(key);
+      assertThat(length).isGreaterThanOrEqualTo(MINIMUM_ITERATIONS * 2 * 
pushListSize);
+      assertThat(length % 3).isEqualTo(0);
+    }

Review comment:
       This test should also validate the contents of the lists in some way, to 
make sure we haven't added elements out of order or interleaved different LPUSH 
commands.




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