You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/12/03 18:34:07 UTC

[GitHub] [geode] Kris-10-0 opened a new pull request #7164: GEODE-9831: support SISMEMBER support command

Kris-10-0 opened a new pull request #7164:
URL: https://github.com/apache/geode/pull/7164


   <!-- Thank you for submitting a contribution to Apache Geode. -->
   
   <!-- In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken: 
   -->
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   - [x] Does `gradlew build` run cleanly?
   
   - [x] Have you written or updated unit tests to verify your changes?
   
   - [NA] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   <!-- Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   -->
   


-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] DonalEvans commented on a change in pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #7164:
URL: https://github.com/apache/geode/pull/7164#discussion_r762167146



##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java
##########
@@ -49,42 +50,81 @@ public void tearDown() {
   }
 
   @Test
-  public void errors_givenWrongNumberOfArguments() {
+  public void sismemberWrongNumberOfArguments_returnsError() {
     assertExactNumberOfArgs(jedis, Protocol.Command.SISMEMBER, 2);
   }
 
   @Test
-  public void testSMembersSIsMember() {
-    int elements = 10;
-    String key = generator.generate('x');
-    String[] strings = generateStrings(elements, 'y');
-    jedis.sadd(key, strings);
-
-    for (String entry : strings) {
-      assertThat(jedis.sismember(key, entry)).isTrue();
+  public void sismemberValidKeyValidMember_returnTrue() {
+    jedis.sadd(setKey, setMembers);
+
+    for (String member : setMembers) {
+      assertThat(jedis.sismember(setKey, member)).isTrue();
     }
   }
 
   @Test
-  public void testSIsMemberWithNonexistentKey_returnsFalse() {
+  public void sismemberValidKeyNonExistingMember_returnFalse() {
+    jedis.sadd(setKey, setMembers);
+    assertThat(jedis.sismember(setKey, "nonExistentMember")).isFalse();
+  }
+
+  @Test
+  public void sismemberNonExistingKeyNonExistingMember_returnFalse() {
     assertThat(jedis.sismember("nonExistentKey", "nonExistentMember")).isFalse();
   }
 
   @Test
-  public void testSIsMemberWithNonexistentMember_returnsFalse() {
-    String key = "key";
+  public void sismemberMemberInAnotherSet_returnFalse() {
+    String member = "elephant";
+    jedis.sadd("diffSet", member);
+    jedis.sadd(setKey, setMembers);
 
-    jedis.sadd("key", "member1", "member2");
-    assertThat(jedis.sismember(key, "nonExistentMember")).isFalse();
+    assertThat(jedis.sismember(setKey, member)).isFalse();
   }
 
-  private String[] generateStrings(int elements, char uniqueElement) {
-    Set<String> strings = new HashSet<>();
-    for (int i = 0; i < elements; i++) {
-      String elem = generator.generate(uniqueElement);
-      strings.add(elem);
+  @Test
+  public void sismemberNonExistingKeyAndMemberInAnotherSet_returnFalse() {
+    jedis.sadd(setKey, setMembers);
+
+    for (String member : setMembers) {
+      assertThat(jedis.sismember("nonExistentKey", member)).isFalse();
     }
-    return strings.toArray(new String[strings.size()]);
   }
 
+
+  @Test
+  public void sismemberAfterSadd_returnsTruee() {

Review comment:
       Typo here, should be "True"

##########
File path: geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSIsMemberIntegrationTest.java
##########
@@ -49,42 +50,81 @@ public void tearDown() {
   }
 
   @Test
-  public void errors_givenWrongNumberOfArguments() {
+  public void sismemberWrongNumberOfArguments_returnsError() {
     assertExactNumberOfArgs(jedis, Protocol.Command.SISMEMBER, 2);
   }
 
   @Test
-  public void testSMembersSIsMember() {
-    int elements = 10;
-    String key = generator.generate('x');
-    String[] strings = generateStrings(elements, 'y');
-    jedis.sadd(key, strings);
-
-    for (String entry : strings) {
-      assertThat(jedis.sismember(key, entry)).isTrue();
+  public void sismemberValidKeyValidMember_returnTrue() {
+    jedis.sadd(setKey, setMembers);
+
+    for (String member : setMembers) {
+      assertThat(jedis.sismember(setKey, member)).isTrue();
     }
   }
 
   @Test
-  public void testSIsMemberWithNonexistentKey_returnsFalse() {
+  public void sismemberValidKeyNonExistingMember_returnFalse() {
+    jedis.sadd(setKey, setMembers);
+    assertThat(jedis.sismember(setKey, "nonExistentMember")).isFalse();
+  }
+
+  @Test
+  public void sismemberNonExistingKeyNonExistingMember_returnFalse() {
     assertThat(jedis.sismember("nonExistentKey", "nonExistentMember")).isFalse();
   }
 
   @Test
-  public void testSIsMemberWithNonexistentMember_returnsFalse() {
-    String key = "key";
+  public void sismemberMemberInAnotherSet_returnFalse() {
+    String member = "elephant";
+    jedis.sadd("diffSet", member);
+    jedis.sadd(setKey, setMembers);
 
-    jedis.sadd("key", "member1", "member2");
-    assertThat(jedis.sismember(key, "nonExistentMember")).isFalse();
+    assertThat(jedis.sismember(setKey, member)).isFalse();
   }
 
-  private String[] generateStrings(int elements, char uniqueElement) {
-    Set<String> strings = new HashSet<>();
-    for (int i = 0; i < elements; i++) {
-      String elem = generator.generate(uniqueElement);
-      strings.add(elem);
+  @Test
+  public void sismemberNonExistingKeyAndMemberInAnotherSet_returnFalse() {
+    jedis.sadd(setKey, setMembers);
+
+    for (String member : setMembers) {
+      assertThat(jedis.sismember("nonExistentKey", member)).isFalse();
     }
-    return strings.toArray(new String[strings.size()]);
   }
 
+
+  @Test
+  public void sismemberAfterSadd_returnsTruee() {
+    String newMember = "chicken";
+    jedis.sadd(setKey, setMembers);
+    assertThat(jedis.sismember(setKey, newMember)).isFalse();
+    jedis.sadd(setKey, newMember);
+    assertThat(jedis.sismember(setKey, newMember)).isTrue();
+  }
+
+  @Test
+  public void sismemberWithConcurrentSAdd_returnsCorrectValue() {

Review comment:
       For this specific command a concurrent test doesn't really make sense, since we're asserting that SISMEMBER either returns true or it returns false depending on whether it's called before or after the SADD. However, since there's nothing else that the command could return, we have no way of detecting a concurrency issue, since one of those assertions will always be correct. For this reason, I think it makes sense to just remove this test case.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] jdeppe-pivotal merged pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
jdeppe-pivotal merged pull request #7164:
URL: https://github.com/apache/geode/pull/7164


   


-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] kirklund commented on a change in pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
kirklund commented on a change in pull request #7164:
URL: https://github.com/apache/geode/pull/7164#discussion_r764271330



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/commands/RedisCommandType.java
##########
@@ -242,6 +242,7 @@
   SADD(new SAddExecutor(), SUPPORTED, new Parameter().min(3).flags(WRITE, DENYOOM, FAST)),
   SDIFF(new SDiffExecutor(), SUPPORTED,
       new Parameter().min(2).lastKey(-1).flags(READONLY, SORT_FOR_SCRIPT)),
+  SISMEMBER(new SIsMemberExecutor(), SUPPORTED, new Parameter().exact(3).flags(READONLY, FAST)),

Review comment:
       I'd recommend writing a simple unit test for RedisCommandType. It would just confirm that SISMEMBER is supported and maybe has an SIsMemberExecutor and 3 parameters including the READONLY and FAST flags.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] dschneider-pivotal commented on a change in pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #7164:
URL: https://github.com/apache/geode/pull/7164#discussion_r762166223



##########
File path: geode-docs/tools_modules/geode_for_redis.html.md.erb
##########
@@ -112,6 +112,7 @@ If the server is functioning properly, you should see a response of `PONG`.
  - RENAME <br/>
  - SADD <br/>
  - SDIFF <br/>
+ - SISMEMBERS <br/>

Review comment:
       this should be SISMEMBER; somehow an S was added to the end




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] Kris-10-0 commented on a change in pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
Kris-10-0 commented on a change in pull request #7164:
URL: https://github.com/apache/geode/pull/7164#discussion_r762167463



##########
File path: geode-docs/tools_modules/geode_for_redis.html.md.erb
##########
@@ -112,6 +112,7 @@ If the server is functioning properly, you should see a response of `PONG`.
  - RENAME <br/>
  - SADD <br/>
  - SDIFF <br/>
+ - SISMEMBERS <br/>

Review comment:
       ```suggestion
    - SISMEMBER <br/>
   ```




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] DonalEvans commented on a change in pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #7164:
URL: https://github.com/apache/geode/pull/7164#discussion_r764280361



##########
File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/commands/RedisCommandType.java
##########
@@ -242,6 +242,7 @@
   SADD(new SAddExecutor(), SUPPORTED, new Parameter().min(3).flags(WRITE, DENYOOM, FAST)),
   SDIFF(new SDiffExecutor(), SUPPORTED,
       new Parameter().min(2).lastKey(-1).flags(READONLY, SORT_FOR_SCRIPT)),
+  SISMEMBER(new SIsMemberExecutor(), SUPPORTED, new Parameter().exact(3).flags(READONLY, FAST)),

Review comment:
       The correctness of the RedisCommandType flags is tested and validated against native Redis in `CommandIntegrationTest`, and the parameters are tested in the `sismemberWrongNumberOfArguments_returnsError` test in `AbstractSIsMemberIntegrationTest`, so we have comprehensive coverage of this code.




-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] Kris-10-0 commented on pull request #7164: GEODE-9831: support SISMEMBER support command

Posted by GitBox <gi...@apache.org>.
Kris-10-0 commented on pull request #7164:
URL: https://github.com/apache/geode/pull/7164#issuecomment-985783777


   I accidentally forced push my new commit, but the changes on the commit were to fix a typo and remove the concurrency test. There was no modification on the ordering of the commits.


-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org