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

Add unit tests for pkg/ovs/openflow #4221

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Sep 13, 2022

Signed-off-by: Hongliang Liu lhongliang@vmware.com

@codecov
Copy link

codecov bot commented Sep 13, 2022

Codecov Report

Merging #4221 (815f8b6) into main (1c0ec50) will decrease coverage by 3.98%.
The diff coverage is n/a.

❗ Current head 815f8b6 differs from pull request most recent head 045a711. Consider uploading reports for the commit 045a711 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4221      +/-   ##
==========================================
- Coverage   73.77%   69.80%   -3.98%     
==========================================
  Files         410      402       -8     
  Lines       60966    58384    -2582     
==========================================
- Hits        44978    40754    -4224     
- Misses      13082    14862    +1780     
+ Partials     2906     2768     -138     
Flag Coverage Δ *Carryforward flag
e2e-tests 38.37% <ø> (+0.02%) ⬆️
integration-tests 34.62% <ø> (+1.22%) ⬆️ Carriedforward from 1d29ae3
kind-e2e-tests 46.72% <ø> (-3.22%) ⬇️ Carriedforward from 1d29ae3
unit-tests 60.30% <ø> (-4.58%) ⬇️ Carriedforward from 1d29ae3

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
pkg/ovs/openflow/ofctrl_packetout.go 99.16% <ø> (+15.36%) ⬆️
pkg/ovs/ovsctl/interface.go 16.66% <ø> (ø)

... and 171 files with indirect coverage changes

@hongliangl hongliangl mentioned this pull request Sep 13, 2022
37 tasks
@hongliangl hongliangl marked this pull request as draft September 14, 2022 10:21
@hongliangl hongliangl marked this pull request as ready for review September 22, 2022 12:42
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 2 times, most recently from c0af2c5 to 4274e52 Compare September 28, 2022 03:46
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 2 times, most recently from 7f12440 to d928d9e Compare September 30, 2022 10:12
@hongliangl
Copy link
Contributor Author

This PR depends on #4258.

@luolanzone luolanzone added this to the Antrea v1.10 release milestone Oct 27, 2022
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 2 times, most recently from c2f254f to 73b3334 Compare November 10, 2022 11:16
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 4 times, most recently from f4feb52 to 8dea3e1 Compare November 21, 2022 01:05
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 3 times, most recently from ff315c8 to 6e9d460 Compare December 16, 2022 00:07
wenyingd
wenyingd previously approved these changes Dec 16, 2022
Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

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

LGTM

@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 3 times, most recently from 0c7d665 to 97dccca Compare June 16, 2023 07:27
pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

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

LGTM overall, a few nits.

pkg/ovs/openflow/testing/mock_openflow.go Outdated Show resolved Hide resolved
@@ -874,7 +874,12 @@ func nxActionLearnToString(action openflow15.Action) string {
if spec.SrcValue != nil {
srcValueStr := strings.TrimLeft(fmt.Sprintf("%x", spec.SrcValue), "0")
if isMatch {
dstFieldStr := getFieldNameString(spec.DstField.Field.Class, spec.DstField.Field.Field, spec.DstField.Ofs, nBits, true, false)
var dstFieldStr string
if spec.DstField.Field.Class == openflow15.OXM_CLASS_NXM_1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain a little bit why this change is needed? A new class is introduced after openflow15?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the OpenFlow learn flow action, the registers in OpenFlow 1.5 (OXM_CLASS_NXM_1) are capitalized when used as an output.

pkg/ovs/openflow/ofctrl_packetout_test.go Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_packetout_test.go Show resolved Hide resolved
@luolanzone
Copy link
Contributor

@tnqn, @wenyingd please help to take a look for this unit test PR. Thanks.

Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

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

Overall LGTM, one general comment is I saw many cases are almost the same except for the data value, maybe no need to add such duplicated cases?

pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
Value: &openflow15.ByteArrayField{Data: []byte{0x12, 0x34, 0x56}, Length: 3},
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get the differences among the three cases except for the data. Are they all needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to test different values. Besides, this can be also to test if the match string is as expected. For example, the first case should be xxreg0=0x123456, not xxreg0=0x00123456

pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
@hongliangl
Copy link
Contributor Author

/test-all

pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_builder_test.go Outdated Show resolved Hide resolved
Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

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

LGTM overall, a few nits for error check.

pkg/ovs/openflow/ofctrl_action_test.go Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_action_test.go Show resolved Hide resolved
@luolanzone
Copy link
Contributor

@tnqn @wenyingd please take a look as well, it would be better if we can close this in release 1.14. Thanks.

@luolanzone
Copy link
Contributor

/test-all

@tnqn @wenyingd could you take a look? Thanks.

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn tnqn merged commit dc0ca2d into antrea-io:main Oct 16, 2023
45 of 48 checks passed
@hongliangl hongliangl deleted the 20220906-ovs-ut branch October 16, 2023 06:26
@hongliangl
Copy link
Contributor Author

Thanks for merging and reviewing this PR @tnqn @luolanzone @wenyingd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test Issues or PRs related to unit and integration tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants