sabbey37 commented on a change in pull request #6493:
URL: https://github.com/apache/geode/pull/6493#discussion_r638013925



##########
File path: 
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/pubsub/AbstractSubCommandsIntegrationTest.java
##########
@@ -0,0 +1,156 @@
+
+/*
+ * 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.executor.pubsub;
+
+import static 
org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+import static 
org.apache.geode.redis.internal.executor.pubsub.SubCommandExecutor.UNKNOWN_SUBCOMMAND_ERROR_BASE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.RedisIntegrationTest;
+import org.apache.geode.redis.mocks.MockSubscriber;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+
+public abstract class AbstractSubCommandsIntegrationTest implements 
RedisIntegrationTest {
+  private Jedis subscriber;
+  private Jedis introspector;
+  private MockSubscriber mockSubscriber;
+
+  @Before
+  public void setup() {
+    mockSubscriber = new MockSubscriber();
+    subscriber = new Jedis("localhost", getPort());
+    introspector = new Jedis("localhost", getPort());
+  }
+
+  @After
+  public void teardown() {
+    if (mockSubscriber.getSubscribedChannels() > 0) {
+      mockSubscriber.unsubscribe();
+    }
+    waitFor(() -> mockSubscriber.getSubscribedChannels() == 0);

Review comment:
       In that case, it might make more sense to unsubscribe and wait for there 
to no longer be any subscribed channels in each test rather than in the 
after... since we're doing something slightly different for each one (some have 
multiple mockSubscribers).  
   
   Yeah, I think it's ok to not waitFor subscriber thread to no longer be 
alive.  Wasn't sure if we added it at some point due to PubSub flakiness, but 
it seems that thread dies once there are no longer any subscribers so we should 
be ok just waiting for that condition.




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


Reply via email to