This is an automated email from the ASF dual-hosted git repository.
bowenliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new bad0ccb5e [KYUUBI #5660] [TEST] Ensure SPI provider file content
sorted in alphabet order
bad0ccb5e is described below
commit bad0ccb5ed3973d76da10aa4354a3fc10608b667
Author: Bowen Liang <[email protected]>
AuthorDate: Fri Nov 10 13:44:36 2023 +0800
[KYUUBI #5660] [TEST] Ensure SPI provider file content sorted in alphabet
order
### _Why are the changes needed?_
Check the content of the SPI provider files sorted in alphabet order.
### _How was this patch tested?_
- [ ] 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/master/contributing/code/testing.html#running-tests)
locally before make a pull request
### _Was this patch authored or co-authored using generative AI tooling?_
No.
Closes #5660 from bowenliang123/spi-sort.
Closes #5660
30c7028f6 [Bowen Liang] ensure SPI provider file sorted
Authored-by: Bowen Liang <[email protected]>
Signed-off-by: Bowen Liang <[email protected]>
---
...bi.plugin.spark.authz.serde.ActionTypeExtractor | 2 +-
...yuubi.plugin.spark.authz.serde.CatalogExtractor | 2 +-
...kyuubi.plugin.spark.authz.serde.ColumnExtractor | 2 +-
...uubi.plugin.spark.authz.serde.DatabaseExtractor | 2 +-
...uubi.plugin.spark.authz.serde.FunctionExtractor | 2 +-
....plugin.spark.authz.serde.FunctionTypeExtractor | 2 +-
....kyuubi.plugin.spark.authz.serde.QueryExtractor | 2 +-
....kyuubi.plugin.spark.authz.serde.TableExtractor | 8 ++--
...ubi.plugin.spark.authz.serde.TableTypeExtractor | 2 +-
...he.kyuubi.plugin.spark.authz.serde.URIExtractor | 8 ++--
.../spark/authz/gen/PolicyJsonFileGenerator.scala | 9 ++--
.../authz/gen/CheckAuthzExtractorSPISuite.scala | 49 ++++++++++++++++++++++
.../spark/authz/gen/JsonSpecFileGenerator.scala | 6 +--
...i.engine.jdbc.connection.JdbcConnectionProvider | 2 +-
...g.apache.kyuubi.engine.jdbc.dialect.JdbcDialect | 2 +-
.../engine/jdbc/CheckJdbcDialectSPISuite.scala | 41 ++++++++++++++++++
.../scala/org/apache/kyuubi/MarkdownUtils.scala | 22 ++--------
...rg.apache.hadoop.security.token.TokenIdentifier | 2 +-
...yuubi.credentials.HadoopDelegationTokenProvider | 2 +-
.../org.apache.kyuubi.engine.ApplicationOperation | 4 +-
.../kyuubi/service/CheckServerSPISuite.scala | 42 +++++++++++++++++++
.../org/apache/kyuubi/util/AssertionUtils.scala | 23 +++++++++-
.../org/apache/kyuubi/util/GoldenFileUtils.scala | 30 +++++++++++++
23 files changed, 217 insertions(+), 49 deletions(-)
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ActionTypeExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ActionTypeExtractor
index 61fa81809..140d113ac 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ActionTypeExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ActionTypeExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.CatalogExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.CatalogExtractor
index ae058a66f..7ae3aac52 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.CatalogExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.CatalogExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ColumnExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ColumnExtractor
index ed76c15d1..497c7867c 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ColumnExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.ColumnExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.DatabaseExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.DatabaseExtractor
index 2a269ee50..c2b658125 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.DatabaseExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.DatabaseExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionExtractor
index 2facb004a..745fd1bfc 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionTypeExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionTypeExtractor
index 3bb0ee6c2..d054f3462 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionTypeExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.FunctionTypeExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.QueryExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.QueryExtractor
index 2406a40e1..10222257a 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.QueryExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.QueryExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableExtractor
index 533e4de40..7010766f2 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
@@ -19,10 +19,10 @@
org.apache.kyuubi.plugin.spark.authz.serde.CatalogTableOptionTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.CatalogTableTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.DataSourceV2RelationTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.ExpressionSeqTableExtractor
-org.apache.kyuubi.plugin.spark.authz.serde.HudiDataSourceV2RelationTableExtractor
-org.apache.kyuubi.plugin.spark.authz.serde.HudiMergeIntoTargetTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.HudiCallProcedureInputTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.HudiCallProcedureOutputTableExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.HudiDataSourceV2RelationTableExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.HudiMergeIntoTargetTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.IdentifierTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.LogicalRelationTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.ResolvedDbObjectNameTableExtractor
@@ -30,6 +30,6 @@
org.apache.kyuubi.plugin.spark.authz.serde.ResolvedIdentifierTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.ResolvedTableTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.StringTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.SubqueryAliasTableExtractor
-org.apache.kyuubi.plugin.spark.authz.serde.TableIdentifierTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.TableIdentifierOptionTableExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.TableIdentifierTableExtractor
org.apache.kyuubi.plugin.spark.authz.serde.TableTableExtractor
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableTypeExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableTypeExtractor
index 251a31758..caeeefa41 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableTypeExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.TableTypeExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.URIExtractor
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.URIExtractor
index bad6aba57..9daf156c6 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.URIExtractor
+++
b/extensions/spark/kyuubi-spark-authz/src/main/resources/META-INF/services/org.apache.kyuubi.plugin.spark.authz.serde.URIExtractor
@@ -6,7 +6,7 @@
# (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
+# 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,
@@ -15,10 +15,10 @@
# limitations under the License.
#
-org.apache.kyuubi.plugin.spark.authz.serde.CatalogStorageFormatURIExtractor
org.apache.kyuubi.plugin.spark.authz.serde.BaseRelationFileIndexURIExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.CatalogStorageFormatURIExtractor
org.apache.kyuubi.plugin.spark.authz.serde.PartitionLocsSeqURIExtractor
-org.apache.kyuubi.plugin.spark.authz.serde.PropertiesPathUriExtractor
org.apache.kyuubi.plugin.spark.authz.serde.PropertiesLocationUriExtractor
-org.apache.kyuubi.plugin.spark.authz.serde.StringURIExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.PropertiesPathUriExtractor
org.apache.kyuubi.plugin.spark.authz.serde.StringSeqURIExtractor
+org.apache.kyuubi.plugin.spark.authz.serde.StringURIExtractor
diff --git
a/extensions/spark/kyuubi-spark-authz/src/test/gen/scala/org/apache/kyuubi/plugin/spark/authz/gen/PolicyJsonFileGenerator.scala
b/extensions/spark/kyuubi-spark-authz/src/test/gen/scala/org/apache/kyuubi/plugin/spark/authz/gen/PolicyJsonFileGenerator.scala
index 7996c8ecc..afc7a5fde 100644
---
a/extensions/spark/kyuubi-spark-authz/src/test/gen/scala/org/apache/kyuubi/plugin/spark/authz/gen/PolicyJsonFileGenerator.scala
+++
b/extensions/spark/kyuubi-spark-authz/src/test/gen/scala/org/apache/kyuubi/plugin/spark/authz/gen/PolicyJsonFileGenerator.scala
@@ -27,9 +27,9 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import org.apache.ranger.plugin.model.RangerPolicy
+// scalastyle:off
import org.scalatest.funsuite.AnyFunSuite
-// scalastyle:off
import org.apache.kyuubi.plugin.spark.authz.RangerTestNamespace._
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._
import
org.apache.kyuubi.plugin.spark.authz.gen.KRangerPolicyItemAccess.allowTypes
@@ -37,6 +37,7 @@ import
org.apache.kyuubi.plugin.spark.authz.gen.KRangerPolicyResource._
import org.apache.kyuubi.plugin.spark.authz.gen.RangerAccessType._
import org.apache.kyuubi.plugin.spark.authz.gen.RangerClassConversions._
import org.apache.kyuubi.util.AssertionUtils._
+import org.apache.kyuubi.util.GoldenFileUtils._
/**
* Generates the policy file to test/main/resources dir.
@@ -59,11 +60,9 @@ class PolicyJsonFileGenerator extends AnyFunSuite {
.build()
test("check ranger policy file") {
- val pluginHome =
getClass.getProtectionDomain.getCodeSource.getLocation.getPath
- .split("target").head
val policyFileName = "sparkSql_hive_jenkins.json"
- val policyFilePath =
- Paths.get(pluginHome, "src", "test", "resources", policyFileName)
+ val policyFilePath = Paths.get(
+ s"${getCurrentModuleHome(this)}/src/test/resources/$policyFileName")
val generatedStr = mapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(servicePolicies)
diff --git
a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/CheckAuthzExtractorSPISuite.scala
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/CheckAuthzExtractorSPISuite.scala
new file mode 100644
index 000000000..7a66e99ea
--- /dev/null
+++
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/CheckAuthzExtractorSPISuite.scala
@@ -0,0 +1,49 @@
+/*
+ * 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.plugin.spark.authz.gen
+
+import java.nio.file.Paths
+
+// scalastyle:off
+import org.scalatest.funsuite.AnyFunSuite
+
+import org.apache.kyuubi.util.AssertionUtils._
+import org.apache.kyuubi.util.GoldenFileUtils._
+
+class CheckAuthzExtractorSPISuite extends AnyFunSuite {
+ // scalastyle:on
+
+ test("check authz extractor SPI service file sorted") {
+ Seq(
+ "org.apache.kyuubi.plugin.spark.authz.serde.ActionTypeExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.CatalogExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.ColumnExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.DatabaseExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.FunctionExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.FunctionTypeExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.QueryExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.TableExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.TableTypeExtractor",
+ "org.apache.kyuubi.plugin.spark.authz.serde.URIExtractor")
+ .foreach { fileName =>
+ val filePath = Paths.get(
+
s"${getCurrentModuleHome(this)}/src/main/resources/META-INF/services/$fileName")
+ assertFileContentSorted(filePath)
+ }
+ }
+}
diff --git
a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/JsonSpecFileGenerator.scala
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/JsonSpecFileGenerator.scala
index 5fb4ace10..58d161ce0 100644
---
a/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/JsonSpecFileGenerator.scala
+++
b/extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/JsonSpecFileGenerator.scala
@@ -26,6 +26,7 @@ import org.scalatest.funsuite.AnyFunSuite
import org.apache.kyuubi.plugin.spark.authz.serde.{mapper, CommandSpec}
import org.apache.kyuubi.plugin.spark.authz.serde.CommandSpecs
import org.apache.kyuubi.util.AssertionUtils._
+import org.apache.kyuubi.util.GoldenFileUtils._
/**
* Generates the default command specs to src/main/resources dir.
@@ -52,10 +53,9 @@ class JsonSpecFileGenerator extends AnyFunSuite {
def writeCommandSpecJson[T <: CommandSpec](
commandType: String,
specsArr: Seq[CommandSpecs[T]]): Unit = {
- val pluginHome =
getClass.getProtectionDomain.getCodeSource.getLocation.getPath
- .split("target").head
val filename = s"${commandType}_command_spec.json"
- val filePath = Paths.get(pluginHome, "src", "main", "resources", filename)
+ val filePath = Paths.get(
+ s"${getCurrentModuleHome(this)}/src/main/resources/$filename")
val allSpecs = specsArr.flatMap(_.specs.sortBy(_.classname))
val duplicatedClassnames = allSpecs.groupBy(_.classname).values
diff --git
a/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.connection.JdbcConnectionProvider
b/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.connection.JdbcConnectionProvider
index 326088aae..db146a42c 100644
---
a/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.connection.JdbcConnectionProvider
+++
b/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.connection.JdbcConnectionProvider
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.dialect.JdbcDialect
b/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.dialect.JdbcDialect
index 03cc66e51..1529f8598 100644
---
a/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.dialect.JdbcDialect
+++
b/externals/kyuubi-jdbc-engine/src/main/resources/META-INF/services/org.apache.kyuubi.engine.jdbc.dialect.JdbcDialect
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/CheckJdbcDialectSPISuite.scala
b/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/CheckJdbcDialectSPISuite.scala
new file mode 100644
index 000000000..e30ebce5d
--- /dev/null
+++
b/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/CheckJdbcDialectSPISuite.scala
@@ -0,0 +1,41 @@
+/*
+ * 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.engine.jdbc
+
+import java.nio.file.Paths
+
+// scalastyle:off
+import org.scalatest.funsuite.AnyFunSuite
+
+import org.apache.kyuubi.util.AssertionUtils._
+import org.apache.kyuubi.util.GoldenFileUtils._
+
+class CheckJdbcDialectSPISuite extends AnyFunSuite {
+ // scalastyle:on
+
+ test("check JDBC dialect SPI service file sorted") {
+ Seq(
+ "org.apache.kyuubi.engine.jdbc.connection.JdbcConnectionProvider",
+ "org.apache.kyuubi.engine.jdbc.dialect.JdbcDialect")
+ .foreach { fileName =>
+ val filePath = Paths.get(
+
s"${getCurrentModuleHome(this)}/src/main/resources/META-INF/services/$fileName")
+ assertFileContentSorted(filePath)
+ }
+ }
+}
diff --git a/kyuubi-common/src/test/scala/org/apache/kyuubi/MarkdownUtils.scala
b/kyuubi-common/src/test/scala/org/apache/kyuubi/MarkdownUtils.scala
index 4dbe6ea67..71dc05f61 100644
--- a/kyuubi-common/src/test/scala/org/apache/kyuubi/MarkdownUtils.scala
+++ b/kyuubi-common/src/test/scala/org/apache/kyuubi/MarkdownUtils.scala
@@ -25,6 +25,8 @@ import
com.vladsch.flexmark.profile.pegdown.PegdownOptionsAdapter
import com.vladsch.flexmark.util.data.{MutableDataHolder, MutableDataSet}
import com.vladsch.flexmark.util.sequence.SequenceUtils.EOL
+import org.apache.kyuubi.util.GoldenFileUtils.getLicenceContent
+
class MarkdownBuilder {
private val buffer = new ListBuffer[String]
@@ -58,24 +60,8 @@ class MarkdownBuilder {
* @return
*/
def licence(): MarkdownBuilder = {
- this ++= """
- |<!--
- |- 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.
- |-->
- |"""
+ buffer.appendAll(getLicenceContent(header = "<!--", linePrefix = "-",
footer = "-->"))
+ this
}
/**
diff --git
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
index 3b1f088f9..65e2965c0 100644
---
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
+++
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.hadoop.security.token.TokenIdentifier
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.credentials.HadoopDelegationTokenProvider
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.credentials.HadoopDelegationTokenProvider
index 1d931c8c7..95d6e1987 100644
---
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.credentials.HadoopDelegationTokenProvider
+++
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.credentials.HadoopDelegationTokenProvider
@@ -6,7 +6,7 @@
# (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
+# 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,
diff --git
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.engine.ApplicationOperation
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.engine.ApplicationOperation
index 712bd8f2e..b6df64bd9 100644
---
a/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.engine.ApplicationOperation
+++
b/kyuubi-server/src/main/resources/META-INF/services/org.apache.kyuubi.engine.ApplicationOperation
@@ -6,7 +6,7 @@
# (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
+# 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,
@@ -15,6 +15,6 @@
# limitations under the License.
#
-org.apache.kyuubi.engine.YarnApplicationOperation
org.apache.kyuubi.engine.JpsApplicationOperation
org.apache.kyuubi.engine.KubernetesApplicationOperation
+org.apache.kyuubi.engine.YarnApplicationOperation
diff --git
a/kyuubi-server/src/test/scala/org/apache/kyuubi/service/CheckServerSPISuite.scala
b/kyuubi-server/src/test/scala/org/apache/kyuubi/service/CheckServerSPISuite.scala
new file mode 100644
index 000000000..295c7df3d
--- /dev/null
+++
b/kyuubi-server/src/test/scala/org/apache/kyuubi/service/CheckServerSPISuite.scala
@@ -0,0 +1,42 @@
+/*
+ * 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.service
+
+import java.nio.file.Paths
+
+// scalastyle:off
+import org.scalatest.funsuite.AnyFunSuite
+
+import org.apache.kyuubi.util.AssertionUtils._
+import org.apache.kyuubi.util.GoldenFileUtils._
+
+class CheckServerSPISuite extends AnyFunSuite {
+ // scalastyle:on
+
+ test("check server SPI service file sorted") {
+ Seq(
+ "org.apache.hadoop.security.token.TokenIdentifier",
+ "org.apache.kyuubi.credentials.HadoopDelegationTokenProvider",
+ "org.apache.kyuubi.engine.ApplicationOperation")
+ .foreach { fileName =>
+ val filePath = Paths.get(
+
s"${getCurrentModuleHome(this)}/src/main/resources/META-INF/services/$fileName")
+ assertFileContentSorted(filePath)
+ }
+ }
+}
diff --git
a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/AssertionUtils.scala
b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/AssertionUtils.scala
index 9d33993b9..0a82af2eb 100644
---
a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/AssertionUtils.scala
+++
b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/AssertionUtils.scala
@@ -17,9 +17,10 @@
package org.apache.kyuubi.util
import java.nio.charset.StandardCharsets
-import java.nio.file.Path
+import java.nio.file.{Files, Path}
import java.util.Locale
+import scala.collection.JavaConverters._
import scala.collection.Traversable
import scala.io.Source
import scala.reflect.ClassTag
@@ -29,6 +30,8 @@ import org.scalactic.Prettifier
import org.scalactic.source.Position
import org.scalatest.Assertions._
+import org.apache.kyuubi.util.GoldenFileUtils.getLicenceContent
+
object AssertionUtils {
def assertEqualsIgnoreCase(expected: AnyRef)(actual: AnyRef)(
@@ -106,6 +109,24 @@ object AssertionUtils {
}
}
+ def assertFileContentSorted(
+ filePath: Path,
+ headerSkipPrefix: String = "#",
+ licenceHeader: Iterable[String] = getLicenceContent(),
+ distinct: Boolean = true): Unit = {
+ val sortedLines = Files.readAllLines(filePath).asScala
+ .dropWhile(line => line.trim == "" ||
line.trim.startsWith(headerSkipPrefix))
+ .map(_.trim).filter(_.nonEmpty)
+ .sorted
+ val expectedSortedLines = if (distinct) {
+ sortedLines.distinct
+ } else {
+ sortedLines
+ }
+ val expectedLines = licenceHeader ++ Seq("") ++ expectedSortedLines
+ assertFileContent(filePath, expectedLines, s"Check SPI provider file
sorted $filePath")
+ }
+
/**
* Assert the iterable contains all the expected elements
*/
diff --git
a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/GoldenFileUtils.scala
b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/GoldenFileUtils.scala
index e9927f7e2..0ab292c9c 100644
---
a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/GoldenFileUtils.scala
+++
b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/GoldenFileUtils.scala
@@ -48,4 +48,34 @@ object GoldenFileUtils {
assertFileContent(path, lines, regenScript)
}
}
+
+ def getCurrentModuleHome(obj: Any): String = {
+ obj.getClass.getProtectionDomain.getCodeSource.getLocation.getPath
+ .split("target").head
+ }
+
+ val apacheLicenceContent: String =
+ """ 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.
+ |""".stripMargin
+
+ def getLicenceContent(
+ header: String = "#",
+ linePrefix: String = "#",
+ footer: String = "#"): Iterable[String] = {
+ val content = apacheLicenceContent.split("\n").map(line => linePrefix +
line)
+ Seq(header) ++ content ++ Seq(footer)
+ }
}