anmolnar commented on a change in pull request #929: ZOOKEEPER-3361: Add multi 
version of getChildren request
URL: https://github.com/apache/zookeeper/pull/929#discussion_r281148025
 
 

 ##########
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/test/MultiTransactionTest.java
 ##########
 @@ -787,6 +811,129 @@ public void testTransactionBuilder() throws Exception {
         assertNull(zk.exists("/t2", false));
     }
 
+    @Test
+    public void testMultiGetChildren() throws Exception {
+        List<String> topLevelNodes = new ArrayList<String>();
+        Map<String, List<String>> childrenNodes = new HashMap<String, 
List<String>>();
+        // Creating a database where '/fooX' nodes has 'barXY' named children.
+        for (int i = 0; i < 10; i++) {
+            String name = "/foo" + i;
+            zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+            topLevelNodes.add(name);
+            childrenNodes.put(name, new ArrayList<>());
+            for (int j = 0; j < 10; j++) {
+                String childname = name + "/bar" + i + j;
+                String childname_s = "bar" + i + j;
+                zk.create(childname, childname.getBytes(), Ids.OPEN_ACL_UNSAFE,
+                        CreateMode.EPHEMERAL);
+                childrenNodes.get(name).add(childname_s);
+            }
+        }
+        // Create a multi operation, which queries the children of the nodes 
in topLevelNodes.
+        List<OpResult> multiChildrenList =
+                multi(zk, 
topLevelNodes.stream().map(Op::getChildren).collect(Collectors.toList()));
+        for (int i = 0; i < topLevelNodes.size(); i++) {
+            String nodeName = topLevelNodes.get(i);
+            Assert.assertTrue(multiChildrenList.get(i) instanceof 
OpResult.GetChildrenResult);
+            List<String> childrenList = ((OpResult.GetChildrenResult) 
multiChildrenList.get(i)).getChildren();
+            // In general, we do not demand an order from the children list 
but to contain every child.
+            Assert.assertEquals(new TreeSet<String>(childrenList),
+                    new TreeSet<String>(childrenNodes.get(nodeName)));
+
+            List<String> children = zk.getChildren(nodeName, false);
+            Assert.assertEquals(childrenList, children);
+        }
+
+        // Check for getting the children of the same node twice
+        List<OpResult> sameChildrenList = multi(zk, Arrays.asList(
+                Op.getChildren(topLevelNodes.get(0)),
+                Op.getChildren(topLevelNodes.get(0))));
+
+        Assert.assertEquals(sameChildrenList.size(), 2);
+        Assert.assertEquals(sameChildrenList.get(0), multiChildrenList.get(0));
+        Assert.assertEquals(sameChildrenList.get(0), sameChildrenList.get(1));
+    }
+
+    @Test
+    public void testMultiGetChildrenAuthentication() throws KeeperException, 
InterruptedException {
 
 Review comment:
   Same here. It would be nice to have 3 (or more) separate test cases.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to