You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/09/01 10:22:49 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3208] Fix Flaky Test - MetadataManagerSuite: metadata request metrics

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

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new a61aa8e59 [KYUUBI #3208] Fix Flaky Test - MetadataManagerSuite: metadata request metrics
a61aa8e59 is described below

commit a61aa8e592635ad7525b03fcd2e007606b4766a9
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Thu Sep 1 18:22:40 2022 +0800

    [KYUUBI #3208] Fix Flaky Test - MetadataManagerSuite: metadata request metrics
    
    ### _Why are the changes needed?_
    
    Close #3208
    Fix flaky test:
    ```
    MetadataManagerSuite:
    - metadata request metrics *** FAILED ***
      2 did not equal 1 (MetadataManagerSuite.scala:141)
    ```
    
    Cleanup the retrying metadata to prevent flaky test.
    ### _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
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3331 from turboFei/flaky_test.
    
    Closes #3208
    
    5b16a9a2 [Fei Wang] use eventually
    9cb8edb8 [Fei Wang] save
    
    Authored-by: Fei Wang <fw...@ebay.com>
    Signed-off-by: Fei Wang <fw...@ebay.com>
---
 .../scala/org/apache/kyuubi/server/metadata/MetadataManager.scala | 6 ++++--
 .../org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala  | 8 ++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
index 4409eba31..6b11d2a3a 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala
@@ -36,10 +36,12 @@ class MetadataManager extends AbstractService("MetadataManager") {
 
   private var _metadataStore: MetadataStore = _
 
-  private val identifierRequestsRetryRefs =
+  // Visible for testing.
+  private[metadata] val identifierRequestsRetryRefs =
     new ConcurrentHashMap[String, MetadataRequestsRetryRef]()
 
-  private val identifierRequestsRetryingCounts =
+  // Visible for testing.
+  private[metadata] val identifierRequestsRetryingCounts =
     new ConcurrentHashMap[String, AtomicInteger]()
 
   private val requestsRetryTrigger =
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
index 7c0285432..a7c7372b6 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/metadata/MetadataManagerSuite.scala
@@ -19,6 +19,8 @@ package org.apache.kyuubi.server.metadata
 
 import java.util.UUID
 
+import scala.collection.JavaConverters._
+
 import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiException, KyuubiFunSuite}
@@ -96,6 +98,12 @@ class MetadataManagerSuite extends KyuubiFunSuite {
       assert(!retryRef2.hasRemainingRequests())
       assert(metadataManager.getBatch(metadata2.identifier).getState === "RUNNING")
     }
+
+    metadataManager.identifierRequestsRetryRefs.clear()
+    eventually(timeout(3.seconds)) {
+      metadataManager.identifierRequestsRetryingCounts.asScala.forall(_._2.get() == 0)
+    }
+    metadataManager.identifierRequestsRetryingCounts.clear()
   }
 
   test("metadata request metrics") {