chia7712 commented on code in PR #16858:
URL: https://github.com/apache/kafka/pull/16858#discussion_r1720991269
##########
core/src/test/scala/integration/kafka/api/SaslSslAdminIntegrationTest.scala:
##########
@@ -519,6 +523,49 @@ class SaslSslAdminIntegrationTest extends
BaseAdminIntegrationTest with SaslSetu
}
}
+ @ParameterizedTest
+ @ValueSource(strings = Array("zk", "kraft"))
+ def testExpireDelegationToken(quorum: String): Unit = {
+ client = createAdminClient
+ val createDelegationTokenOptions = new CreateDelegationTokenOptions()
+
+ // Test expiration for non-exists token
+ TestUtils.assertFutureExceptionTypeEquals(
+ client.expireDelegationToken("".getBytes()).expiryTimestamp(),
+ classOf[DelegationTokenNotFoundException]
+ )
+
+ // Test expiring the token immediately
+ val token1 =
client.createDelegationToken(createDelegationTokenOptions).delegationToken().get()
+ val expireTokeOptions = new ExpireDelegationTokenOptions()
+ // wait for broker sync
+ Thread.sleep(500)
Review Comment:
Could you please add `waitUntilTrue` ?
##########
core/src/test/scala/integration/kafka/api/SaslSslAdminIntegrationTest.scala:
##########
@@ -519,6 +523,49 @@ class SaslSslAdminIntegrationTest extends
BaseAdminIntegrationTest with SaslSetu
}
}
+ @ParameterizedTest
+ @ValueSource(strings = Array("zk", "kraft"))
+ def testExpireDelegationToken(quorum: String): Unit = {
+ client = createAdminClient
+ val createDelegationTokenOptions = new CreateDelegationTokenOptions()
+
+ // Test expiration for non-exists token
+ TestUtils.assertFutureExceptionTypeEquals(
+ client.expireDelegationToken("".getBytes()).expiryTimestamp(),
+ classOf[DelegationTokenNotFoundException]
+ )
+
+ // Test expiring the token immediately
+ val token1 =
client.createDelegationToken(createDelegationTokenOptions).delegationToken().get()
+ val expireTokeOptions = new ExpireDelegationTokenOptions()
+ // wait for broker sync
+ Thread.sleep(500)
+ val token1ExpireTime = assertDoesNotThrow(() =>
client.expireDelegationToken(
+ token1.hmac(),
+ expireTokeOptions.expiryTimePeriodMs(-1)).expiryTimestamp().get()
+ )
+ assertTrue(token1ExpireTime < System.currentTimeMillis())
+
+ // Test expiring the expired token
+ val token2 =
client.createDelegationToken(createDelegationTokenOptions).delegationToken().get()
+ // Ensure current time > maxLifeTimeMs of token
+ Thread.sleep(5000)
Review Comment:
This sleep time is too large. Could you please create a token with small
`maxLifeTimeMs` instead?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]