Skip to content

Commit

Permalink
support to refersh unlimited users
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Feb 17, 2023
1 parent 777c311 commit 86440b5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ object AdminCommandLine extends CommonCommandLine {
.optional()
.action((v, c) => c.copy(adminConfigOpts = c.adminConfigOpts.copy(configType = v)))
.text("The valid config type can be one of the following: " +
s"$HADOOP_CONF, $USER_DEFAULTS_CONF."))
s"$HADOOP_CONF, $USER_DEFAULTS_CONF, $UNLIMITED_USERS."))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.kyuubi.ctl

import org.apache.kyuubi.{KYUUBI_VERSION, KyuubiFunSuite}
import org.apache.kyuubi.ctl.cli.AdminControlCliArguments
import org.apache.kyuubi.ctl.cmd.refresh.RefreshConfigCommandConfigType
import org.apache.kyuubi.ctl.cmd.refresh.RefreshConfigCommandConfigType._
import org.apache.kyuubi.ctl.opt.{ControlAction, ControlObject}

Expand Down Expand Up @@ -63,7 +64,8 @@ class AdminControlCliArgumentsSuite extends KyuubiFunSuite with TestPrematureExi
val opArgs = new AdminControlCliArguments(args)
assert(opArgs.cliConfig.action === ControlAction.REFRESH)
assert(opArgs.cliConfig.resource === ControlObject.CONFIG)
assert(opArgs.cliConfig.adminConfigOpts.configType === "hadoopConf")
assert(
opArgs.cliConfig.adminConfigOpts.configType === RefreshConfigCommandConfigType.HADOOP_CONF)

args = Array(
"refresh",
Expand All @@ -72,7 +74,16 @@ class AdminControlCliArgumentsSuite extends KyuubiFunSuite with TestPrematureExi
val opArgs2 = new AdminControlCliArguments(args)
assert(opArgs2.cliConfig.action === ControlAction.REFRESH)
assert(opArgs2.cliConfig.resource === ControlObject.CONFIG)
assert(opArgs2.cliConfig.adminConfigOpts.configType === "userDefaultsConf")
assert(opArgs2.cliConfig.adminConfigOpts.configType === RefreshConfigCommandConfigType.USER_DEFAULTS_CONF)

args = Array(
"refresh",
"config",
"unlimitedUsers")
val opArgs3 = new AdminControlCliArguments(args)
assert(opArgs3.cliConfig.action === ControlAction.REFRESH)
assert(opArgs3.cliConfig.resource === ControlObject.CONFIG)
assert(opArgs3.cliConfig.adminConfigOpts.configType === RefreshConfigCommandConfigType.UNLIMITED_USERS)

args = Array(
"refresh",
Expand Down Expand Up @@ -147,7 +158,7 @@ class AdminControlCliArgumentsSuite extends KyuubiFunSuite with TestPrematureExi
| Refresh the resource.
|Command: refresh config [<configType>]
| Refresh the config with specified type.
| <configType> The valid config type can be one of the following: $HADOOP_CONF, $USER_DEFAULTS_CONF.
| <configType> The valid config type can be one of the following: $HADOOP_CONF, $USER_DEFAULTS_CONF, $UNLIMITED_USERS.
|
| -h, --help Show help message and exit.""".stripMargin
// scalastyle:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ class AdminResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(200 == response.getStatus)
}

test("refresh unlimited users the kyuubi server") {
var response = webTarget.path("api/v1/admin/refresh/unlimited_users")
.request()
.post(null)
assert(405 == response.getStatus)

val adminUser = Utils.currentUser
val encodeAuthorization = new String(
Base64.getEncoder.encode(
s"$adminUser:".getBytes()),
"UTF-8")
response = webTarget.path("api/v1/admin/refresh/unlimited_users")
.request()
.header(AUTHORIZATION_HEADER, s"BASIC $encodeAuthorization")
.post(null)
assert(200 == response.getStatus)
}

test("delete engine - user share level") {
val id = UUID.randomUUID().toString
conf.set(KyuubiConf.ENGINE_SHARE_LEVEL, USER.toString)
Expand Down

0 comments on commit 86440b5

Please sign in to comment.