Skip to content

Commit c56077a

Browse files
committed
Move integration tests to polaris-server
`@QuarkusIntegrationTest` uses the regular server build with only non-test dependencies. Therefore, those tests naturally belong into the `server` module. This change is as a prerequisite for apache#3252 to allow the `polaris-runtime-service` module to avoid having Polaris extensions as runtime dependencies. Extensions will be runtime dependencies only in the `polaris-server` module.
1 parent 2929a99 commit c56077a

26 files changed

+138
-99
lines changed

runtime/server/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,28 @@ following command:
6464
-Dquarkus.container-image.group=apache \
6565
-Dquarkus.container-image.name=polaris-local
6666
```
67+
68+
## Integration tests
69+
70+
Integration tests from the `:polaris-tests` module can be run against a local Polaris Quarkus instance
71+
for each supported cloud storage. Set the appropriate environment variables for your target cloud,
72+
then run the tests as shown below.
73+
74+
For S3:
75+
```shell
76+
export INTEGRATION_TEST_S3_PATH="s3://bucket/subpath"
77+
export INTEGRATION_TEST_S3_ROLE_ARN="your-role-arn"
78+
./gradlew :polaris-server:cloudTest
79+
```
80+
For ADLS:
81+
```shell
82+
export INTEGRATION_TEST_AZURE_PATH="abfss://bucket/subpath"
83+
export INTEGRATION_TEST_AZURE_TENANT_ID="your-tenant-id"
84+
./gradlew :polaris-server:cloudTest
85+
```
86+
For GCS:
87+
```shell
88+
export INTEGRATION_TEST_GCS_PATH="gs://bucket/subpath"
89+
export INTEGRATION_TEST_GCS_SERVICE_ACCOUNT="your-service-account"
90+
./gradlew :polaris-server:cloudTest
91+
```

runtime/server/build.gradle.kts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ dependencies {
5353
// enforce the Quarkus _platform_ here, to get a consistent and validated set of dependencies
5454
implementation(enforcedPlatform(libs.quarkus.bom))
5555
implementation("io.quarkus:quarkus-container-image-docker")
56+
57+
testImplementation("io.quarkus:quarkus-junit5")
58+
59+
testImplementation(testFixtures(project(":polaris-runtime-service")))
60+
testImplementation(project(":polaris-runtime-test-common"))
61+
testImplementation(project(":polaris-core"))
62+
testImplementation(project(":polaris-api-management-model"))
63+
testImplementation(project(":polaris-minio-testcontainer"))
64+
65+
testImplementation(project(":polaris-tests")) {
66+
// exclude all spark dependencies
67+
exclude(group = "org.apache.iceberg", module = "iceberg-spark-3.5_2.12")
68+
exclude(group = "org.apache.iceberg", module = "iceberg-spark-extensions-3.5_2.12")
69+
exclude(group = "org.apache.spark", module = "spark-sql_2.12")
70+
}
71+
72+
testImplementation(platform(libs.iceberg.bom))
73+
testImplementation("org.apache.iceberg:iceberg-api")
74+
testImplementation("org.apache.iceberg:iceberg-core")
75+
testImplementation("org.apache.iceberg:iceberg-aws")
76+
testImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}:tests")
77+
testImplementation("org.apache.iceberg:iceberg-core:${libs.versions.iceberg.get()}:tests")
78+
79+
// This dependency brings in RESTEasy Classic, which conflicts with Quarkus RESTEasy Reactive;
80+
// it must not be present during Quarkus augmentation otherwise Quarkus tests won't start.
81+
intTestRuntimeOnly(libs.keycloak.admin.client)
5682
}
5783

5884
quarkus {
@@ -100,3 +126,70 @@ artifacts {
100126
}
101127
add("distributionElements", layout.buildDirectory.dir("quarkus-app")) { builtBy("quarkusBuild") }
102128
}
129+
130+
tasks.withType(Test::class.java).configureEach {
131+
if (System.getenv("AWS_REGION") == null) {
132+
environment("AWS_REGION", "us-west-2")
133+
}
134+
// Note: the test secrets are referenced in
135+
// org.apache.polaris.service.it.ServerManager
136+
environment("POLARIS_BOOTSTRAP_CREDENTIALS", "POLARIS,test-admin,test-secret")
137+
jvmArgs("--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED")
138+
// Need to allow a java security manager after Java 21, for Subject.getSubject to work
139+
// "getSubject is supported only if a security manager is allowed".
140+
systemProperty("java.security.manager", "allow")
141+
}
142+
143+
listOf("intTest", "cloudTest")
144+
.map { tasks.named<Test>(it) }
145+
.forEach {
146+
it.configure {
147+
maxParallelForks = 1
148+
149+
val logsDir = project.layout.buildDirectory.get().asFile.resolve("logs")
150+
151+
// JVM arguments provider does not interfere with Gradle's cache keys
152+
jvmArgumentProviders.add(
153+
CommandLineArgumentProvider {
154+
// Same issue as above: allow a java security manager after Java 21
155+
// (this setting is for the application under test, while the setting above is for test
156+
// code).
157+
val securityManagerAllow = "-Djava.security.manager=allow"
158+
159+
val args = mutableListOf<String>()
160+
161+
// Example: to attach a debugger to the spawned JVM running Quarkus, add
162+
// -Dquarkus.test.arg-line=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
163+
// to your test configuration.
164+
val explicitQuarkusTestArgLine = System.getProperty("quarkus.test.arg-line")
165+
var quarkusTestArgLine =
166+
if (explicitQuarkusTestArgLine != null)
167+
"$explicitQuarkusTestArgLine $securityManagerAllow"
168+
else securityManagerAllow
169+
170+
args.add("-Dquarkus.test.arg-line=$quarkusTestArgLine")
171+
// This property is not honored in a per-profile application.properties file,
172+
// so we need to set it here.
173+
args.add("-Dquarkus.log.file.path=${logsDir.resolve("polaris.log").absolutePath}")
174+
175+
// Add `quarkus.*` system properties, other than the ones explicitly set above
176+
System.getProperties()
177+
.filter {
178+
it.key.toString().startsWith("quarkus.") &&
179+
!"quarkus.test.arg-line".equals(it.key) &&
180+
!"quarkus.log.file.path".equals(it.key)
181+
}
182+
.forEach { args.add("${it.key}=${it.value}") }
183+
184+
args
185+
}
186+
)
187+
// delete files from previous runs
188+
doFirst {
189+
// delete log files written by Polaris
190+
logsDir.deleteRecursively()
191+
// delete quarkus.log file (captured Polaris stdout/stderr)
192+
project.layout.buildDirectory.get().asFile.resolve("quarkus.log").delete()
193+
}
194+
}
195+
}

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogAdlsIT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogAdlsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogAdlsIntegrationTestBase;

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogGcsIT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogGcsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogGcsIntegrationTestBase;

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogS3IT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogS3IT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogS3IntegrationTestBase;

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogViewAdlsIT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogViewAdlsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogViewAdlsIntegrationTestBase;

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogViewGcsIT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogViewGcsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogViewGcsIntegrationTestBase;

runtime/service/src/cloudTest/java/org/apache/polaris/service/it/RestCatalogViewS3IT.java renamed to runtime/server/src/cloudTest/java/org/apache/polaris/server/it/RestCatalogViewS3IT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisRestCatalogViewS3IntegrationTestBase;

runtime/service/src/cloudTest/resources/META-INF/services/org.apache.polaris.service.it.ext.PolarisServerManager renamed to runtime/server/src/cloudTest/resources/META-INF/services/org.apache.polaris.service.it.ext.PolarisServerManager

File renamed without changes.

runtime/service/src/intTest/java/org/apache/polaris/service/it/ApplicationIT.java renamed to runtime/server/src/intTest/java/org/apache/polaris/server/it/ApplicationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.polaris.service.it;
19+
package org.apache.polaris.server.it;
2020

2121
import io.quarkus.test.junit.QuarkusIntegrationTest;
2222
import org.apache.polaris.service.it.test.PolarisApplicationIntegrationTest;

0 commit comments

Comments
 (0)