diff --git a/aws-kinesis-project/consumer/.localstack/init-aws.sh b/aws-kinesis-project/consumer/.localstack/init-aws.sh index 7d40dced..fc53c3a3 100755 --- a/aws-kinesis-project/consumer/.localstack/init-aws.sh +++ b/aws-kinesis-project/consumer/.localstack/init-aws.sh @@ -19,4 +19,6 @@ awslocal dynamodb create-table \ --billing-mode PROVISIONED awslocal dynamodb list-tables -awslocal kinesis list-streams \ No newline at end of file +awslocal kinesis list-streams + +echo "LocalStack initialized successfully" diff --git a/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/ApplicationIntegrationTest.java b/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/ApplicationIntegrationTest.java index d94a2c4a..9084520a 100644 --- a/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/ApplicationIntegrationTest.java +++ b/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/ApplicationIntegrationTest.java @@ -19,7 +19,7 @@ void contextLoads() throws InterruptedException { .pollDelay(Duration.ofSeconds(1)) .untilAsserted( () -> - assertThat(ipAddressEventRepository.count().block()) + assertThat(ipAddressEventRepository.count().block() + initialCount) .isGreaterThan(10)); } } diff --git a/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/TestKinesisConsumerApplication.java b/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/TestKinesisConsumerApplication.java index 32409493..a34eb7bb 100644 --- a/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/TestKinesisConsumerApplication.java +++ b/aws-kinesis-project/consumer/src/test/java/com/learning/aws/spring/TestKinesisConsumerApplication.java @@ -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 { @@ -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);