-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
764 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
kyuubi-common/src/main/scala/org/apache/kyuubi/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache | ||
|
||
import java.util.Properties | ||
|
||
import scala.util.Try | ||
|
||
package object kyuubi { | ||
private object BuildInfo { | ||
private val buildFile = "kyuubi-version-info.properties" | ||
private val buildFileStream = | ||
Thread.currentThread().getContextClassLoader.getResourceAsStream(buildFile) | ||
private val unknown = "<unknown>" | ||
private val props = new Properties() | ||
|
||
try { | ||
props.load(buildFileStream) | ||
} catch { | ||
case e: Exception => throw new KyuubiException(e) | ||
} finally { | ||
Try(buildFileStream.close()) | ||
} | ||
|
||
val version: String = props.getProperty("kyuubi_version", unknown) | ||
val sparkVersion: String = props.getProperty("spark_version", unknown) | ||
val branch: String = props.getProperty("branch", unknown) | ||
val jar: String = props.getProperty("jar", unknown) | ||
val revision: String = props.getProperty("revision", unknown) | ||
val user: String = props.getProperty("user", unknown) | ||
val repoUrl: String = props.getProperty("url", unknown) | ||
val buildDate: String = props.getProperty("date", unknown) | ||
} | ||
|
||
val KYUUBI_VERSION: String = BuildInfo.version | ||
val SPARK_COMPILE_VERSION: String = BuildInfo.sparkVersion | ||
val BRANCH: String = BuildInfo.branch | ||
val KYUUBI_JAR_NAME: String = BuildInfo.jar | ||
val REVISION: String = BuildInfo.revision | ||
val BUILD_USER: String = BuildInfo.user | ||
val REPO_URL: String = BuildInfo.repoUrl | ||
val BUILD_DATE: String = BuildInfo.buildDate | ||
} |
63 changes: 63 additions & 0 deletions
63
kyuubi-common/src/test/scala/org/apache/kyuubi/KerberizedTestHelper.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.kyuubi | ||
|
||
import java.io.{File, IOException} | ||
|
||
import org.apache.hadoop.conf.Configuration | ||
import org.apache.hadoop.minikdc.MiniKdc | ||
import org.apache.hadoop.security.UserGroupInformation | ||
|
||
trait KerberizedTestHelper { | ||
var kdc: MiniKdc = _ | ||
val baseDir: File = Utils.createTempDir( | ||
this.getClass.getProtectionDomain.getCodeSource.getLocation.getPath, "kyuubi-kdc") | ||
|
||
try { | ||
val kdcConf = MiniKdc.createConf() | ||
kdcConf.setProperty(MiniKdc.INSTANCE, "KyuubiKrbServer") | ||
kdcConf.setProperty(MiniKdc.ORG_NAME, "KYUUBI") | ||
kdcConf.setProperty(MiniKdc.ORG_DOMAIN, "COM") | ||
|
||
if (kdc == null) { | ||
kdc = new MiniKdc(kdcConf, baseDir) | ||
kdc.start() | ||
} | ||
} catch { | ||
case e: IOException => | ||
throw new AssertionError("unable to create temporary directory: " + e.getMessage) | ||
} | ||
|
||
def tryWithSecurityEnabled(block: => Unit): Unit = { | ||
val conf = new Configuration() | ||
assert(!UserGroupInformation.isSecurityEnabled) | ||
val authType = "hadoop.security.authentication" | ||
try { | ||
conf.set(authType, "KERBEROS") | ||
System.setProperty("java.security.krb5.realm", kdc.getRealm) | ||
UserGroupInformation.setConfiguration(conf) | ||
assert(UserGroupInformation.isSecurityEnabled) | ||
block | ||
} finally { | ||
conf.unset(authType) | ||
System.clearProperty("java.security.krb5.realm") | ||
UserGroupInformation.setConfiguration(conf) | ||
assert(!UserGroupInformation.isSecurityEnabled) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.