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

feat : using aws Serviceconnection for testcontainers in dev mode #665

Merged
merged 8 commits into from
Apr 2, 2024

Conversation

rajadilipkolli
Copy link
Owner

@rajadilipkolli rajadilipkolli commented Apr 2, 2024

Summary by CodeRabbit

  • Tests
    • Improved integration testing framework for AWS services in the application.
    • Updated test configurations for better isolation and reliability.
  • Chores
    • Updated dependencies to Spring Boot 3.3.0-M3 and spring-cloud-aws 3.2.0-M1.
    • Added test dependency spring-cloud-aws-testcontainers.
  • New Features
    • Introduced functionality for setting up a local test environment using TestContainers with LocalStack for AWS SES testing.
    • Refactored test configuration in TestcontainersConfig.java for improved functionality.
  • Bug Fixes
    • Updated package declaration in SchemaValidationTest.java for correct functionality.

Copy link

coderabbitai bot commented Apr 2, 2024

Warning

Rate Limit Exceeded

@rajadilipkolli has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 51 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 5430004 and 22efa56.

Walkthrough

The recent updates enhance testing setups across AWS projects, focusing on Spring Boot applications interacting with AWS services like SES, SNS, and SQS. Changes include dependency upgrades, test environment setup improvements using TestContainers with LocalStack, and refactored configurations for streamlined testing.

Changes

File Path Change Summary
aws-dynamodb-project/pom.xml
aws-sns-project/pom.xml
Removed spring-boot-testcontainers, localstack dependencies in DynamoDB and SNS projects.
aws-ses-project/pom.xml Upgraded dependencies, changed test dependencies for AWS SES testing, and updated googleJavaFormat version.
aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java Introduced local test environment setup for AWS SES testing.
aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java Modified @SpringBootTest annotation for SES testing setup.
aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java
aws-sqs-project/src/test/java/com/learning/awspring/config/TestcontainersConfig.java
Updated localstackContainer method with @ServiceConnection annotation.
aws-sqs-project/pom.xml Updated Spring Boot and spring-cloud-aws versions, added spring-cloud-aws-testcontainers dependency.
aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java Updated package declaration to com.learning.awspring.repositories.

🐇🌟
In the realm of code where changes bloom,
AWS projects dance, dispelling gloom.
With SES, SNS, and SQS in play,
TestContainers and LocalStack lead the way.
Spring's embrace, upgrades galore,
Testing refined, we seek for more.
🌱🐰💻

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1b003fe and 181ea8e.
Files selected for processing (3)
  • aws-dynamodb-project/src/test/java/com/learning/awsspring/ApplicationIntegrationTest.java (1 hunks)
  • aws-dynamodb-project/src/test/java/com/learning/awsspring/TestApplication.java (1 hunks)
  • aws-dynamodb-project/src/test/java/com/learning/awsspring/common/AbstractIntegrationTest.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • aws-dynamodb-project/src/test/java/com/learning/awsspring/ApplicationIntegrationTest.java
Additional comments not posted (6)
aws-dynamodb-project/src/test/java/com/learning/awsspring/common/AbstractIntegrationTest.java (3)

7-7: The import of TestApplication is correctly added to support the new testing configuration.


15-15: The modification of the @SpringBootTest annotation to include classes = TestApplication.class is a key change that aligns with the PR objectives, ensuring that TestApplication is used for testing configurations.


17-17: The structural changes to the AbstractIntegrationTest class, including the removal of inheritance from LocalStackConfig, align with the PR objectives to shift the testing configuration approach. This change simplifies the testing setup by leveraging TestApplication.

aws-dynamodb-project/src/test/java/com/learning/awsspring/TestApplication.java (3)

14-15: The use of @Slf4j for logging and @TestConfiguration(proxyBeanMethods = false) to mark this as a test configuration class is appropriate and aligns with best practices for Spring Boot testing configurations.


18-32: The configuration of the LocalStackContainer bean is comprehensive, including Docker image specification, file copying for initialization, and a log waiting strategy. This setup is crucial for integrating LocalStack with Testcontainers effectively.

Ensure that the LocalStack Docker image version 3.3.0 is the intended version for your testing needs, as Docker images are frequently updated with new features and bug fixes.


34-36: The main method's approach to run the application in a test context by combining Application::main with TestApplication.class is innovative and aligns with the objective of integrating Testcontainers into the development environment.

Copy link

sonarqubecloud bot commented Apr 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 181ea8e and d469eaa.
Files selected for processing (4)
  • .github/workflows/sonarbuild.yml (1 hunks)
  • aws-sqs-project/pom.xml (3 hunks)
  • aws-sqs-project/src/test/java/com/learning/awspring/config/TestcontainersConfig.java (2 hunks)
  • aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java (1 hunks)
Additional comments not posted (6)
aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java (1)

1-1: The package declaration change to com.learning.awspring.repositories aligns with the file's location and follows Java best practices for package structuring.

aws-sqs-project/src/test/java/com/learning/awspring/config/TestcontainersConfig.java (1)

20-24: The introduction of the @ServiceConnection annotation for the localstackContainer bean simplifies and enhances the configuration for using LocalStack with Testcontainers, aligning with the PR objectives.

.github/workflows/sonarbuild.yml (1)

28-29: The introduction of a conditional check to run the "Build and analyze" job only for the main branch is a good optimization, saving resources and ensuring that SonarCloud analysis is performed where most relevant.

aws-sqs-project/pom.xml (3)

9-9: Updating to Spring Boot 3.3.0-M3 aligns with keeping the project up-to-date with the latest improvements and features.


24-24: Updating to spring-cloud-aws 3.2.0-M1 is a positive change, ensuring the project benefits from the latest features and bug fixes. Ensure compatibility with existing functionalities.


124-128: The addition of spring-cloud-aws-testcontainers as a test dependency supports the PR objectives by providing specific utilities for testing AWS services with Testcontainers, enhancing the testing environment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d469eaa and 4eb30bd.
Files selected for processing (7)
  • aws-dynamodb-project/pom.xml (2 hunks)
  • aws-ses-project/pom.xml (4 hunks)
  • aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java (1 hunks)
  • aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java (2 hunks)
  • aws-sns-project/pom.xml (4 hunks)
  • aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java (2 hunks)
  • aws-sqs-project/pom.xml (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • aws-sqs-project/pom.xml
Additional comments not posted (10)
aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java (2)

14-14: The addition of the @ServiceConnection annotation is a good practice for simplifying connections to services in test environments. Ensure that all necessary AWS services are enabled in the LocalStack container configuration.


16-16: Ensure the LocalStack version (3.3.0) is compatible with the AWS services you intend to test. It's important to keep the LocalStack version up-to-date for compatibility and security reasons.

aws-ses-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java (2)

6-6: The import of TestSESApplication is necessary for the specific configuration of integration tests. Ensure that TestSESApplication is correctly configured for this purpose.


15-15: Modifying the @SpringBootTest annotation to specify TestSESApplication.class is a good practice for ensuring tests run in a controlled environment. Consider adding comments to explain the choice of TestSESApplication for future maintainers.

aws-ses-project/src/test/java/com/example/awsspring/TestSESApplication.java (1)

12-30: The TestSESApplication class is well-structured for testing purposes, with appropriate logging and container setup. Consider adding error handling for the LocalStackContainer startup process to ensure robustness in case of startup failures.

aws-sns-project/pom.xml (2)

10-10: Upgrading the Spring Boot version to 3.3.0-M3 and spring-cloud-aws.version to 3.2.0-M1 is a positive step towards keeping the project up-to-date. Ensure thorough testing is conducted to verify compatibility with existing code and dependencies.

Also applies to: 24-24


87-88: The addition of spring-cloud-aws-testcontainers and junit-jupiter dependencies is aligned with the PR's objective and is essential for setting up a local AWS environment for testing. Ensure that any unused dependencies, especially related to localstack, are removed to keep the project clean and maintainable.

Also applies to: 107-107

aws-ses-project/pom.xml (2)

8-8: Upgrading the Spring Boot version to 3.3.0-M3 and spring-cloud-aws.version to 3.2.0-M1 is a positive step towards keeping the project up-to-date. Ensure thorough testing is conducted to verify compatibility with existing code and dependencies.

Also applies to: 22-22


101-102: The changes in dependencies, including the addition of spring-cloud-aws-testcontainers and junit-jupiter, are aligned with the PR's objective of integrating Testcontainers for AWS service testing. Ensure that all dependencies are used effectively and any unused dependencies are removed to keep the project clean and maintainable.

Also applies to: 107-107

aws-dynamodb-project/pom.xml (1)

94-99: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]

Ensure that the dependencies for spring-cloud-aws-testcontainers and junit-jupiter are correctly utilized for testing with DynamoDB. Additionally, verify that any references to removed dependencies, such as localstack, are also cleaned up from the project configuration to maintain clarity and avoid confusion.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4eb30bd and 463c1ce.
Files selected for processing (1)
  • aws-sqs-project/pom.xml (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • aws-sqs-project/pom.xml

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 463c1ce and 5430004.
Files selected for processing (5)
  • aws-cloudwatch-project/pom.xml (4 hunks)
  • aws-cloudwatch-project/src/test/java/com/example/awsspring/TestApplication.java (1 hunks)
  • aws-cloudwatch-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java (2 hunks)
  • aws-secretmanager-project/pom.xml (7 hunks)
  • aws-secretmanager-project/src/test/java/com/example/awsspring/TestApplication.java (1 hunks)
Additional comments not posted (14)
aws-cloudwatch-project/src/test/java/com/example/awsspring/TestApplication.java (4)

11-11: Consider adding a brief Javadoc comment above the TestApplication class to explain its purpose, especially since it's part of the test configuration.


14-19: The localstackContainer bean is correctly defined for LocalStack integration. Ensure that the LocalStack services required by your tests are enabled by using .withServices(Service... services) method on the LocalStackContainer instance.


21-25: The postgreSQLContainer bean is correctly defined. To improve maintainability, consider externalizing the Docker image name and tag into a properties file or constants class.


27-29: The main method is correctly implemented for running the test application. Ensure that the Application::main reference correctly points to your main application class.

aws-cloudwatch-project/src/test/java/com/example/awsspring/common/AbstractIntegrationTest.java (1)

3-15: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-27]

The restructuring of annotations and class inheritance in AbstractIntegrationTest is a positive change for clarity and maintainability. Ensure that all integration tests extending this class do not rely on any specific configurations or beans previously provided by LocalStackConfig.

aws-secretmanager-project/src/test/java/com/example/awsspring/TestApplication.java (2)

14-16: The use of @ImportTestcontainers to import DBTestContainer is a good practice for modular test configuration. Ensure that DBTestContainer is correctly configured and its lifecycle is managed appropriately.


18-25: The configuration of the LocalStack container with a custom initialization script is a powerful feature. Verify that the script at "localstack/" correctly initializes the required AWS services and resources for your tests.

aws-secretmanager-project/pom.xml (4)

8-8: Upgrading the spring-boot-starter-parent version to 3.3.0-M3 is a significant change. Ensure that this upgrade does not introduce any compatibility issues with your project's existing configurations and dependencies.


23-23: Updating the spring-cloud-aws.version to 3.2.0-M1 aligns with the objective of enhancing AWS service integration. Verify that all AWS-related functionalities work as expected with this new version.


113-118: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [102-124]

The replacement of spring-boot-testcontainers with io.awspring.cloud:spring-cloud-aws-testcontainers and the addition of org.testcontainers:junit-jupiter and postgresql are in line with the PR objectives. Ensure that your test suites are updated to leverage these new dependencies effectively.


233-233: Upgrading the googleJavaFormat version to 1.19.2 is a minor change but important for code style consistency. Ensure that your codebase complies with the new version's formatting rules.

aws-cloudwatch-project/pom.xml (3)

8-8: Upgrading the spring-boot-starter-parent version to 3.3.0-M3 is consistent with the changes in the other project. As before, ensure compatibility with your project's configurations and dependencies.


22-22: The upgrade of spring-cloud-aws.version to 3.2.0-M1 should be verified for compatibility with AWS services used in this project, similar to the aws-secretmanager-project.


113-124: The addition of spring-cloud-aws-testcontainers, junit-jupiter, and postgresql dependencies aligns with the PR's objectives to enhance testing with AWS services. Ensure that these dependencies are utilized effectively in your tests.

@rajadilipkolli rajadilipkolli merged commit 45475ab into main Apr 2, 2024
10 checks passed
@rajadilipkolli rajadilipkolli deleted the aws-localstack branch April 2, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant