This is an automated email from the ASF dual-hosted git repository.
ulyssesyou 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 795b7e1 [KYUUBI #1459] Kyuubi Server Event Test change
795b7e1 is described below
commit 795b7e1bb23740aab4358c3f163d9be9cce340c0
Author: zhenjiaguo <[email protected]>
AuthorDate: Mon Nov 29 14:13:44 2021 +0800
[KYUUBI #1459] Kyuubi Server Event Test change
<!--
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.
-->
Use regular matching to replace jackson Json parsing in kyuubi server event
info test. Because the Json string is queried by SparkSQL, the special
characters will be converted. This causes the configuration of environment
variables to be read again and cannot be parsed into JSON.
For example, the environment variable contains the variable
`ENV_VAR="\"string\""`, which becomes `ENV_VAR=""string""` after being read by
SparkSQL, which cannot be converted into JSON.
### _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
- [x] [Run
test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests)
locally before make a pull request
Closes #1459 from zhenjiaguo/add-kyuubi-server-event.
Closes #1459
0282030a [jia] Merge branch 'master' into add-kyuubi-server-event
8b4f4f1a [zhenjiaguo] use regular replace JSON parser
d97e1d00 [zhenjiaguo] optimize import
56939c13 [zhenjiaguo] change import way
7632363b [zhenjiaguo] rebase master
44559154 [zhenjiaguo] add more info in kyuubi server event
beacc88a [zhenjiaguo] add sparksql case-sensitive setting
b35875fc [zhenjiaguo] add kyuubi server start event test
d3161681 [zhenjiaguo] add KyuubiServerEvent
Lead-authored-by: zhenjiaguo <[email protected]>
Co-authored-by: jia <[email protected]>
Signed-off-by: ulysses-you <[email protected]>
---
.../kyuubi/events/EventLoggingServiceSuite.scala | 31 ++++++++++++++++------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git
a/kyuubi-server/src/test/scala/org/apache/kyuubi/events/EventLoggingServiceSuite.scala
b/kyuubi-server/src/test/scala/org/apache/kyuubi/events/EventLoggingServiceSuite.scala
index f64e3ee..fe52472 100644
---
a/kyuubi-server/src/test/scala/org/apache/kyuubi/events/EventLoggingServiceSuite.scala
+++
b/kyuubi-server/src/test/scala/org/apache/kyuubi/events/EventLoggingServiceSuite.scala
@@ -21,6 +21,8 @@ import java.net.InetAddress
import java.nio.file.Paths
import java.util.UUID
+import scala.util.matching.Regex
+
import com.fasterxml.jackson.databind.ObjectMapper
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}
@@ -185,19 +187,22 @@ class EventLoggingServiceSuite extends WithKyuubiServer
with HiveJDBCTestHelper
val serverIP = res.getString("serverIP")
assert(serverIP != null && !"".equals(serverIP))
- val objMapper = new ObjectMapper()
- val confMap = objMapper.readTree(res.getString("serverConf"))
- confKv.foreach(kv => assert(confMap.get(kv._1).asText() == kv._2))
-
- val USER = "USER"
- val envMap = objMapper.readTree(res.getString("serverEnv"))
- val envUser = if (envMap.has(USER)) envMap.get(USER).asText() else ""
- assert(envUser == sys.env.getOrElse(USER, ""))
+ var confIdx = 0
+ List(""""awesome.kyuubi":"(.*?)"""".r,
""""awesome.kyuubi.server":"(.*?)"""".r).foreach { p =>
+ val matchConf = p.findFirstMatchIn(res.getString("serverConf"))
+ assert(matchConf.isDefined)
+ matchConf.foreach {
+ case p(value) =>
+ assert(value == confKv(confIdx)._2)
+ confIdx += 1
+ }
+ }
assert(res.getString("BUILD_USER") == BUILD_USER)
assert(res.getString("BUILD_DATE") == BUILD_DATE)
assert(res.getString("REPO_URL") == REPO_URL)
+ val objMapper = new ObjectMapper()
val versionInfoMap = objMapper.readTree(res.getString("VERSION_INFO"))
assert(versionInfoMap.get("KYUUBI_VERSION").asText() == KYUUBI_VERSION)
assert(versionInfoMap.get("JAVA_COMPILE_VERSION").asText() ==
JAVA_COMPILE_VERSION)
@@ -212,6 +217,16 @@ class EventLoggingServiceSuite extends WithKyuubiServer
with HiveJDBCTestHelper
assert(res.getString("state") == ServiceState.STOPPED.toString)
assert(res.getString("BUILD_USER") == BUILD_USER)
assert(res.getString("eventType") == "kyuubi_server_info")
+
+ val USER = "USER"
+ if (sys.env.contains(USER)) {
+ val pattern: Regex = s""""$USER":"(.*?)"""".r
+ val matchEnv = pattern.findFirstMatchIn(res.getString("serverEnv"))
+ assert(matchEnv.isDefined)
+ matchEnv.foreach {
+ case pattern(usr) => assert(usr == sys.env(USER))
+ }
+ }
}
}
}