Skip to content

Commit

Permalink
Fix migrate to LocalStack 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fameing committed Jan 25, 2024
1 parent 1e2df93 commit 574129f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion embedded-localstack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>embedded-localstack</artifactId>

<properties>
<aws-java-sdk.version>1.12.261</aws-java-sdk.version>
<aws-java-sdk.version>1.12.643</aws-java-sdk.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public LocalStackContainer localStack(ConfigurableEnvironment environment,
.withExposedPorts(properties.getEdgePort())
.withEnv("EDGE_PORT", String.valueOf(properties.getEdgePort()))
.withEnv("HOSTNAME", properties.getHostname())
.withEnv("HOSTNAME_EXTERNAL", properties.getHostnameExternal())
.withEnv("LOCALSTACK_HOST", properties.getHostnameExternal())
.withEnv("SKIP_SSL_CERT_DOWNLOAD", "1")
.withNetworkAliases(LOCALSTACK_NETWORK_ALIAS);

network.ifPresent(localStackContainer::withNetwork);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ public class LocalStackProperties extends CommonContainerProperties {
public static final String BEAN_NAME_EMBEDDED_LOCALSTACK = "embeddedLocalstack";
public Collection<LocalStackContainer.Service> services = Collections.emptyList();
public int edgePort = 4566;
public String hostname = "127.0.0.1";
public String hostname = "localhost";
public String hostnameExternal = "127.0.0.1";

// https://hub.docker.com/r/localstack/localstack
@Override
public String getDefaultDockerImage() {
// Please don`t remove this comment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"name": "embedded.localstack.docker-image",
"type": "java.lang.String",
"defaultValue": "localstack/localstack:0.10.8"
"defaultValue": "localstack/localstack:3.0.0"
}
],
"hints": [
Expand All @@ -36,7 +36,7 @@
"values": [
{
"value": "localstack/localstack:3.0.0",
"description": "Default Localstack image in version 0.10.8. Ref https://hub.docker.com/r/localstack/localstack for further info."
"description": "Default Localstack image. Ref https://hub.docker.com/r/localstack/localstack for further info."
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import com.amazonaws.services.sqs.model.CreateQueueResult;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -91,10 +92,12 @@ public void shouldStartSQS() {

CreateQueueResult queueResult = sqs.createQueue("baz");
String fooQueueUrl = queueResult.getQueueUrl();
assertThat(fooQueueUrl).
contains("http://" + properties.getHostname() + ":" + sqsPort);

sqs.sendMessage(fooQueueUrl, "test");
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.setQueueUrl(fooQueueUrl);
sendMessageRequest.setMessageBody("test");
sqs.sendMessage(sendMessageRequest);

long messageCount = sqs.receiveMessage(fooQueueUrl).getMessages().stream()
.filter(message -> message.getBody().equals("test"))
.count();
Expand Down

0 comments on commit 574129f

Please sign in to comment.