Update localstack test container to 4.x

This commit is contained in:
Chris Eager
2025-07-22 18:01:20 -05:00
committed by Chris Eager
parent 5f77d7f582
commit 83d19ac8ed
2 changed files with 11 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ package org.whispersystems.textsecuregcm.storage;
import static org.testcontainers.containers.localstack.LocalStackContainer.Service.S3;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
@@ -31,9 +32,16 @@ import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
public class S3LocalStackExtension implements BeforeEachCallback, AfterEachCallback, BeforeAllCallback,
AfterAllCallback {
private final static DockerImageName LOCAL_STACK_IMAGE = DockerImageName.parse(TestcontainersImages.getLocalStack());
private final static DockerImageName LOCAL_STACK_IMAGE = DockerImageName.parse(TestcontainersImages.getLocalStack())
.asCompatibleSubstituteFor(
// Workaround: DockerImageName#parse does not correctly handle registry/image:tag@sha256:hash,
// and so it doesn't consider the image to be "localstack/localstack"
StringUtils.substringBefore(
StringUtils.substringBefore(TestcontainersImages.getLocalStack(), "@"),
":"));
private static LocalStackContainer LOCAL_STACK = new LocalStackContainer(LOCAL_STACK_IMAGE).withServices(S3);
private static LocalStackContainer LOCAL_STACK = new LocalStackContainer(LOCAL_STACK_IMAGE).withServices(S3)
.withExposedPorts(4566);
private final String bucketName;
private S3AsyncClient s3Client;