Server: use awaitility in quarkus tests

This commit is contained in:
2024-11-29 15:34:06 +01:00
parent 28318fd004
commit c4fd46d9b1
3 changed files with 22 additions and 8 deletions

View File

@@ -54,6 +54,12 @@
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>

View File

@@ -18,6 +18,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.usatiuk</groupId>
<artifactId>autoprotomap</artifactId>

View File

@@ -17,8 +17,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static org.awaitility.Awaitility.await;
class Profiles {
public static class DhfsFileServiceSimpleTestProfile implements QuarkusTestProfile {
@Override
@@ -228,14 +231,14 @@ public class DhfsFileServiceSimpleTestImpl {
Assertions.assertArrayEquals(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
fileService.read(fileService.open("/moveOverTest2").get(), 0, 10).get().toByteArray());
Thread.sleep(1000);
try {
chunkObj.runReadLocked(JObjectManager.ResolutionStrategy.LOCAL_ONLY, (m, d) -> {
Assertions.assertFalse(m.getReferrers().contains(uuid));
return null;
});
} catch (DeletedObjectAccessException ignored) {}
await().atMost(5, TimeUnit.SECONDS).until(() -> {
try {
return chunkObj.runReadLocked(JObjectManager.ResolutionStrategy.LOCAL_ONLY,
(m, d) -> !m.getReferrers().contains(uuid));
} catch (DeletedObjectAccessException ignored) {
return true;
}
});
}
@Test