You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ul...@apache.org on 2021/07/21 04:14:20 UTC
[incubator-kyuubi] branch branch-1.2 updated: [KYUUBI #839]Fix load
user specific defaults from properties file
This is an automated email from the ASF dual-hosted git repository.
ulyssesyou pushed a commit to branch branch-1.2
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/branch-1.2 by this push:
new e0b8495 [KYUUBI #839]Fix load user specific defaults from properties file
e0b8495 is described below
commit e0b8495de051a299683dc3aaf33fbd06df6080be
Author: hongdongdong <ho...@cmss.chinamobile.com>
AuthorDate: Wed Jul 21 12:13:46 2021 +0800
[KYUUBI #839]Fix load user specific defaults from properties file
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
loadFromMap ignored user specific defaults that start with '___'.
### _How was this patch tested?_
- [X] 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/latest/tools/testing.html#running-tests) locally before make a pull request
Closes #840 from hddong/kyuubi-839.
Closes #839
ba3683e3 [hongdongdong] fix comments
a7753849 [hongdongdong] fix test
07f82667 [hongdongdong] fix test
b2a4c3cb [hongdongdong] [KYUUBI#839]Fix load user specific defaults from properties file
Authored-by: hongdongdong <ho...@cmss.chinamobile.com>
Signed-off-by: ulysses-you <ul...@gmail.com>
(cherry picked from commit 8cef5c809a95f9788e643082d1c828ed7f1313f1)
Signed-off-by: ulysses-you <ul...@gmail.com>
---
.../main/scala/org/apache/kyuubi/config/KyuubiConf.scala | 4 +++-
kyuubi-common/src/test/resources/kyuubi-defaults.conf | 4 ++++
.../scala/org/apache/kyuubi/config/KyuubiConfSuite.scala | 15 ++++-----------
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
index d3d24a9..9f7575a 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
@@ -39,7 +39,9 @@ case class KyuubiConf(loadSysDefault: Boolean = true) extends Logging {
}
private def loadFromMap(props: Map[String, String] = Utils.getSystemProperties): KyuubiConf = {
- for ((key, value) <- props if key.startsWith("kyuubi.") || key.startsWith("spark.")) {
+ for ((key, value) <- props if key.startsWith("kyuubi.") || key.startsWith("spark.") ||
+ // for user specific defaults
+ key.startsWith("___")) {
set(key, value)
}
this
diff --git a/kyuubi-common/src/test/resources/kyuubi-defaults.conf b/kyuubi-common/src/test/resources/kyuubi-defaults.conf
index 0bd89b9..ef78175 100644
--- a/kyuubi-common/src/test/resources/kyuubi-defaults.conf
+++ b/kyuubi-common/src/test/resources/kyuubi-defaults.conf
@@ -18,3 +18,7 @@
kyuubi.yes yes
spark.kyuubi.yes no
# kyuubi.no no
+
+spark.user.test a
+___userb___.spark.user.test b
+___userc___.spark.user.test c
\ No newline at end of file
diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/config/KyuubiConfSuite.scala b/kyuubi-common/src/test/scala/org/apache/kyuubi/config/KyuubiConfSuite.scala
index fc7065f..e49f287 100644
--- a/kyuubi-common/src/test/scala/org/apache/kyuubi/config/KyuubiConfSuite.scala
+++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/config/KyuubiConfSuite.scala
@@ -97,17 +97,10 @@ class KyuubiConfSuite extends KyuubiFunSuite {
test("get user specific defaults") {
- val conf = KyuubiConf(false)
- .set("spark.user.test", "a")
- .set("___userb___.spark.user.test", "b")
- .set("___userc___.spark.user.test", "c")
-
- val all1 = conf.getUserDefaults("kyuubi").getAll
- assert(all1.size === 1)
- assert(all1("spark.user.test") === "a")
- val all2 = conf.getUserDefaults("userb").getAll
- assert(all2.size === 1)
- assert(all2("spark.user.test") === "b")
+ val conf = KyuubiConf().loadFileDefaults()
+
+ assert(conf.getUserDefaults("kyuubi").getOption("spark.user.test").get === "a")
+ assert(conf.getUserDefaults("userb").getOption("spark.user.test").get === "b")
assert(conf.getUserDefaults("userc").getOption("spark.user.test").get === "c")
}