diff --git a/Dockerfile b/Dockerfile index 7b8cbfb80..224116dc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ WORKDIR /app RUN rm -rf build # Build the rest catalog -RUN ./gradlew --no-daemon --info ${ECLIPSELINK_DEPS+"-PeclipseLinkDeps=$ECLIPSELINK_DEPS"} -PeclipseLink=$ECLIPSELINK clean :polaris-quarkus-service:build -x test +RUN ./gradlew --no-daemon --info ${ECLIPSELINK_DEPS+"-PeclipseLinkDeps=$ECLIPSELINK_DEPS"} -PeclipseLink=$ECLIPSELINK clean :polaris-quarkus-service:build -x test -x intTest FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.21-1.1733995527 diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts b/build-logic/src/main/kotlin/polaris-java.gradle.kts index 78f363474..43f25f8b5 100644 --- a/build-logic/src/main/kotlin/polaris-java.gradle.kts +++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts @@ -105,6 +105,49 @@ testing { } } } + + register("intTest") { + val libs = versionCatalogs.named("libs") + useJUnitJupiter( + libs + .findLibrary("junit-bom") + .orElseThrow { GradleException("junit-bom not declared in libs.versions.toml") } + .map { it.version!! } + ) + + testType = TestSuiteType.INTEGRATION_TEST + + dependencies { implementation.add(project()) } + + val hasQuarkus = plugins.hasPlugin("io.quarkus") + + targets.all { + testTask.configure { + shouldRunAfter("test") + + // For Quarkus... + // + // io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory(java.net.URL) + // is not smart enough :( + if (hasQuarkus) { + systemProperty("build.output.directory", layout.buildDirectory.asFile.get()) + dependsOn(tasks.named("quarkusBuild")) + } + } + + if (hasQuarkus) { + tasks.named("compileIntTestJava").configure { + dependsOn(tasks.named("compileQuarkusTestGeneratedSourcesJava")) + } + } + + tasks.named("check").configure { dependsOn(testTask) } + } + + if (hasQuarkus) { + sources { java.srcDirs(tasks.named("quarkusGenerateCodeTests")) } + } + } } } @@ -221,3 +264,15 @@ configurations.all { } } } + +// Let the test's implementation config extend testImplementation, so it also inherits the +// project's "main" implementation dependencies (not just the "api" configuration) +configurations.named("intTestImplementation").configure { + extendsFrom(configurations.getByName("testImplementation")) +} + +dependencies { add("intTestImplementation", java.sourceSets.getByName("test").output.dirs) } + +configurations.named("intTestRuntimeOnly").configure { + extendsFrom(configurations.getByName("testRuntimeOnly")) +} diff --git a/quarkus/service/build.gradle.kts b/quarkus/service/build.gradle.kts index 3405a3fe2..4695a64a6 100644 --- a/quarkus/service/build.gradle.kts +++ b/quarkus/service/build.gradle.kts @@ -89,7 +89,8 @@ dependencies { implementation(libs.jakarta.servlet.api) - testImplementation(project(":polaris-tests")) + testFixturesApi(project(":polaris-tests")) + testImplementation(project(":polaris-api-management-model")) testImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}:tests") @@ -120,13 +121,26 @@ dependencies { testImplementation("org.testcontainers:testcontainers") testImplementation(libs.s3mock.testcontainers) - // required for PolarisSparkIntegrationTest - testImplementation(enforcedPlatform(libs.scala212.lang.library)) - testImplementation(enforcedPlatform(libs.scala212.lang.reflect)) - testImplementation(libs.javax.servlet.api) - testImplementation(libs.antlr4.runtime) - testImplementation(libs.hawkular.agent.prometheus.scraper) + + intTestImplementation(project(":polaris-api-management-model")) + + intTestImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}") + intTestImplementation("org.apache.iceberg:iceberg-core:${libs.versions.iceberg.get()}") + intTestImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}:tests") + intTestImplementation("org.apache.iceberg:iceberg-core:${libs.versions.iceberg.get()}:tests") + + intTestImplementation(platform(libs.quarkus.bom)) + intTestImplementation("io.quarkus:quarkus-junit5") + + // override dnsjava version in dependencies due to https://github.com/dnsjava/dnsjava/issues/329 + intTestImplementation(platform(libs.dnsjava)) + + // required for QuarkusSparkIT + intTestImplementation(enforcedPlatform(libs.scala212.lang.library)) + intTestImplementation(enforcedPlatform(libs.scala212.lang.reflect)) + intTestImplementation(libs.javax.servlet.api) + intTestImplementation(libs.antlr4.runtime) } tasks.withType(Test::class.java).configureEach { @@ -147,6 +161,19 @@ tasks.named("test").configure { maxParallelForks = 4 } +tasks.named("intTest").configure { + if (System.getenv("AWS_REGION") == null) { + environment("AWS_REGION", "us-west-2") + } + // Note: the test secrets are referenced in DropwizardServerManager + environment("POLARIS_BOOTSTRAP_CREDENTIALS", "POLARIS,root,test-admin,test-secret") + jvmArgs("--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED") + // Need to allow a java security manager after Java 21, for Subject.getSubject to work + // "getSubject is supported only if a security manager is allowed". + systemProperty("java.security.manager", "allow") + maxParallelForks = 1 +} + /** * Adds the JPMS options required for Spark to run on Java 17, taken from the * `DEFAULT_MODULE_OPTIONS` constant in `org.apache.spark.launcher.JavaModuleOptions`. diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusApplicationIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusApplicationIT.java new file mode 100644 index 000000000..ee38ff46b --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusApplicationIT.java @@ -0,0 +1,25 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.apache.polaris.service.it.test.PolarisApplicationIntegrationTest; + +@QuarkusIntegrationTest +public class QuarkusApplicationIT extends PolarisApplicationIntegrationTest {} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusManagementServiceIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusManagementServiceIT.java new file mode 100644 index 000000000..d7f4779e4 --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusManagementServiceIT.java @@ -0,0 +1,26 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.apache.polaris.service.it.test.PolarisManagementServiceIntegrationTest; + +@QuarkusIntegrationTest +public class QuarkusManagementServiceIT + extends PolarisManagementServiceIntegrationTest {} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogIT.java new file mode 100644 index 000000000..5d214d188 --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogIT.java @@ -0,0 +1,25 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import org.apache.polaris.service.it.test.PolarisRestCatalogIntegrationTest; + +@QuarkusIntegrationTest +public class QuarkusRestCatalogIT extends PolarisRestCatalogIntegrationTest {} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAwsIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAwsIT.java new file mode 100644 index 000000000..1a46d9713 --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAwsIT.java @@ -0,0 +1,40 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import java.lang.reflect.Field; +import java.nio.file.Path; +import org.apache.iceberg.view.ViewCatalogTests; +import org.apache.polaris.service.it.test.PolarisRestCatalogViewAwsIntegrationTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; + +@QuarkusIntegrationTest +public class QuarkusRestCatalogViewAwsIT + extends PolarisRestCatalogViewAwsIntegrationTest { + + @BeforeEach + public void setUpTempDir(@TempDir Path tempDir) throws Exception { + // see https://github.com/quarkusio/quarkus/issues/13261 + Field field = ViewCatalogTests.class.getDeclaredField("tempDir"); + field.setAccessible(true); + field.set(this, tempDir); + } +} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAzureIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAzureIT.java new file mode 100644 index 000000000..45178230b --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewAzureIT.java @@ -0,0 +1,40 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import java.lang.reflect.Field; +import java.nio.file.Path; +import org.apache.iceberg.view.ViewCatalogTests; +import org.apache.polaris.service.it.test.PolarisRestCatalogViewAzureIntegrationTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; + +@QuarkusIntegrationTest +public class QuarkusRestCatalogViewAzureIT + extends PolarisRestCatalogViewAzureIntegrationTest { + + @BeforeEach + public void setUpTempDir(@TempDir Path tempDir) throws Exception { + // see https://github.com/quarkusio/quarkus/issues/13261 + Field field = ViewCatalogTests.class.getDeclaredField("tempDir"); + field.setAccessible(true); + field.set(this, tempDir); + } +} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewFileIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewFileIT.java new file mode 100644 index 000000000..735973d8e --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewFileIT.java @@ -0,0 +1,40 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import java.lang.reflect.Field; +import java.nio.file.Path; +import org.apache.iceberg.view.ViewCatalogTests; +import org.apache.polaris.service.it.test.PolarisRestCatalogViewFileIntegrationTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; + +@QuarkusIntegrationTest +public class QuarkusRestCatalogViewFileIT + extends PolarisRestCatalogViewFileIntegrationTest { + + @BeforeEach + public void setUpTempDir(@TempDir Path tempDir) throws Exception { + // see https://github.com/quarkusio/quarkus/issues/13261 + Field field = ViewCatalogTests.class.getDeclaredField("tempDir"); + field.setAccessible(true); + field.set(this, tempDir); + } +} diff --git a/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewGcpIT.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewGcpIT.java new file mode 100644 index 000000000..9fdc69421 --- /dev/null +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewGcpIT.java @@ -0,0 +1,40 @@ +/* + * 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.service.quarkus.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import java.lang.reflect.Field; +import java.nio.file.Path; +import org.apache.iceberg.view.ViewCatalogTests; +import org.apache.polaris.service.it.test.PolarisRestCatalogViewGcpIntegrationTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; + +@QuarkusIntegrationTest +public class QuarkusRestCatalogViewGcpIT + extends PolarisRestCatalogViewGcpIntegrationTest { + + @BeforeEach + public void setUpTempDir(@TempDir Path tempDir) throws Exception { + // see https://github.com/quarkusio/quarkus/issues/13261 + Field field = ViewCatalogTests.class.getDeclaredField("tempDir"); + field.setAccessible(true); + field.set(this, tempDir); + } +} diff --git a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIntegrationTest.java b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIT.java similarity index 86% rename from quarkus/service/src/test/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIntegrationTest.java rename to quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIT.java index 9a25c5fe8..0c5ce7c8a 100644 --- a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIntegrationTest.java +++ b/quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusSparkIT.java @@ -18,8 +18,8 @@ */ package org.apache.polaris.service.quarkus.it; -import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; import org.apache.polaris.service.it.test.PolarisSparkIntegrationTest; -@QuarkusTest -public class QuarkusSparkIntegrationTest extends PolarisSparkIntegrationTest {} +@QuarkusIntegrationTest +public class QuarkusSparkIT extends PolarisSparkIntegrationTest {} diff --git a/quarkus/service/src/intTest/resources/META-INF/services/org.apache.polaris.service.it.ext.PolarisServerManager b/quarkus/service/src/intTest/resources/META-INF/services/org.apache.polaris.service.it.ext.PolarisServerManager new file mode 100644 index 000000000..a8615d99d --- /dev/null +++ b/quarkus/service/src/intTest/resources/META-INF/services/org.apache.polaris.service.it.ext.PolarisServerManager @@ -0,0 +1,20 @@ +# +# 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. +# + +org.apache.polaris.service.quarkus.it.QuarkusServerManager \ No newline at end of file diff --git a/quarkus/service/src/main/resources/application.properties b/quarkus/service/src/main/resources/application.properties index 0915eb3f7..1d7eca9bf 100644 --- a/quarkus/service/src/main/resources/application.properties +++ b/quarkus/service/src/main/resources/application.properties @@ -72,6 +72,8 @@ quarkus.otel.sdk.disabled=false # quarkus.otel.traces.sampler=parentbased_always_on # quarkus.otel.traces.sampler.arg=1.0d +quarkus.test.integration-test-profile=test + polaris.realm-context.type=default polaris.realm-context.realms=realm1,realm2,realm3 polaris.realm-context.header-name=Polaris-Realm diff --git a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/it/QuarkusServerManager.java b/quarkus/service/src/testFixtures/java/org/apache/polaris/service/quarkus/it/QuarkusServerManager.java similarity index 100% rename from quarkus/service/src/test/java/org/apache/polaris/service/quarkus/it/QuarkusServerManager.java rename to quarkus/service/src/testFixtures/java/org/apache/polaris/service/quarkus/it/QuarkusServerManager.java