Skip to content
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
12 changes: 7 additions & 5 deletions build-logic/src/main/kotlin/polaris-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ testing {
dependencies {
implementation(project())
implementation(testFixtures(project()))
runtimeOnly(
libs.findLibrary("logback-classic").orElseThrow {
GradleException("logback-classic not declared in libs.versions.toml")
}
)
if (!plugins.hasPlugin("io.quarkus")) {
implementation(
libs.findLibrary("logback-classic").orElseThrow {
GradleException("logback-classic not declared in libs.versions.toml")
}
)
}
implementation(
libs.findLibrary("assertj-core").orElseThrow {
GradleException("assertj-core not declared in libs.versions.toml")
Expand Down
25 changes: 25 additions & 0 deletions build-logic/src/main/kotlin/polaris-runtime.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ testing {
suites {
withType<JvmTestSuite> {
targets.all {
testTask.configure {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
// Enable automatic extension detection to execute GradleDuplicateLoggingWorkaround
// automatically.
// See https://github.com/quarkusio/quarkus/issues/22844
systemProperty("junit.jupiter.extensions.autodetection.enabled", "true")
}

if (testTask.name != "test") {
testTask.configure {
// For Quarkus...
Expand All @@ -47,6 +55,23 @@ testing {
}
}

dependencies {
// All Quarkus projects should use JBoss LogManager with SLF4J, instead of Logback
implementation("org.jboss.slf4j:slf4j-jboss-logmanager")
}

configurations.all {
// Validate that Logback dependencies are not used in Quarkus modules.
dependencies.configureEach {
if (group == "ch.qos.logback") {
throw GradleException(
"Logback dependencies are not allowed in Quarkus modules. " +
"Found $group:$name in ${project.name}."
)
}
}
}

// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@
under the License.

-->
<configuration>
<configuration debug="false">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="${log.level.console:-INFO}">
<root level="${test.log.level:-ERROR}">
<appender-ref ref="console"/>
</root>

<!--
Prevent the 'The Agroal dependency is present but no JDBC datasources have been defined.' build-time warning.
See https://github.com/quarkusio/quarkus/blob/2fbc20f445fad43aaf4f3f984b9ac8319c7c7f0a/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java#L111
THIS IS A TECHNICAL NECESSITY, because of the
-->
<logger name="io.quarkus.agroal.deployment" level="ERROR"/>
</configuration>
5 changes: 3 additions & 2 deletions plugins/spark/v3.5/integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
exclude(group = "org.scala-lang", module = "scala-reflect")
}

implementation(project(":polaris-runtime-defaults"))
implementation(project(":polaris-runtime-service"))

testImplementation(
Expand All @@ -52,6 +53,8 @@ dependencies {

testImplementation(project(":polaris-api-management-model"))

testImplementation(project(":polaris-runtime-test-common"))

testImplementation("org.apache.spark:spark-sql_${scalaVersion}:${spark35Version}") {
// exclude log4j dependencies. Explicit dependencies for the log4j libraries are
// enforced below to ensure the version compatibility
Expand All @@ -63,7 +66,6 @@ dependencies {
// enforce the usage of log4j 2.24.3. This is for the log4j-api compatibility
// of spark-sql dependency
testRuntimeOnly("org.apache.logging.log4j:log4j-core:2.25.1")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl:2.25.1")

testImplementation("io.delta:delta-spark_${scalaVersion}:3.3.1")

Expand Down Expand Up @@ -95,7 +97,6 @@ dependencies {

tasks.named<Test>("intTest").configure {
maxParallelForks = 1
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
if (System.getenv("AWS_REGION") == null) {
environment("AWS_REGION", "us-west-2")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
Expand All @@ -19,20 +19,14 @@
under the License.

-->
<!--
Spark by default set the logging at DEBUG level, which dumps a lot of code details in
the Intelij console, which impacts the IDE performance significantly when running the
tests. This configuration allows only log back the ERROR logs for the IDE, you can comment
out the configuration if you would like ot see all spark debug log during the run.
-->
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level - %msg%n</pattern>
<configuration debug="false">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="ERROR">
<appender-ref ref="CONSOLE"/>
<root level="${test.log.level:-ERROR}">
<appender-ref ref="console"/>
</root>
</configuration>
2 changes: 0 additions & 2 deletions runtime/admin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dependencies {
implementation("io.quarkus:quarkus-container-image-docker")

implementation(project(":polaris-runtime-common"))
implementation("org.jboss.slf4j:slf4j-jboss-logmanager")

testImplementation(project(":polaris-runtime-test-common"))
testFixturesApi(project(":polaris-core"))
Expand Down Expand Up @@ -92,7 +91,6 @@ artifacts {
tasks.withType(Test::class.java).configureEach {
maxParallelForks = 4
forkEvery = 1
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
}

tasks.named<Test>("test").configure {
Expand Down
3 changes: 1 addition & 2 deletions runtime/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/

plugins {
alias(libs.plugins.quarkus)
alias(libs.plugins.jandex)
id("polaris-runtime")
id("polaris-server")
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions runtime/defaults/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/

plugins {
alias(libs.plugins.quarkus)
alias(libs.plugins.jandex)
id("polaris-runtime")
id("polaris-server")
}

dependencies {
Expand Down
13 changes: 10 additions & 3 deletions runtime/defaults/src/main/resources/application-it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
# under the License.
#

# Configuration common to ALL integration tests (executed with "it" profile).
# Note: Quarkus integration tests cannot use QuarkusTestProfile
# Configuration common to ALL integration tests (executed with "it" profile – Gradle "intTest" tasks).
# Note: Quarkus integration tests cannot use QuarkusTestProfile.

# Note about logging during integration tests:
# - Logging for test code is configured in the `application-test.properties` file (!!).
# By default, it is set to `ERROR` level.
# - Logging for application code is configured in the main `application.properties` file.
# By default, it is set to `INFO` level.
# Configuring logging levels or appenders in this file IS INEFFECTIVE!

quarkus.http.limits.max-body-size=1000000
quarkus.http.port=0

quarkus.management.port=0

# polaris.persistence.type=eclipse-link
# polaris.persistence.type=jdbc
# polaris.persistence.type=in-memory-atomic
polaris.persistence.type=in-memory

Expand Down
24 changes: 20 additions & 4 deletions runtime/defaults/src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,37 @@
# under the License.
#

# Configuration common to ALL unit tests (executed with "test" profile).
# Configuration common to ALL unit tests (executed with "test" profile – Gradle "test" tasks).
# Per-test specific configuration should use QuarkusTestProfile

quarkus.log.file.enable=false
quarkus.datasource.devservices.enabled=false

quarkus.log.level=ERROR
quarkus.log.file.enable=false
quarkus.console.color=true

# Useful loggers for debugging purposes.
# quarkus.log.category."org.apache.polaris".level=INFO
# quarkus.log.category."org.apache.iceberg".level=INFO
# quarkus.log.category."io.quarkus.http.access-log".level=INFO
# quarkus.log.category."org.apache.hc.client5.http".level=INFO

# Silence a few verbose loggers that are not useful for unit tests.
quarkus.log.category."org.apache.polaris.core.persistence.transactional.TransactionalMetaStoreManagerImpl".level=ERROR
quarkus.log.category."org.apache.iceberg.rest.auth.AuthManagers".level=ERROR
quarkus.log.category."org.apache.iceberg.rest.auth.OAuth2Manager".level=ERROR

# Prevent the 'Hibernate Validator does not support constraints on static methods yet.' warning log messages on
# code generated by the OpenAPI generator. The warning can only be silenced via a log level setting.
# See https://github.com/quarkusio/quarkus/blob/15f6b4426512c04a54e7a0bd87f894fabe068c07/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/MethodValidatedAnnotationsTransformer.java#L51-L53
# and how the 'LOGGER' is setup.
# and how the 'LOGGER' is set up.
quarkus.log.category."io.quarkus.hibernate.validator.deployment".level=ERROR

# Silence the FJP warning, nothing we can do about it.
# See https://github.com/quarkusio/quarkus/blob/15f6b4426512c04a54e7a0bd87f894fabe068c07/core/deployment/src/main/java/io/quarkus/runner/bootstrap/ForkJoinClassLoading.java#L41-L42
quarkus.log.category."io.quarkus.runner.bootstrap.ForkJoinClassLoading".level=FATAL

# Prevent the 'The Agroal dependency is present but no JDBC datasources have been defined.' build-time warning.
# See https://github.com/quarkusio/quarkus/blob/2fbc20f445fad43aaf4f3f984b9ac8319c7c7f0a/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java#L111
# THIS IS ALSO CONFIGURED IN polaris-runtime-service/src/test/resources/logback-test.xml
quarkus.log.category."io.quarkus.agroal.deployment".level=ERROR

9 changes: 6 additions & 3 deletions runtime/defaults/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ quarkus.log.file.path=./logs/polaris.log
quarkus.log.file.rotation.file-suffix=.yyyy-MM-dd.gz
quarkus.log.file.rotation.max-file-size=10M
quarkus.log.file.rotation.max-backup-index=14
quarkus.log.category."org.apache.polaris".level=INFO
quarkus.log.category."org.apache.iceberg.rest".level=INFO
quarkus.log.category."io.smallrye.config".level=INFO

# Useful loggers. Set "io.smallrye.config" to DEBUG to print the resolved configuration properties.
# quarkus.log.category."io.smallrye.config".level=INFO
# quarkus.log.category."org.apache.polaris".level=INFO
# quarkus.log.category."org.apache.iceberg.rest".level=INFO

quarkus.management.port=8182
quarkus.management.test-port=0
Expand All @@ -97,6 +99,7 @@ quarkus.otel.sdk.disabled=true
# quarkus.otel.traces.sampler=parentbased_always_on
# quarkus.otel.traces.sampler.arg=1.0d

# This setting is a build-time setting and MUST be specified in this file.
quarkus.test.integration-test-profile=it

quarkus.fault-tolerance.global.timeout.enabled=false
Expand Down
6 changes: 1 addition & 5 deletions runtime/service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ dependencies {
implementation(libs.guava)
implementation(libs.slf4j.api)

implementation("org.jboss.slf4j:slf4j-jboss-logmanager")

implementation(libs.hadoop.client.api)
implementation(libs.hadoop.client.runtime)

Expand Down Expand Up @@ -151,9 +149,8 @@ dependencies {
testImplementation(libs.threeten.extra)
testImplementation(libs.hawkular.agent.prometheus.scraper)

testImplementation(libs.logback.classic)

testImplementation(project(":polaris-runtime-test-common"))

testImplementation("io.quarkus:quarkus-junit5")
testImplementation(libs.awaitility)
testImplementation(platform(libs.testcontainers.bom))
Expand Down Expand Up @@ -197,7 +194,6 @@ tasks.named("javadoc") { dependsOn("jandex") }

tasks.withType(Test::class.java).configureEach {
forkEvery = 1
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
if (System.getenv("AWS_REGION") == null) {
environment("AWS_REGION", "us-west-2")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,17 @@ public class IcebergExceptionMapper implements ExceptionMapper<RuntimeException>
private static final Set<String> ACCESS_DENIED_HINTS =
Set.of("access denied", "not authorized", "forbidden");

public IcebergExceptionMapper() {}

@Override
public Response toResponse(RuntimeException runtimeException) {
LOGGER.info("Handling runtimeException {}", runtimeException.getMessage());
getLogger().info("Handling runtimeException {}", runtimeException.getMessage());

int responseCode = mapExceptionToResponseCode(runtimeException);
LOGGER
getLogger()
.atLevel(responseCode >= 500 ? Level.INFO : Level.DEBUG)
.log("Full RuntimeException", runtimeException);

if (responseCode == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
LOGGER.error("Unhandled exception returning INTERNAL_SERVER_ERROR", runtimeException);
getLogger().error("Unhandled exception returning INTERNAL_SERVER_ERROR", runtimeException);
}

ErrorResponse icebergErrorResponse =
Expand All @@ -113,7 +111,7 @@ public Response toResponse(RuntimeException runtimeException) {
.entity(icebergErrorResponse)
.type(MediaType.APPLICATION_JSON_TYPE)
.build();
LOGGER.debug("Mapped exception to errorResp: {}", errorResp);
getLogger().debug("Mapped exception to errorResp: {}", errorResp);
return errorResp;
}

Expand Down Expand Up @@ -262,4 +260,9 @@ static Optional<Integer> mapCloudExceptionToResponseCode(Throwable t) {

return Optional.of(Status.INTERNAL_SERVER_ERROR.getStatusCode());
}

@VisibleForTesting
Logger getLogger() {
return LOGGER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
import com.google.common.annotations.VisibleForTesting;
import jakarta.annotation.Nullable;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand All @@ -40,7 +41,7 @@

/** See Dropwizard's {@code io.dropwizard.jersey.jackson.JsonProcessingExceptionMapper} */
@Provider
public final class IcebergJsonProcessingExceptionMapper
public class IcebergJsonProcessingExceptionMapper
implements ExceptionMapper<JsonProcessingException> {

private static final Logger LOGGER =
Expand All @@ -60,7 +61,8 @@ public Response toResponse(JsonProcessingException exception) {
if (exception instanceof JsonGenerationException
|| exception instanceof InvalidDefinitionException) {
long id = ThreadLocalRandom.current().nextLong();
LOGGER.error(String.format(Locale.ROOT, "Error handling a request: %016x", id), exception);
getLogger()
.error(String.format(Locale.ROOT, "Error handling a request: %016x", id), exception);
String message =
String.format(
Locale.ROOT,
Expand All @@ -75,8 +77,8 @@ public Response toResponse(JsonProcessingException exception) {
/*
* Otherwise, it's those pesky users.
*/
LOGGER.info("Unable to process JSON: {}", exception.getMessage());
LOGGER.debug("Full JsonProcessingException", exception);
getLogger().info("Unable to process JSON: {}", exception.getMessage());
getLogger().debug("Full JsonProcessingException", exception);

String messagePrefix =
switch (exception) {
Expand All @@ -96,4 +98,9 @@ public Response toResponse(JsonProcessingException exception) {
.entity(icebergErrorResponse)
.build();
}

@VisibleForTesting
Logger getLogger() {
return LOGGER;
}
}
Loading