Conversation
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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)
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)
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)
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)
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";
};
}
6405760 to
b708741
Compare
b708741 to
5c01969
Compare
5c01969 to
ec2592f
Compare
e86013d to
eff8173
Compare
.../src/main/java/io/lighty/modules/northbound/netty/restconf/community/impl/NettyRestConf.java
Outdated
Show resolved
Hide resolved
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>
eff8173 to
a2e0811
Compare
No description provided.