From e386b1300338450ec0d45d154a73b0cf8dce0bf5 Mon Sep 17 00:00:00 2001 From: ulysses-you Date: Tue, 1 Jun 2021 08:44:27 +0800 Subject: [PATCH] [KYUUBI #653] Fix flaky test in ctl module ### _Why are the changes needed?_ As `zookeeper` mentioned, the result of getChildren is no guarantee order. So it is also no guarantee order that use exists children to create new node . flaky test log: ``` - test expose zk service node to another namespace *** FAILED *** "...ceUri=localhost:1000[1];version=1.2.0;seque..." did not equal "...ceUri=localhost:1000[0];version=1.2.0;seque..." (ServiceControlCliSuite.scala:212) Analysis: "...ceUri=localhost:1000[1];version=1.2.0;seque..." -> "...ceUri=localhost:1000[0];version=1.2.0;seque..." ``` zookeeper description: ``` /** * For the given znode path return the stat and children list. *

* If the watch is true and the call is successful (no exception is thrown), * a watch will be left on the node with the given path. The watch will be * triggered by a successful operation that deletes the node of the given * path or creates/delete a child under the node. *

* The list of children returned is not sorted and no guarantee is provided * as to its natural or lexical order. *

* A KeeperException with error code KeeperException.NoNode will be thrown * if no node with the given path exists. * * since 3.3.0 * * param path * param watch * param stat stat of the znode designated by path * return an unordered array of children of the node with the given path * throws InterruptedException If the server transaction is interrupted. * throws KeeperException If the server signals an error with a non-zero * error code. */ public List getChildren(String path, boolean watch, Stat stat) throws KeeperException, InterruptedException { return getChildren(path, watch ? watchManager.defaultWatcher : null, stat); } ``` ### _How was this patch tested?_ Pass CI. Closes #653 from ulysses-you/flaky-test-ctl. Closes #653 0be8248a [ulysses-you] fix Authored-by: ulysses-you Signed-off-by: fwang12 (cherry picked from commit 55df6457b6d7c87c1913d877b44149f1db149aa6) Signed-off-by: ulysses-you --- .../apache/kyuubi/ctl/ServiceControlCliSuite.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala index 447f022e037..9a1f8cdf6d2 100644 --- a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala +++ b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala @@ -203,12 +203,13 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit { testPrematureExit(args, getRenderedNodesInfoWithoutTitle(expectedCreatedNodes)) val znodeRoot = s"/$newNamespace" - val children = framework.getChildren.forPath(znodeRoot).asScala + val children = framework.getChildren.forPath(znodeRoot).asScala.sorted assert(children.size == 2) - assert(children.head === - s"serviceUri=localhost:10000;version=$KYUUBI_VERSION;sequence=0000000000") - assert(children.last === - s"serviceUri=localhost:10001;version=$KYUUBI_VERSION;sequence=0000000001") + + assert(children.head.startsWith( + s"serviceUri=localhost:10000;version=$KYUUBI_VERSION;sequence=")) + assert(children.last.startsWith( + s"serviceUri=localhost:10001;version=$KYUUBI_VERSION;sequence=")) children.foreach { child => framework.delete().forPath(s"""$znodeRoot/$child""") }