【发布时间】:2021-12-02 03:02:40
【问题描述】:
当我将 quarkus 从 1.13.2 升级到 2.X.X 时,我的集成测试中出现“无法加载凭据”错误。
LambdaIntegTest.class :
@Testcontainers
@QuarkusTest
@QuarkusTestResource(ContainerRessource.class)
class LambdaIntegTest {
@Test
void test() throws Exception {
String s3Event = oneS3event();
String out = LambdaClient.invokeJson(String.class, s3Event);
assertThat(out).isEqualTo("Success");
}
ContainerRessource.class:
public class ContainerRessource implements QuarkusTestResourceLifecycleManager {
private static final LocalStackContainer LOCAL_STACK_CONTAINER;
static {
DockerImageName localstackImage = DockerImageName.parse("localstack/localstack:0.11.3");
LOCAL_STACK_CONTAINER = new LocalStackContainer(localstackImage)
.withServices(S3);
}
@Override
public Map<String, String> start() {
LOCAL_STACK_CONTAINER.start();
innitS3();
return Map.ofEntries(
entry("aws.region", LOCAL_STACK_CONTAINER.getRegion()),
entry("s3.url.override", LOCAL_STACK_CONTAINER.getEndpointOverride(S3).toString()),
entry("aws.accessKeyId", LOCAL_STACK_CONTAINER.getAccessKey()),
entry("aws.secretAccessKey", LOCAL_STACK_CONTAINER.getSecretKey()));
}
@Override
public void stop() {
LOCAL_STACK_CONTAINER.stop();
}
}
我尝试将凭据放入 application.properties,但我遇到了同样的错误。 我在 Quarkus 1.13.2 上的测试工作
我还有一个原生测试:
@QuarkusIntegrationTest
public class LambdaNativeTest extends LambdaIntegTest {
}
它奏效了。
【问题讨论】:
标签: java amazon-s3 quarkus testcontainers localstack