-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : upgrade software to latest versions (#818)
* feat : upgrade software to latest versions * attempt to use OOTB service connection for S3 * fix : issue with assiging dynamic properties * run all repo tests with testcontainers
- Loading branch information
1 parent
0083751
commit 0e77433
Showing
10 changed files
with
77 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic", | ||
"java.compile.nullAnalysis.mode": "automatic", | ||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable" | ||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable", | ||
"java.debug.settings.onBuildFailureProceed": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 5 additions & 37 deletions
42
aws-s3-project/src/test/java/com/learning/awspring/TestS3Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,14 @@ | ||
package com.learning.awspring; | ||
|
||
import com.learning.awspring.common.LocalStackContainerConfig; | ||
import com.learning.awspring.common.SQLContainerConfig; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.devtools.restart.RestartScope; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerImageName; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class TestS3Application { | ||
|
||
@Bean | ||
@ServiceConnection | ||
@RestartScope | ||
PostgreSQLContainer<?> postgresContainer() { | ||
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:17.0-alpine")) | ||
.withReuse(true); | ||
} | ||
|
||
@Bean | ||
LocalStackContainer localstackContainer(DynamicPropertyRegistry registry) { | ||
LocalStackContainer localStackContainer = | ||
new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack").withTag("3.7.2")) | ||
.withCopyFileToContainer( | ||
MountableFile.forHostPath(".localstack/"), | ||
"/etc/localstack/init/ready.d/") | ||
.waitingFor( | ||
Wait.forLogMessage(".*LocalStack initialized successfully\n", 1)); | ||
registry.add("spring.cloud.aws.credentials.access-key", localStackContainer::getAccessKey); | ||
registry.add("spring.cloud.aws.credentials.secret-key", localStackContainer::getSecretKey); | ||
registry.add("spring.cloud.aws.region.static", localStackContainer::getRegion); | ||
registry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint); | ||
return localStackContainer; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(S3Application::main).with(TestS3Application.class).run(args); | ||
SpringApplication.from(S3Application::main) | ||
.with(SQLContainerConfig.class, LocalStackContainerConfig.class) | ||
.run(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
aws-s3-project/src/test/java/com/learning/awspring/common/LocalStackContainerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.learning.awspring.common; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistrar; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerImageName; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class LocalStackContainerConfig { | ||
|
||
@Bean | ||
LocalStackContainer localstackContainer() { | ||
return new LocalStackContainer( | ||
DockerImageName.parse("localstack/localstack").withTag("4.0.3")) | ||
.withCopyFileToContainer( | ||
MountableFile.forHostPath(".localstack/"), "/etc/localstack/init/ready.d/") | ||
.waitingFor(Wait.forLogMessage(".*LocalStack initialized successfully\n", 1)); | ||
} | ||
|
||
@Bean | ||
DynamicPropertyRegistrar dynamicPropertyRegistrar(LocalStackContainer localStackContainer) { | ||
return registry -> { | ||
registry.add( | ||
"spring.cloud.aws.credentials.access-key", localStackContainer::getAccessKey); | ||
registry.add( | ||
"spring.cloud.aws.credentials.secret-key", localStackContainer::getSecretKey); | ||
registry.add("spring.cloud.aws.region.static", localStackContainer::getRegion); | ||
registry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint); | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
aws-s3-project/src/test/java/com/learning/awspring/common/SQLContainerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.learning.awspring.common; | ||
|
||
import org.springframework.boot.devtools.restart.RestartScope; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class SQLContainerConfig { | ||
|
||
@Bean | ||
@ServiceConnection | ||
@RestartScope | ||
PostgreSQLContainer<?> postgresContainer() { | ||
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:17.2-alpine")) | ||
.withReuse(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters