You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "xyuanlu (via GitHub)" <gi...@apache.org> on 2023/06/06 00:00:40 UTC

[GitHub] [helix] xyuanlu commented on a diff in pull request #2523: [helix/metaclient] ZkMetaClient Stress Tests (Part 2)

xyuanlu commented on code in PR #2523:
URL: https://github.com/apache/helix/pull/2523#discussion_r1218723399


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestStressZkClient.java:
##########
@@ -369,4 +383,47 @@ public void handleDataChange(String key, Object data, ChangeType changeType) {
     _zkMetaClient.recursiveDelete(zkParentKey);
     Assert.assertEquals(_zkMetaClient.countDirectChildren(zkParentKey), 0);
   }
+
+  @Test
+  public void testTransactionOps() {
+    String zkParentKey = "/stressZk_testTransactionOp";
+    _zkMetaClient.create(zkParentKey, "parent_node");
+
+    // Transaction Create
+    List<Op> ops = new ArrayList<>();
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      ops.add(Op.create(zkParentKey + "/" + i, new byte[0], PERSISTENT));
+    }
+    List<OpResult> opResults = _zkMetaClient.transactionOP(ops);
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      Assert.assertTrue(opResults.get(i) instanceof OpResult.CreateResult);
+    }
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      Assert.assertNotNull(_zkMetaClient.exists(zkParentKey + "/" + i));
+    }
+
+    // Transaction Set
+    List<Op> ops_set = new ArrayList<>();
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      ops_set.add(Op.set(zkParentKey + "/" + i, new byte[0], -1));
+    }
+    List<OpResult> opsResultSet = _zkMetaClient.transactionOP(ops_set);
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      Assert.assertTrue(opsResultSet.get(i) instanceof OpResult.SetDataResult);
+    }
+
+    // Transaction Delete
+    List<Op> ops_delete = new ArrayList<>();
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      ops_delete.add(Op.delete(zkParentKey + "/" + i, -1));
+    }
+    List<OpResult> opsResultDelete = _zkMetaClient.transactionOP(ops_delete);
+    for (int i = 0; i < TEST_ITERATION_COUNT; i++) {
+      Assert.assertTrue(opsResultDelete.get(i) instanceof OpResult.DeleteResult);
+    }

Review Comment:
   Do we have any negative test?



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org