From 83e0f6eb0aba6285935b3d882d5b8de1c70d8a4f Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sun, 13 Apr 2025 20:05:51 +0200 Subject: [PATCH] Server: fix not being able to delete temp dir in tests --- .github/workflows/server.yml | 2 +- .../test/java/com/usatiuk/dhfs/integration/KillIT.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 780e4701..9ed90e31 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -49,7 +49,7 @@ jobs: cache: maven - name: Test with Maven - run: cd dhfs-parent && mvn -T $(nproc) --batch-mode --update-snapshots package verify + run: cd dhfs-parent && TESTCONTAINERS_USER="$(id -u):$(id -g)" mvn -T $(nproc) --batch-mode --update-snapshots package verify # - name: Build with Maven # run: cd dhfs-parent && mvn --batch-mode --update-snapshots package # -Dquarkus.log.category.\"com.usatiuk.dhfs\".min-level=DEBUG diff --git a/dhfs-parent/dhfs-app/src/test/java/com/usatiuk/dhfs/integration/KillIT.java b/dhfs-parent/dhfs-app/src/test/java/com/usatiuk/dhfs/integration/KillIT.java index 2236d6d6..3a4994f5 100644 --- a/dhfs-parent/dhfs-app/src/test/java/com/usatiuk/dhfs/integration/KillIT.java +++ b/dhfs-parent/dhfs-app/src/test/java/com/usatiuk/dhfs/integration/KillIT.java @@ -43,16 +43,25 @@ public class KillIT { @BeforeEach void setup(TestInfo testInfo) throws IOException, InterruptedException, TimeoutException { Network network = Network.newNetwork(); + + String testcontainersUser = System.getenv("TESTCONTAINERS_USER"); + container1 = new GenericContainer<>(DhfsImage.getInstance()) .withPrivilegedMode(true) .withCreateContainerCmdModifier(cmd -> Objects.requireNonNull(cmd.getHostConfig()).withDevices(Device.parse("/dev/fuse"))) .waitingFor(Wait.forLogMessage(".*Listening.*", 1).withStartupTimeout(Duration.ofSeconds(60))).withNetwork(network) .withFileSystemBind(data1.getAbsolutePath(), "/root/dhfs_default/data"); + if (testcontainersUser != null) { + container1.withCreateContainerCmdModifier(cmd -> cmd.withUser(testcontainersUser)); + } container2 = new GenericContainer<>(DhfsImage.getInstance()) .withPrivilegedMode(true) .withCreateContainerCmdModifier(cmd -> Objects.requireNonNull(cmd.getHostConfig()).withDevices(Device.parse("/dev/fuse"))) .waitingFor(Wait.forLogMessage(".*Listening.*", 1).withStartupTimeout(Duration.ofSeconds(60))).withNetwork(network) .withFileSystemBind(data2.getAbsolutePath(), "/root/dhfs_default/data"); + if (testcontainersUser != null) { + container2.withCreateContainerCmdModifier(cmd -> cmd.withUser(testcontainersUser)); + } Stream.of(container1, container2).parallel().forEach(GenericContainer::start);