Skip to content

Netty config tests#2486

Merged
ihrasko merged 2 commits intoPANTHEONtech:mainfrom
PeterSuna:netty-config-tests
Dec 17, 2025
Merged

Netty config tests#2486
ihrasko merged 2 commits intoPANTHEONtech:mainfrom
PeterSuna:netty-config-tests

Conversation

@PeterSuna
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @PeterSuna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly bolsters the testing capabilities for the Netty RestConf module by introducing a new, structured TestNG-based test suite. The changes cover critical areas such as configuration validation, lifecycle management of core components, and the verification of advanced features like YANG patch operations. This enhancement aims to improve the overall stability and reliability of the Netty RestConf implementation by ensuring robust and comprehensive test coverage.

Highlights

  • Enhanced Testing Framework: Introduced a comprehensive TestNG-based test suite for the Netty RestConf component, moving away from or complementing existing JUnit setups by adding TestNG as a dependency and excluding JUnit Jupiter where conflicts might arise.
  • Netty RestConf Configuration Tests: Added new test classes (NettyRestConfConfigurationTest) to validate the NettyRestConfConfiguration's behavior, including object equality, hash code consistency, and the ability to load configuration from external JSON streams.
  • YANG Patch Operation Testing: Included a dedicated test (YangPatchTest) to verify YANG patch operations, demonstrating the ability to apply data modifications (e.g., 'replace') to the configuration datastore via Restconf and ensuring data integrity.
  • Centralized Test Setup: Created an abstract base class (NettyRestConfTestBase) to standardize the setup and teardown of LightyController and NettyRestConf instances for all related tests, ensuring a consistent and efficient testing environment.
  • Configuration Immutability Adjustment: Removed the setRestconfServletContextPath method from NettyRestConfConfiguration, suggesting a shift towards making this specific configuration property immutable or managed differently after initial setup.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a suite of TestNG tests for the Netty RESTCONF configuration and functionality, enhancing test coverage with new test classes, a base class for setup, and necessary dependency updates. The changes are a positive step. My review focuses on improving the new tests' robustness and maintainability, and also flags a potential regression due to the removal of a setter method, which could affect URL path handling.

I am having trouble creating individual review comments. Click here to see my feedback.

lighty-modules/lighty-restconf-netty-nb-community/src/main/java/io/lighty/modules/northbound/netty/restconf/community/impl/config/NettyRestConfConfiguration.java (133-136)

high

The setRestconfServletContextPath method, which contained logic to remove a leading slash from the path, has been removed. This logic is not present in the getter or any other part of the class. If a configuration file provides a path with a leading slash (like the new restconf-config.json test file does), it will be used as-is, which might cause issues with servlet path mapping if the downstream code expects a path without a leading slash.

Was the removal of this logic intentional? If the path should not have a leading slash, consider moving this logic to the getter to ensure consistency.

For example:

public String getRestconfServletContextPath() {
    return restconfServletContextPath.startsWith("/")
        ? restconfServletContextPath.substring(1) : restconfServletContextPath;
}

This would make the class's behavior more robust. The field restconfServletContextPath is initialized to "restconf" which has no leading slash, but can be overridden by JSON deserialization.

lighty-modules/lighty-restconf-netty-nb-community/src/test/java/io/lighty/modules/northbound/netty/restconf/community/impl/tests/NettyRestConfConfigurationTest.java (41)

medium

This test loads configuration from restconf-config.json but doesn't verify the restconfServletContextPath property. Given the changes to how this property is handled in NettyRestConfConfiguration, it would be valuable to add an assertion here to ensure it's parsed as expected and to document the expected behavior (i.e., whether the leading slash is preserved).

For example, you could add:
Assert.assertEquals(restConfConfiguration.getRestconfServletContextPath(), "/restconf-path");

lighty-modules/lighty-restconf-netty-nb-community/src/test/java/io/lighty/modules/northbound/netty/restconf/community/impl/tests/NettyRestConfTestBase.java (56)

medium

The call to started.get() blocks until the future completes or the @BeforeClass timeout is reached. This can make tests hang and harder to debug. It's also inconsistent with the nettyRestConf.start().get(10_000, TimeUnit.MILLISECONDS) call later. It's a good practice to use a timeout on all blocking get() calls to prevent tests from hanging.

        started.get(10, TimeUnit.SECONDS);

lighty-modules/lighty-restconf-netty-nb-community/src/test/java/io/lighty/modules/northbound/netty/restconf/community/impl/tests/NettyRestConfTestBase.java (104-114)

medium

The switch statement uses magic numbers (-1, 1, 2, etc.) to represent TestNG result statuses. This makes the code harder to read and maintain. It's better to use the named constants provided by the ITestResult interface (e.g., ITestResult.SUCCESS, ITestResult.FAILURE).

Note: This change will require adding import org.testng.ITestResult;.

    private static String parseTestNGStatus(final int testResultStatus) {
        return switch (testResultStatus) {
            case ITestResult.CREATED -> "CREATED";
            case ITestResult.SUCCESS -> "SUCCESS";
            case ITestResult.FAILURE -> "FAILURE";
            case ITestResult.SKIP -> "SKIP";
            case ITestResult.SUCCESS_PERCENTAGE_FAILURE -> "SUCCESS_PERCENTAGE_FAILURE";
            case ITestResult.STARTED -> "STARTED";
            default -> "N/A";
        };
    }

@PeterSuna PeterSuna force-pushed the netty-config-tests branch 2 times, most recently from 6405760 to b708741 Compare December 5, 2025 14:36
@PeterSuna PeterSuna closed this Dec 5, 2025
@PeterSuna PeterSuna reopened this Dec 5, 2025
@PeterSuna PeterSuna closed this Dec 5, 2025
@PeterSuna PeterSuna reopened this Dec 5, 2025
@PeterSuna PeterSuna closed this Dec 8, 2025
@PeterSuna PeterSuna reopened this Dec 8, 2025
@PeterSuna PeterSuna force-pushed the netty-config-tests branch 2 times, most recently from e86013d to eff8173 Compare December 15, 2025 09:40
Tobianas and others added 2 commits December 16, 2025 19:21
Add tests based of CommunityRestConf tests to properly verify netty
restconf and its configuration.

JIRA: LIGHTY-333
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Fix:
- Remove Junit dependency from lighty-restconf-netty-nb-community.
- Remove vincent author.
- Use var.
- Unify the copyright link with other lighty copyrights.
- Fix private property.
- Verify that modueles are closed at the end of test.
- Initializing AAA bundles added `key-stores` container into
  data-store. Fix test by targeting "patch-cont" in get request.
- Simplifies the getPath method.

JIRA: LIGHTY-333
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
@PeterSuna PeterSuna closed this Dec 17, 2025
@PeterSuna PeterSuna reopened this Dec 17, 2025
@PeterSuna PeterSuna closed this Dec 17, 2025
@PeterSuna PeterSuna reopened this Dec 17, 2025
@PeterSuna PeterSuna requested a review from ihrasko December 17, 2025 08:49
@ihrasko ihrasko merged commit 220c0fa into PANTHEONtech:main Dec 17, 2025
11 of 14 checks passed
@ihrasko ihrasko mentioned this pull request Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants