@@ -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
5884quarkus {
@@ -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+ }
0 commit comments