You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/04/24 11:45:31 UTC

[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2459: [KYUUBI #1936][FOLLOWUP] stop updating credentials when credentials are expired

turboFei commented on code in PR #2459:
URL: https://github.com/apache/incubator-kyuubi/pull/2459#discussion_r857112567


##########
kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HadoopCredentialsManagerSuite.scala:
##########
@@ -158,6 +158,49 @@ class HadoopCredentialsManagerSuite extends KyuubiFunSuite {
       eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
         assert(manager.userCredentialsRefMap.size == 0)
       }
+
+      // Wait for renewal task to stop
+      Thread.sleep(2000L)
+
+      // Check renewal schedule is stopped
+      assert(userRef.getEpoch >= 4)
+      val epoch = userRef.getEpoch
+      Thread.sleep(2000L)
+      assert(userRef.getEpoch == epoch)
+    }
+  }
+
+  test("stop old credential schedule when there is newer userRef in the map") {
+    val kyuubiConf = new KyuubiConf(false)
+      .set(KyuubiConf.CREDENTIALS_RENEWAL_INTERVAL, 1000L)
+      .set(KyuubiConf.CREDENTIALS_RENEWAL_RETRY_WAIT, 1000L)
+      .set(KyuubiConf.CREDENTIALS_CHECK_INTERVAL, 4000L)
+      .set(KyuubiConf.CREDENTIALS_IDLE_TIMEOUT, 5000L)
+
+    withStartedManager(kyuubiConf) { manager =>
+      // Trigger UserCredentialsRef's initialization
+      val userRef = manager.getOrCreateUserCredentialsRef(appUser)
+      assert(manager.userCredentialsRefMap.size == 1)
+
+      // Credentials are expired
+      eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
+        assert(manager.userCredentialsRefMap.size == 0)
+      }
+
+      // New userRef is created
+      val userRef_new = manager.getOrCreateUserCredentialsRef(appUser)

Review Comment:
   nit: userRef_new -> newUserRef



##########
kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HadoopCredentialsManagerSuite.scala:
##########
@@ -158,6 +158,49 @@ class HadoopCredentialsManagerSuite extends KyuubiFunSuite {
       eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
         assert(manager.userCredentialsRefMap.size == 0)
       }
+
+      // Wait for renewal task to stop
+      Thread.sleep(2000L)
+
+      // Check renewal schedule is stopped
+      assert(userRef.getEpoch >= 4)
+      val epoch = userRef.getEpoch
+      Thread.sleep(2000L)
+      assert(userRef.getEpoch == epoch)
+    }
+  }
+
+  test("stop old credential schedule when there is newer userRef in the map") {
+    val kyuubiConf = new KyuubiConf(false)
+      .set(KyuubiConf.CREDENTIALS_RENEWAL_INTERVAL, 1000L)
+      .set(KyuubiConf.CREDENTIALS_RENEWAL_RETRY_WAIT, 1000L)
+      .set(KyuubiConf.CREDENTIALS_CHECK_INTERVAL, 4000L)
+      .set(KyuubiConf.CREDENTIALS_IDLE_TIMEOUT, 5000L)
+
+    withStartedManager(kyuubiConf) { manager =>
+      // Trigger UserCredentialsRef's initialization
+      val userRef = manager.getOrCreateUserCredentialsRef(appUser)
+      assert(manager.userCredentialsRefMap.size == 1)
+
+      // Credentials are expired
+      eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
+        assert(manager.userCredentialsRefMap.size == 0)
+      }
+
+      // New userRef is created
+      val userRef_new = manager.getOrCreateUserCredentialsRef(appUser)
+      assert(manager.userCredentialsRefMap.size == 1)

Review Comment:
   I think you can move this part into original UT.



##########
kyuubi-server/src/test/scala/org/apache/kyuubi/credentials/HadoopCredentialsManagerSuite.scala:
##########
@@ -158,6 +158,49 @@ class HadoopCredentialsManagerSuite extends KyuubiFunSuite {
       eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
         assert(manager.userCredentialsRefMap.size == 0)

Review Comment:
   nit:
   ```    
     eventually(timeout(9000.milliseconds), interval(100.milliseconds)) {
           assert(manager.userCredentialsRefMap.size == 0)
           val epoch = userRef.getEpoch
           Thread.sleep(2000L)
           assert(userRef.getEpoch == epoch)
     }
   ```



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org