You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/03/08 02:00:22 UTC

[kyuubi] branch branch-1.7 updated: [KYUUBI #4451] Skip etcd test if no docker env

This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new e6e945595 [KYUUBI #4451] Skip etcd test if no docker env
e6e945595 is described below

commit e6e9455956b460dfb020ce93a2bb90282a7661e8
Author: ulysses-you <ul...@gmail.com>
AuthorDate: Wed Mar 8 09:57:12 2023 +0800

    [KYUUBI #4451] Skip etcd test if no docker env
    
    ### _Why are the changes needed?_
    
    Skip etcd test if no docker env.
    
    It would fail if no docker env
    ```
    org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClientSuite *** ABORTED ***
      java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
      at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$6(DockerClientProviderStrategy.java:257)
      at java.util.Optional.orElseThrow(Optional.java:290)
      at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:247)
      at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:135)
      at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:171)
      at org.testcontainers.containers.Network$NetworkImpl.create(Network.java:69)
      at org.testcontainers.containers.Network$NetworkImpl.getId(Network.java:62)
      at io.etcd.jetcd.launcher.EtcdClusterImpl.start(EtcdClusterImpl.java:72)
      at org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClientSuite.beforeAll(EtcdDiscoveryClientSuite.scala:48)
    ```
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4451 from ulysses-you/skip-etcd.
    
    Closes #4451
    
    a5e65adb4 [ulysses-you] isDockerAvailable
    39baad662 [ulysses-you] Skip etcd test is no docker env
    
    Authored-by: ulysses-you <ul...@gmail.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
    (cherry picked from commit 86f7537a8e2203dd39e9b634cc6cc95dbd3ff326)
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .../ha/client/etcd/EtcdDiscoveryClientSuite.scala  | 32 ++++++++++++++++------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/kyuubi-ha/src/test/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClientSuite.scala b/kyuubi-ha/src/test/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClientSuite.scala
index 5b8855c1e..de48a3495 100644
--- a/kyuubi-ha/src/test/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClientSuite.scala
+++ b/kyuubi-ha/src/test/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClientSuite.scala
@@ -22,6 +22,9 @@ import java.nio.charset.StandardCharsets
 import scala.collection.JavaConverters._
 
 import io.etcd.jetcd.launcher.{Etcd, EtcdCluster}
+import org.scalactic.source.Position
+import org.scalatest.Tag
+import org.testcontainers.DockerClientFactory
 
 import org.apache.kyuubi.config.KyuubiConf
 import org.apache.kyuubi.ha.HighAvailabilityConf.{HA_ADDRESSES, HA_CLIENT_CLASS}
@@ -41,25 +44,38 @@ class EtcdDiscoveryClientSuite extends DiscoveryClientTests {
   var conf: KyuubiConf = KyuubiConf()
     .set(HA_CLIENT_CLASS, classOf[EtcdDiscoveryClient].getName)
 
+  private val hasDockerEnv = DockerClientFactory.instance().isDockerAvailable
+
   override def beforeAll(): Unit = {
-    etcdCluster = new Etcd.Builder()
-      .withNodes(2)
-      .build()
-    etcdCluster.start()
-    conf = new KyuubiConf()
-      .set(HA_CLIENT_CLASS, classOf[EtcdDiscoveryClient].getName)
-      .set(HA_ADDRESSES, getConnectString)
+    if (hasDockerEnv) {
+      etcdCluster = new Etcd.Builder()
+        .withNodes(2)
+        .build()
+      etcdCluster.start()
+      conf = new KyuubiConf()
+        .set(HA_CLIENT_CLASS, classOf[EtcdDiscoveryClient].getName)
+        .set(HA_ADDRESSES, getConnectString)
+    }
     super.beforeAll()
   }
 
   override def afterAll(): Unit = {
     super.afterAll()
-    if (etcdCluster != null) {
+    if (hasDockerEnv && etcdCluster != null) {
       etcdCluster.close()
       etcdCluster = null
     }
   }
 
+  override protected def test(
+      testName: String,
+      testTags: Tag*)(testFun: => Any)(implicit pos: Position): Unit = {
+    if (hasDockerEnv) {
+      super.test(testName, testTags: _*)(testFun)
+    }
+    // skip test
+  }
+
   test("etcd test: set, get and delete") {
     withDiscoveryClient(conf) { discoveryClient =>
       val path = "/kyuubi"