Skip to content

Commit

Permalink
delete persistence files from within a container
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrinot committed Oct 12, 2023
1 parent 17519b0 commit a968d56
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")));
}
Expand Down

0 comments on commit a968d56

Please sign in to comment.