Skip to content

Commit

Permalink
verify dropwizard application log (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored Jan 2, 2025
1 parent 2414c8d commit 82d7bdf
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation;
import jakarta.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.iceberg.BaseTable;
Expand Down Expand Up @@ -94,6 +96,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
Expand All @@ -105,6 +108,10 @@
SnowmanCredentialsExtension.class
})
public class PolarisApplicationIntegrationTest {
@TempDir private static Path tempDir;
private static final Supplier<String> CURRENT_LOG =
() -> tempDir.resolve("application.log").toString();

private static final Logger LOGGER =
LoggerFactory.getLogger(PolarisApplicationIntegrationTest.class);

Expand All @@ -117,7 +124,9 @@ public class PolarisApplicationIntegrationTest {
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
"server.adminConnectors[0].port", "0"), // Bind to random port to support parallelism
ConfigOverride.config("logging.appenders[1].type", "file"),
ConfigOverride.config("logging.appenders[1].currentLogFilename", CURRENT_LOG));

private static String userToken;
private static SnowmanCredentialsExtension.SnowmanCredentials snowmanCredentials;
Expand All @@ -132,6 +141,11 @@ public static void setup(
throws IOException {
realm = polarisRealm;

assertThat(new File(CURRENT_LOG.get()))
.exists()
.content()
.contains("PolarisApplication: Server started successfully");

testDir = Path.of("build/test_data/iceberg/" + realm);
FileUtils.deleteQuietly(testDir.toFile());
Files.createDirectories(testDir);
Expand Down Expand Up @@ -165,6 +179,8 @@ public static void setup(
assertThat(assignPrResponse)
.returns(Response.Status.CREATED.getStatusCode(), Response::getStatus);
}

assertZeroErrorsInApplicationLog();
}

@AfterAll
Expand All @@ -181,6 +197,14 @@ public static void deletePrincipalRole() {
.close();
}

private static void assertZeroErrorsInApplicationLog() {
assertThat(new File(CURRENT_LOG.get()))
.exists()
.content()
.hasSizeGreaterThan(0)
.doesNotContain("ERROR", "FATAL");
}

/**
* Create a new catalog for each test case. Assign the snowman catalog-admin principal role the
* admin role of the new catalog.
Expand Down

0 comments on commit 82d7bdf

Please sign in to comment.