Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only run Paimon authz tests with Scala 2.12 #6925

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private[authz] object AuthZUtils {

lazy val SCALA_RUNTIME_VERSION: SemanticVersion =
SemanticVersion(scala.util.Properties.versionNumberString)
lazy val isScalaV213: Boolean = SCALA_RUNTIME_VERSION >= "2.13"
lazy val isScalaV212: Boolean = SCALA_RUNTIME_VERSION === "2.12"
lazy val isScalaV213: Boolean = SCALA_RUNTIME_VERSION === "2.13"

def derbyJdbcDriverClass: String = if (isSparkV40OrGreater) {
// SPARK-46257 (Spark 4.0.0) moves to Derby 10.16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
*/
package org.apache.kyuubi.plugin.spark.authz.ranger

import scala.util.Properties

import org.scalatest.Outcome

import org.apache.kyuubi.Utils
import org.apache.kyuubi.plugin.spark.authz.AccessControlException
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._
import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._
import org.apache.kyuubi.tags.PaimonTest
import org.apache.kyuubi.util.AssertionUtils._

Expand All @@ -32,9 +31,8 @@ import org.apache.kyuubi.util.AssertionUtils._
@PaimonTest
class PaimonCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
override protected val catalogImpl: String = "hive"
private def isSupportedVersion = true
private def isSupportedVersion = isScalaV212

val scalaVersion: String = Properties.versionString
val catalogV2 = "paimon_catalog"
val namespace1 = "paimon_ns"
val table1 = "table1"
Expand All @@ -51,9 +49,8 @@ class PaimonCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
s"spark.sql.catalog.$catalogV2.warehouse",
Utils.createTempDir(catalogV2).toString)
super.beforeAll()
doAs(admin, sql(s"CREATE DATABASE IF NOT EXISTS $catalogV2.$namespace1"))
}

doAs(admin, sql(s"CREATE DATABASE IF NOT EXISTS $catalogV2.$namespace1"))
}

override def afterAll(): Unit = {
Expand Down Expand Up @@ -87,28 +84,20 @@ class PaimonCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {

test("[KYUUBI #6541] INSERT/SELECT TABLE") {
val tName = "t_paimon"
withCleanTmpResources(Seq((s"$catalogV2.$namespace1.$tName", "table"))) {
doAs(bob, sql(createTableSql(namespace1, tName)))

/**
* paimon-spark run on Scala 2.12.
*/
if (scalaVersion.startsWith("version 2.12")) {
withCleanTmpResources(Seq((s"$catalogV2.$namespace1.$tName", "table"))) {

doAs(bob, sql(createTableSql(namespace1, tName)))

interceptEndsWith[AccessControlException] {
doAs(someone, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_1')"))
}(s"does not have [update] privilege on [$namespace1/$tName]")
doAs(bob, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_1')"))
doAs(bob, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_2')"))
interceptEndsWith[AccessControlException] {
doAs(someone, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_1')"))
}(s"does not have [update] privilege on [$namespace1/$tName]")
doAs(bob, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_1')"))
doAs(bob, sql(s"INSERT INTO $catalogV2.$namespace1.$tName VALUES (1, 'name_2')"))

interceptEndsWith[AccessControlException] {
doAs(someone, sql(s"SELECT id FROM $catalogV2.$namespace1.$tName").show())
}(s"does not have [select] privilege on [$namespace1/$tName/id]")
doAs(bob, sql(s"SELECT name FROM $catalogV2.$namespace1.$tName").show())
}
interceptEndsWith[AccessControlException] {
doAs(someone, sql(s"SELECT id FROM $catalogV2.$namespace1.$tName").show())
}(s"does not have [select] privilege on [$namespace1/$tName/id]")
doAs(bob, sql(s"SELECT name FROM $catalogV2.$namespace1.$tName").show())
}

}

def createTableSql(namespace: String, table: String): String =
Expand Down
Loading