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 : upgrade to spring boot 3.4 and polish tc config #606

Merged
merged 5 commits into from
Dec 7, 2024
Merged

Conversation

rajadilipkolli
Copy link
Owner

@rajadilipkolli rajadilipkolli commented Dec 7, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a Person class for managing user data, including fields for ID, name, and age, with serialization support.
    • Added KafkaContainersConfig for automated Kafka and Schema Registry container setup during integration testing.
  • Bug Fixes

    • Updated project dependencies for improved compatibility and performance.
  • Refactor

    • Transitioned TestSpringBootKafkaAvroProducerApplication to a standard application class, removing test-specific configurations.
    • Removed the custom KafkaRaftWithExtraListenersContainer class to streamline container management.
  • Documentation

    • Updated pom.xml to reflect new dependency versions and removed obsolete dependencies.

@rajadilipkolli rajadilipkolli self-assigned this Dec 7, 2024
Copy link
Contributor

coderabbitai bot commented Dec 7, 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 22 minutes and 57 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

Reviewing files that changed from the base of the PR and between f264514 and 74ab107.

Walkthrough

The changes in this pull request introduce a new Person class implementing the Avro SpecificRecord interface, which includes methods for serialization and deserialization. Additionally, the pom.xml file is updated to reflect version changes for Spring Boot and other dependencies. The test configuration class TestSpringBootKafkaAvroProducerApplication is refactored to a standard application class, while a new configuration class KafkaContainersConfig is added for managing Kafka and Schema Registry containers. A custom container class for Kafka has been removed.

Changes

File Change Summary
kafka-avro/spring-boot-kafka-avro-consumer/generated-avro/com/example/springbootkafkaavro/model/Person.java Added Person class implementing Avro SpecificRecord, including fields, constructors, getters/setters, Builder class, and serialization methods.
kafka-avro/spring-boot-kafka-avro-producer/pom.xml Updated Spring Boot version to 3.4.0, modified confluent.version and springdoc-openapi.version, removed jaxb-runtime dependency, and updated googleJavaFormat version.
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/SpringBootKafkaAvroProducerApplicationIntTests.java Updated @SpringBootTest annotation to reference KafkaContainersConfig.class.
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/TestSpringBootKafkaAvroProducerApplication.java Removed @TestConfiguration annotation, refactored class for standard application use without inline container management.
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaContainersConfig.java Added new configuration class for managing Kafka and Schema Registry containers using Testcontainers.
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaRaftWithExtraListenersContainer.java Removed custom Kafka container class designed for additional listeners.

Possibly related PRs

Suggested labels

component : avro, component : spring-boot, component : reactor, component : streams, component : dsl-integration, component : cloud

Poem

🐇 In the meadow, changes bloom,
A Person class dispels the gloom.
With Kafka's dance, we weave and spin,
New containers join, let the fun begin!
Spring Boot's upgrade, a leap so bright,
In code we trust, our future's in sight! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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/schema.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
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (5)
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/SpringBootKafkaAvroProducerApplicationIntTests.java (1)

Line range hint 35-43: Consider optimizing test execution and adding cleanup

While the test implementation is solid, here are some suggestions for improvement:

  1. The 30-second timeout might be excessive for local testing. Consider making it configurable or reducing it.
  2. Consider adding test cleanup to prevent message accumulation between test runs.
 @Test
 void contextLoads(CapturedOutput output) throws Exception {
     this.mockMvc
             .perform(post("/person/publish").param("name", "junit").param("age", "33"))
             .andExpect(status().isOk());
-    await().atMost(30, SECONDS)
+    await().atMost(10, SECONDS)  // Reduced timeout
             .untilAsserted(
                     () -> assertThat(output.getOut()).contains("Person received : junit : 33"));
 }
+
+@AfterEach
+void cleanup() {
+    // Add cleanup logic for Kafka messages if needed
+}
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/TestSpringBootKafkaAvroProducerApplication.java (1)

6-6: Consider renaming the class to reflect its new role

Since TestSpringBootKafkaAvroProducerApplication is now serving as a standard application class rather than a test configuration class, consider renaming it to something like SpringBootKafkaAvroProducerApplicationTest to better indicate its purpose and avoid potential confusion.

kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaContainersConfig.java (2)

30-31: Let Spring manage the Kafka container lifecycle

Explicitly calling confluentKafkaContainer.start(); within the bean definition may interfere with Spring's lifecycle management. Spring Boot can automatically start and stop Testcontainers when they are defined as beans. Consider removing the start() call to allow Spring to handle the container lifecycle.


50-51: Let Spring manage the Schema Registry container lifecycle

Similarly, calling schemaRegistry.start(); inside the bean definition bypasses Spring's container management. Remove the explicit start() call to let Spring Boot manage the Schema Registry container, ensuring proper startup and shutdown aligned with the application context.

kafka-avro/spring-boot-kafka-avro-producer/pom.xml (1)

152-152: Update Google Java Format to version 1.25.0

The Google Java Format version in the spotless-maven-plugin configuration has been updated. Ensure all code is reformatted according to the new formatter rules to maintain code style consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6bb9f and f264514.

📒 Files selected for processing (6)
  • kafka-avro/spring-boot-kafka-avro-consumer/generated-avro/com/example/springbootkafkaavro/model/Person.java (0 hunks)
  • kafka-avro/spring-boot-kafka-avro-producer/pom.xml (3 hunks)
  • kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/SpringBootKafkaAvroProducerApplicationIntTests.java (2 hunks)
  • kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/TestSpringBootKafkaAvroProducerApplication.java (1 hunks)
  • kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaContainersConfig.java (1 hunks)
  • kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaRaftWithExtraListenersContainer.java (0 hunks)
💤 Files with no reviewable changes (2)
  • kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaRaftWithExtraListenersContainer.java
  • kafka-avro/spring-boot-kafka-avro-consumer/generated-avro/com/example/springbootkafkaavro/model/Person.java
🔇 Additional comments (7)
kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/SpringBootKafkaAvroProducerApplicationIntTests.java (2)

9-9: LGTM: Clean import of new container configuration

The import of KafkaContainersConfig aligns with the architectural change to centralize container management.


27-27: Verify container initialization in KafkaContainersConfig

The switch to KafkaContainersConfig looks good, but let's verify that it properly initializes both Kafka and Schema Registry containers.

✅ Verification successful

Let me generate another verification script to check for Kafka container initialization since we only see the Schema Registry part.


Container configuration verified successfully

The KafkaContainersConfig properly initializes both required containers:

  • Kafka container with proper network configuration and aliases
  • Schema Registry container with correct bootstrap configuration and network setup
  • Both containers share the same network for communication
  • Dynamic property registration is configured for schema registry URL
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify KafkaContainersConfig implementation
# Check if the config class properly initializes both containers

# Look for container initialization
ast-grep --pattern 'class KafkaContainersConfig {
  $$$
  @Bean
  $$$Container $$$() {
    $$$
  }
  $$$
}'

# Verify Schema Registry configuration
rg -A 5 "schemaRegistry" --type java

Length of output: 5352


Script:

#!/bin/bash
# Check for Kafka container initialization
rg -A 10 "KafkaContainer" --type java

# Also check for network setup which is crucial for container communication
rg -A 5 "Network" --type java

Length of output: 54462

kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/TestSpringBootKafkaAvroProducerApplication.java (1)

3-10: LGTM

The integration of KafkaContainersConfig into the application startup process using SpringApplication.from(...).with(...).run(args); is appropriate and aligns with Spring Boot best practices.

kafka-avro/spring-boot-kafka-avro-producer/src/test/java/com/example/springbootkafkaavro/containers/KafkaContainersConfig.java (1)

54-71: LGTM

The DynamicPropertyRegistrar correctly configures the Schema Registry URLs for both the Kafka producer and consumer. This dynamic approach ensures that the application picks up the correct endpoints based on the Testcontainers' runtime configuration.

kafka-avro/spring-boot-kafka-avro-producer/pom.xml (3)

9-9: Update Spring Boot parent version

The parent version has been updated to 3.4.0. Ensure that all project dependencies and plugins are compatible with this newer version to prevent any runtime issues.


21-21: Verify the downgrade of confluent.version from 7.8.0 to 7.7.2

The Confluent platform version is being downgraded from 7.8.0 to 7.7.2. Verify that this change is intentional and that the older version meets all the application's requirements. Downgrading may reintroduce previously resolved bugs or remove features present in the newer version.


22-22: Update springdoc-openapi version

The springdoc-openapi.version is updated to 2.7.0. Confirm that this version is compatible with Spring Boot 3.4.0 and that there are no breaking changes affecting the API documentation.

.withListener("tc-kafka:19092") // Internal alias and port
.withNetwork(network) // Shared network for communication
.withNetworkAliases("tc-kafka") // Alias to match Schema Registry
.withReuse(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Review the use of .withReuse(true) in testing context

Using .withReuse(true) on the confluentKafkaContainer keeps the container running between test executions. This can lead to shared state across tests and might cause flaky tests or unexpected behaviors. Unless there's a specific need for container reuse, consider removing .withReuse(true) to ensure a clean environment for each test run.

@rajadilipkolli rajadilipkolli merged commit a9129e9 into main Dec 7, 2024
6 checks passed
@rajadilipkolli rajadilipkolli deleted the polish branch December 7, 2024 06:52
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