Skip to content

Add unit tests for pkg/ovs/openflow#4221

Merged
tnqn merged 1 commit into
antrea-io:mainfrom
hongliangl:20220906-ovs-ut
Oct 16, 2023
Merged

Add unit tests for pkg/ovs/openflow#4221
tnqn merged 1 commit into
antrea-io:mainfrom
hongliangl:20220906-ovs-ut

Conversation

@hongliangl
Copy link
Copy Markdown
Contributor

@hongliangl hongliangl commented Sep 13, 2022

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

@codecov
Copy link
Copy Markdown

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 requested a review from wenyingd September 13, 2022 05:43
@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 requested a review from tnqn 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
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
@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
Copy Markdown
Contributor Author

This PR depends on #4258.

@hongliangl hongliangl requested a review from wenyingd October 13, 2022 00:23
@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
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
@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
Copy Markdown
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 2 times, most recently from 295ab33 to 5344de4 Compare December 21, 2022 08:59
@hongliangl hongliangl requested a review from luolanzone June 16, 2023 02:57
@hongliangl hongliangl force-pushed the 20220906-ovs-ut branch 3 times, most recently from 0c7d665 to 97dccca Compare June 16, 2023 07:27
Comment thread pkg/agent/openflow/pipeline.go
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Copy link
Copy Markdown
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.

Comment thread pkg/ovs/openflow/testing/mock_openflow.go
Comment thread pkg/ovs/openflow/utils.go
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
Copy Markdown
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
Copy Markdown
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.

Comment thread pkg/ovs/openflow/ofctrl_packetout_test.go
Comment thread pkg/ovs/openflow/ofctrl_packetout_test.go
@luolanzone
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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?

Comment thread pkg/agent/openflow/pipeline.go
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Value: &openflow15.ByteArrayField{Data: []byte{0x12, 0x34, 0x56}, Length: 3},
},
},
{
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
@hongliangl
Copy link
Copy Markdown
Contributor Author

/test-all

Comment thread pkg/ovs/openflow/ofctrl_action_test.go
Comment thread pkg/ovs/openflow/ofctrl_action_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Comment thread pkg/ovs/openflow/ofctrl_builder_test.go Outdated
Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
Copy link
Copy Markdown
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.

Comment thread pkg/ovs/openflow/ofctrl_action_test.go
Comment thread pkg/ovs/openflow/ofctrl_action_test.go
@luolanzone
Copy link
Copy Markdown
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
Copy Markdown
Contributor

/test-all

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

Copy link
Copy Markdown
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
@hongliangl hongliangl deleted the 20220906-ovs-ut branch October 16, 2023 06:26
@hongliangl
Copy link
Copy Markdown
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