-
Notifications
You must be signed in to change notification settings - Fork 363
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
Added tests for the nodeportlocal package #5917
Conversation
e7bad9a
to
176e70a
Compare
@luolanzone, the
The |
Unit tests shouldn't need to really interact with iptables of the system. Instead, you should replace the iptables instance with a mock implementation and only validate if the expected calls has been made. Check the following test as an example: antrea/pkg/agent/route/route_linux_test.go Line 584 in 025c3f6
|
a7eca14
to
1371690
Compare
It makes sense, thanks for the suggestion. I've updated the code, I think that this PR is ready for a code review. |
hi @tnqn, do you know how to enable the github action in this PR for the UT workflow? |
I don't see the code reflects the change. It still calls the iptables command of the system. As seen from the test code, none of the call can succeed, so the test can't really ensure code work as expected. I think you should at least replace |
First time contributor needs a manual approval before the the tests can run. But since the code is not correct, I haven't clicked it yet. |
1371690
to
36326e1
Compare
Thanks for sharing the pointer @tnqn. This time, I was able to write some tests using the mockIPTable interface. |
9d25d17
to
ed9f5a9
Compare
@tnqn, I've made some updates to the code. Could you please review it again and let me know if the tests are now effective? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this version is on the right direction.
PodPort: 17, | ||
PodIP: "localhost", | ||
Protocol: "tcp", | ||
Protocols: []string{"tcp", "udp"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field is deprecated, you could just set Protocol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protocols are still being used at:
for _, protocol := range nplData.Protocols { |
This is why I added this field to the tests. I've removed it in the latest version though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The code shouldn't keep using it. It will be changed by #5943 (review). For this PR, it will have to expect wrong output (note that the iptables rules used by "iptables-restore" are empty)
This commit introduces new tests for the `pkg/agent/nodeportlocal/rules` package. Fixes: antrea-io#5650 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
ed9f5a9
to
0c02e70
Compare
/skip-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @VaibhavMalik4187
Thank you for the pointers and the code review. |
This commit introduces new tests for the
pkg/agent/nodeportlocal/rules
package.Fixes: #5650