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

Introduce "real" integration tests #778

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 55 additions & 0 deletions build-logic/src/main/kotlin/polaris-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,49 @@ testing {
}
}
}

register<JvmTestSuite>("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")) }
}
}
}
}

Expand Down Expand Up @@ -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"))
}
41 changes: 34 additions & 7 deletions quarkus/service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -147,6 +161,19 @@ tasks.named<Test>("test").configure {
maxParallelForks = 4
}

tasks.named<Test>("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`.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
@@ -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 {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: if tests can work with the same server, it might be an option to rung them via a JUnit5 "suite". This way we can have only one class that references the package of tests from polaris-test and also leverage JUnit5 parallelism as opposed to Gradle test parallelism.

I did not do that under DW only because it was hard to share DW servers between test threads. Now, it looks like all tests are segregated by in entity names and servers are in a separate JVM... so it might work :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I haven't used JUnit5 suites. Mind if we do your suggestion in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely (it's one additional dependency for the "suite" engine, by the way)

Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this test from the test directory but left the others, because this one is a bit more heavy-weight.

Loading
Loading