Class PostgreSqlJsonContainerIT
java.lang.Object
com.github.isuhorukov.log.watcher.PostgreSqlJsonContainerIT
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) de.dm.infrastructure.logcapture.LogCapture
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
applicationProcessLog
(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer, Path pgData) static void
assertExpectedLogEvents
(de.dm.infrastructure.logcapture.LogCapture logCapture1) static org.testcontainers.containers.PostgreSQLContainer
<?> configurePostgresContainer
(Path pgData) static Path
createPgDataDirectory
(Path tempDir) (package private) static void
executeSomeTestQueriesInPostgreSql
(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer) (package private) static PostgreSqlJson
getPostgreSqlJson
(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer, Path pgData) (package private) static void
shutdownExecutor
(ExecutorService executorService) startLogWatcher
(ExecutorService executorService, PostgreSqlJson postgreSqlJson) static void
startPostgreSqlContainer
(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer) (package private) void
testWatchPostgreSqlLogsWithContainer
(Path tempDir) Tests the functionality of watching PostgreSQL logs using a Docker container.(package private) static void
waitEventsAndCloseLogWatcher
(PostgreSqlJson postgreSqlJson, Future<Integer> resultCode)
-
Field Details
-
logCapture
@RegisterExtension de.dm.infrastructure.logcapture.LogCapture logCapture
-
-
Constructor Details
-
PostgreSqlJsonContainerIT
public PostgreSqlJsonContainerIT()
-
-
Method Details
-
testWatchPostgreSqlLogsWithContainer
Tests the functionality of watching PostgreSQL logs using a Docker container.This test sets up a temporary directory for Postgres data and log files, configures a PostgreSQL Docker container to log in JSON format, and verifies that the application correctly processes these logs.
The test uses a
PostgreSQLContainer
from the Testcontainers library to run a PostgreSQL instance with specific logging configurations. It evaluates whether thePostgreSqlJson.watchPostgreSqlLogs()
method can detect and process log entries in the specified directory.- Parameters:
tempDir
- a temporary directory provided by JUnit for test file storage.
-
applicationProcessLog
@Step("application should detect and process log entries from the PostgreSQL logs") public static void applicationProcessLog(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer, Path pgData) throws SQLException, InterruptedException, IOException -
createPgDataDirectory
@Step("a temporary directory for Postgres data and log files") public static Path createPgDataDirectory(Path tempDir) throws IOException - Throws:
IOException
-
configurePostgresContainer
@Step("configure PostgreSQL container") public static org.testcontainers.containers.PostgreSQLContainer<?> configurePostgresContainer(Path pgData) -
shutdownExecutor
- Throws:
InterruptedException
-
waitEventsAndCloseLogWatcher
static void waitEventsAndCloseLogWatcher(PostgreSqlJson postgreSqlJson, Future<Integer> resultCode) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
startLogWatcher
@NotNull static @NotNull Future<Integer> startLogWatcher(ExecutorService executorService, PostgreSqlJson postgreSqlJson) -
startPostgreSqlContainer
@Step("I start the PostgreSQL container with specific logging configurations") public static void startPostgreSqlContainer(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
getPostgreSqlJson
static PostgreSqlJson getPostgreSqlJson(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer, Path pgData) -
executeSomeTestQueriesInPostgreSql
static void executeSomeTestQueriesInPostgreSql(org.testcontainers.containers.PostgreSQLContainer<?> postgresContainer) throws SQLException - Throws:
SQLException
-
assertExpectedLogEvents
@Step("logs are generated in the specified directory and watched & processed by postgres_log_parser") public static void assertExpectedLogEvents(de.dm.infrastructure.logcapture.LogCapture logCapture1)
-