Skip to content

Commit

Permalink
feat: enhances tests to use script for provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Mar 13, 2024
1 parent a510e17 commit b79ffe3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion aws-kinesis-project/consumer/.localstack/init-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ awslocal dynamodb create-table \
--billing-mode PROVISIONED

awslocal dynamodb list-tables
awslocal kinesis list-streams
awslocal kinesis list-streams

echo "LocalStack initialized successfully"
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void contextLoads() throws InterruptedException {
.pollDelay(Duration.ofSeconds(1))
.untilAsserted(
() ->
assertThat(ipAddressEventRepository.count().block())
assertThat(ipAddressEventRepository.count().block() + initialCount)
.isGreaterThan(10));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
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 TestKinesisConsumerApplication {
Expand All @@ -21,7 +23,13 @@ PostgreSQLContainer<?> postgreSQLContainer() {
@Bean
LocalStackContainer localStackContainer(DynamicPropertyRegistry dynamicPropertyRegistry) {
LocalStackContainer localStackContainer =
new LocalStackContainer(DockerImageName.parse("localstack/localstack:3.2.0"));
new LocalStackContainer(DockerImageName.parse("localstack/localstack:3.2.0"))
.withCopyFileToContainer(
MountableFile.forHostPath(".localstack/"),
"/etc/localstack/init/ready.d/")
.waitingFor(
Wait.forLogMessage(".*LocalStack initialized successfully\n", 1));
;
dynamicPropertyRegistry.add("spring.cloud.aws.endpoint", localStackContainer::getEndpoint);
dynamicPropertyRegistry.add(
"spring.cloud.aws.region.static", localStackContainer::getRegion);
Expand Down

0 comments on commit b79ffe3

Please sign in to comment.