nandorKollar commented on code in PR #4583:
URL: https://github.com/apache/polaris/pull/4583#discussion_r3328811327
##########
persistence/relational-jdbc/build.gradle.kts:
##########
@@ -55,3 +55,83 @@ dependencies {
testImplementation(project(":polaris-container-spec-helper"))
testImplementation(project(":polaris-runtime-test-common"))
}
+
+val generatedSchemaVersionTestsDir =
+ layout.buildDirectory.dir("generated/sources/schemaVersionTests/java")
+
+val generateSchemaVersionTests by
+ tasks.registering {
+ val schemaFiles =
+ files(
+ // schema-v0.sql lives in test resources to cover legacy bootstrap
behavior; newer H2
+ // schema files live in main resources. Scan both so new schema
versions get tests
+ // automatically.
+ fileTree("src/main/resources/h2") { include("schema-v*.sql") },
+ fileTree("src/test/resources/h2") { include("schema-v*.sql") },
+ )
+ inputs.files(schemaFiles)
+ outputs.dir(generatedSchemaVersionTestsDir)
+
+ doLast {
+ val outputDir =
+ generatedSchemaVersionTestsDir
+ .get()
+ .file("org/apache/polaris/persistence/relational/jdbc")
+ .asFile
+ delete(outputDir)
+ outputDir.mkdirs()
+
+ val schemaVersionPattern = Regex("""schema-v(\d+)\.sql""")
+ val schemaVersions =
+ schemaFiles.files
+ .mapNotNull {
schemaVersionPattern.matchEntire(it.name)?.groupValues?.get(1)?.toInt() }
+ .toSortedSet()
+
+ check(schemaVersions.isNotEmpty()) { "No H2 schema files found for JDBC
tests" }
+
+ schemaVersions.forEach { schemaVersion ->
+ outputDir
+ .resolve(
+
"AtomicMetastoreManagerWithJdbcBasePersistenceImplV${schemaVersion}SchemaTest.java"
+ )
+ .writeText(
+ """
+ /*
+ * 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.polaris.persistence.relational.jdbc;
+
+ public class
AtomicMetastoreManagerWithJdbcBasePersistenceImplV${schemaVersion}SchemaTest
+ extends AtomicMetastoreManagerWithJdbcBasePersistenceImplTest {
+
+ @Override
+ public int schemaVersion() {
+ return ${schemaVersion};
Review Comment:
+1, using TestFactory and DynamicTests sounds like a better approach.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]