Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update localstack/localstack and Spring Boot #807

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws-sns-project/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'
services:

localstack:
image: localstack/localstack:3.8.1
image: localstack/localstack:4.0.3
ports:
- "4566:4566"
environment:
Expand Down
2 changes: 1 addition & 1 deletion aws-sns-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<configuration>
<java>
<palantirJavaFormat>
<version>2.47.0</version>
<version>2.50.0</version>
</palantirJavaFormat>
<importOrder />
<removeUnusedImports />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
import static io.awspring.cloud.sns.configuration.NotificationHandlerMethodArgumentResolverConfigurationUtils.getNotificationHandlerMethodArgumentResolver;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import software.amazon.awssdk.services.sns.SnsClient;

@Configuration(proxyBeanMethods = false)
@RequiredArgsConstructor
class WebMvcConfig implements WebMvcConfigurer {

private final ApplicationProperties properties;
private final SnsClient snsClient;

public WebMvcConfig(ApplicationProperties properties, SnsClient snsClient) {
this.properties = properties;
this.snsClient = snsClient;
}

@Override
public void addCorsMappings(CorsRegistry registry) {
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping(properties.getCors().getPathPattern())
.allowedMethods(properties.getCors().getAllowedMethods())
.allowedHeaders(properties.getCors().getAllowedHeaders())
Expand All @@ -27,7 +31,7 @@ public void addCorsMappings(CorsRegistry registry) {
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
public void addArgumentResolvers(@NonNull List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(getNotificationHandlerMethodArgumentResolver(snsClient));
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.learning.awssns;

import com.learning.awssns.common.ContainersConfig;
import com.learning.awssns.utils.AppConstants;
import org.springframework.boot.SpringApplication;

public class TestSNSApplication {

public static void main(String[] args) {
System.setProperty("spring.profiles.active", "local");
SpringApplication.from(SNSApplication::main)
.with(ContainersConfig.class)
.withAdditionalProfiles(AppConstants.PROFILE_LOCAL)
.run(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class ContainersConfig {
@ServiceConnection
LocalStackContainer localstackContainer() {
return new LocalStackContainer(
DockerImageName.parse("localstack/localstack").withTag("3.7.2"));
DockerImageName.parse("localstack/localstack").withTag("4.0.3"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Version upgrade requires project-wide synchronization

The analysis reveals significant version inconsistencies that need attention:

  • Only aws-sns-project and aws-sqs-project use LocalStack 4.0.3
  • Other projects use older versions (3.7.1, 3.7.2, 3.8.1)
  • Configuration differences exist between versions (e.g., environment variables, port mappings)

Key findings:

  • 4.0.3 configurations use EDGE_PORT instead of legacy port mappings
  • 3.x versions have additional port ranges (4510-4559) in some projects
  • Different environment variable patterns between versions
🔗 Analysis chain

Verify LocalStack 4.0.3 compatibility

The upgrade from 3.x to 4.x is a major version change that might include breaking changes.

Let's verify the LocalStack version consistency across the project and check for any known issues:


Version inconsistency detected across LocalStack configurations

The codebase has mixed LocalStack versions that need to be aligned:

  • Java test files use versions: 3.7.1, 3.7.2, and 4.0.3
  • Docker compose files use versions: 3.8.1 and 4.0.3

Let's verify if there are any breaking changes or configuration differences between these versions:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check LocalStack version consistency and configuration requirements

# Check LocalStack versions across all files
echo "Checking LocalStack versions in docker-compose files:"
fd docker-compose.yml --exec grep -l "localstack/localstack"

echo -e "\nChecking LocalStack versions in Java test files:"
rg "localstack/localstack" --type java

# Check if there are any custom LocalStack configurations that might need updates
echo -e "\nChecking for LocalStack environment variables and configurations:"
fd docker-compose.yml --exec grep -A 5 "localstack:"

Length of output: 5784


Script:

#!/bin/bash
# Check for configuration differences between versions
echo "Checking 4.0.3 configurations:"
rg -B 2 -A 5 "localstack/localstack:4\.0\.3" --type yaml

echo -e "\nChecking 3.x configurations:"
rg -B 2 -A 5 "localstack/localstack:3\." --type yaml

# Check for any version-specific environment variables or settings in test files
echo -e "\nChecking LocalStack container configurations in test files:"
rg "LocalStackContainer\(" -A 5 --type java

Length of output: 16447

}
}
2 changes: 1 addition & 1 deletion aws-sqs-project/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
retries: 5

localstack:
image: localstack/localstack:3.8.1
image: localstack/localstack:4.0.3
environment:
- AWS_DEFAULT_REGION=us-east-1
- EDGE_PORT=4566
Expand Down
2 changes: 1 addition & 1 deletion aws-sqs-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.22.0</version>
<version>1.25.0</version>
<style>AOSP</style>
</googleJavaFormat>
<formatAnnotations />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class LocalStackTestContainers {
@ServiceConnection
LocalStackContainer localstackContainer() {
return new LocalStackContainer(
DockerImageName.parse("localstack/localstack").withTag("3.7.2"))
DockerImageName.parse("localstack/localstack").withTag("4.0.3"))
.withReuse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class SQLTestcontainersConfig {
@Bean
@ServiceConnection
PostgreSQLContainer<?> postgreSQLContainer() {
return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.0-alpine"));
return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.2-alpine"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
import javax.sql.DataSource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.Import;

@DataJpaTest(
properties = {
"spring.jpa.hibernate.ddl-auto=validate",
"spring.test.database.replace=none"
})
@DataJpaTest(properties = {"spring.jpa.hibernate.ddl-auto=validate"})
@Import(SQLTestcontainersConfig.class)
@AutoConfigureTestDatabase
rajadilipkolli marked this conversation as resolved.
Show resolved Hide resolved
class SchemaValidationTest {

@Autowired private DataSource dataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class FakeObjectCreator {

public static SQSMessagePayload createMessage() {
return new SQSMessagePayload(
RandomStringUtils.randomNumeric(3), RandomStringUtils.randomAlphanumeric(100));
RandomStringUtils.secure().nextNumeric(3),
RandomStringUtils.secure().nextAlphanumeric(100));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
rajadilipkolli marked this conversation as resolved.
Show resolved Hide resolved
import org.springframework.test.web.servlet.MockMvc;

@WebMvcTest(controllers = CustomerController.class)
class CustomerControllerTest {

@Autowired private MockMvc mockMvc;

@MockBean private CustomerService customerService;
@MockitoBean private CustomerService customerService;

@Autowired private ObjectMapper objectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

@WebMvcTest(controllers = InboundLogController.class)
class InboundLogControllerTest {

@Autowired private MockMvc mockMvc;

@MockBean private InboundLogService inboundLogService;
@MockitoBean private InboundLogService inboundLogService;
rajadilipkolli marked this conversation as resolved.
Show resolved Hide resolved

@Autowired private ObjectMapper objectMapper;

Expand Down
Loading