Skip to content

Commit

Permalink
test(backup/s3): don't fail test if localstack takes longer to delete
Browse files Browse the repository at this point in the history
(cherry picked from commit 18f4113)
  • Loading branch information
lenaschoenburg committed Feb 1, 2023
1 parent ffd906c commit 080dc4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions backup-stores/s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
<artifactId>aws-java-sdk-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.time.Instant;
import java.util.stream.Stream;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;
import software.amazon.awssdk.core.async.AsyncRequestBody;
Expand Down Expand Up @@ -163,14 +164,22 @@ default void allBackupObjectsAreDeleted(final Backup backup) {
getStore().delete(backup.id()).join();

// then
final var listed =
getClient()
.listObjectsV2(
req ->
req.bucket(getConfig().bucketName())
.prefix(S3BackupStore.objectPrefix(backup.id())))
.join();
Assertions.assertThat(listed.contents()).isEmpty();

// Retry a couple of times because LocalStack takes a moment to actually delete every object.
Awaitility.await("Finds no objects after deleting")
.pollInterval(Duration.ofSeconds(1))
.atMost(Duration.ofSeconds(30))
.untilAsserted(
() -> {
final var listed =
getClient()
.listObjectsV2(
req ->
req.bucket(getConfig().bucketName())
.prefix(S3BackupStore.objectPrefix(backup.id())))
.join();
Assertions.assertThat(listed.contents()).isEmpty();
});
}

@ParameterizedTest
Expand Down

0 comments on commit 080dc4e

Please sign in to comment.