Skip to content

Commit

Permalink
Update localstack images in tests (#5783)
Browse files Browse the repository at this point in the history
`atlassian/pipelines-awscli` is deprecated and it recommends to use
`amazon/aws-cli`.
  • Loading branch information
eddumelendez committed Sep 16, 2022
1 parent 1f3a1f7 commit 9540652
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Expand Up @@ -26,7 +26,6 @@
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
Expand Down Expand Up @@ -153,12 +152,7 @@ public void sqsTestOverBridgeNetwork() {
String fooQueueUrl = queueResult.getQueueUrl();
assertThat(fooQueueUrl)
.as("Created queue has external hostname URL")
.contains(
"http://" +
DockerClientFactory.instance().dockerHostIpAddress() +
":" +
localstack.getMappedPort(LocalStackContainer.PORT)
);
.contains("http://" + localstack.getHost() + ":" + localstack.getMappedPort(LocalStackContainer.PORT));

sqs.sendMessage(fooQueueUrl, "test");
final long messageCount = sqs
Expand Down Expand Up @@ -265,14 +259,17 @@ public static class WithNetwork {
LocalstackTestImages.AWS_CLI_IMAGE
)
.withNetwork(network)
.withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint("top"))
.withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint("tail"))
.withCommand(" -f /dev/null")
.withEnv("AWS_ACCESS_KEY_ID", "accesskey")
.withEnv("AWS_SECRET_ACCESS_KEY", "secretkey")
.withEnv("AWS_REGION", "eu-west-1");

@Test
public void s3TestOverDockerNetwork() throws Exception {
runAwsCliAgainstDockerNetworkContainer("s3api create-bucket --bucket foo");
runAwsCliAgainstDockerNetworkContainer(
"s3api create-bucket --bucket foo --create-bucket-configuration LocationConstraint=eu-west-1"
);
runAwsCliAgainstDockerNetworkContainer("s3api list-buckets");
runAwsCliAgainstDockerNetworkContainer("s3 ls s3://foo");
}
Expand Down Expand Up @@ -313,7 +310,7 @@ public void cloudWatchLogsTestOverDockerNetwork() throws Exception {
private String runAwsCliAgainstDockerNetworkContainer(String command) throws Exception {
final String[] commandParts = String
.format(
"/usr/bin/aws --region eu-west-1 %s --endpoint-url http://localstack:%d --no-verify-ssl",
"/usr/local/bin/aws --region eu-west-1 %s --endpoint-url http://localstack:%d --no-verify-ssl",
command,
LocalStackContainer.PORT
)
Expand Down
Expand Up @@ -8,5 +8,5 @@ public interface LocalstackTestImages {
DockerImageName LOCALSTACK_0_10_IMAGE = LOCALSTACK_IMAGE.withTag("0.10.7");
DockerImageName LOCALSTACK_0_11_IMAGE = LOCALSTACK_IMAGE.withTag("0.11.3");
DockerImageName LOCALSTACK_0_12_IMAGE = LOCALSTACK_IMAGE.withTag("0.12.8");
DockerImageName AWS_CLI_IMAGE = DockerImageName.parse("atlassian/pipelines-awscli:1.16.302");
DockerImageName AWS_CLI_IMAGE = DockerImageName.parse("amazon/aws-cli:2.7.27");
}

0 comments on commit 9540652

Please sign in to comment.