From a968d561e0604f1217c0b781da04779d7c348b89 Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Thu, 12 Oct 2023 11:05:05 +0200 Subject: [PATCH] delete persistence files from within a container --- .../kafka/QuestDBSinkConnectorEmbeddedTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/connector/src/test/java/io/questdb/kafka/QuestDBSinkConnectorEmbeddedTest.java b/connector/src/test/java/io/questdb/kafka/QuestDBSinkConnectorEmbeddedTest.java index 19f07d4..e5c6b64 100644 --- a/connector/src/test/java/io/questdb/kafka/QuestDBSinkConnectorEmbeddedTest.java +++ b/connector/src/test/java/io/questdb/kafka/QuestDBSinkConnectorEmbeddedTest.java @@ -63,6 +63,20 @@ public static void createContainer() { @AfterAll public static void stopContainer() { questDBContainer.stop(); + deleteFromContainer(questDBDirectory()); + } + + private static void deleteFromContainer(String directory) { + GenericContainer cleanup = new GenericContainer<>("alpine:3.18.4") + .withCommand("rm -rf /var/lib/delete") + .withFileSystemBind(directory, "/var/lib/delete") + .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("cleanup"))); + cleanup.start(); + cleanup.stop(); + } + + private static String questDBDirectory() { + return dbRoot.resolve("questdb").toAbsolutePath().toString(); } private static GenericContainer questDBContainer; @@ -79,8 +93,7 @@ private static GenericContainer newQuestDbConnector() { } else { selfGenericContainer.addExposedPort(QuestDBUtils.QUESTDB_ILP_PORT); } - String dbRootString = dbRoot.toAbsolutePath().toString(); - selfGenericContainer = selfGenericContainer.withFileSystemBind(dbRootString, "/var/lib/questdb"); + selfGenericContainer = selfGenericContainer.withFileSystemBind(questDBDirectory(), "/var/lib/questdb"); if (DUMP_QUESTDB_CONTAINER_LOGS) { selfGenericContainer = selfGenericContainer.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("questdb"))); }