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

Fix unit tests that rely on pseudo-random numbers #4148

Merged
merged 1 commit into from
Aug 25, 2022

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Aug 24, 2022

Test_ofPacketOutBuilder_Done relies on specific pseudo-random numbers to
be generated and will fail if another test also calls the pseudo-random
number generator. This patch creates a dedicated random number generator
for ofPacketOutBuilder and specifies a hardcoded seed for unit tests to
make test outputs predictable.

Signed-off-by: Quan Tian qtian@vmware.com

@tnqn tnqn added the area/test Issues or PRs related to unit and integration tests. label Aug 24, 2022
@codecov
Copy link

codecov bot commented Aug 24, 2022

Codecov Report

Merging #4148 (aaad71d) into main (3d5c617) will increase coverage by 0.65%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4148      +/-   ##
==========================================
+ Coverage   66.00%   66.65%   +0.65%     
==========================================
  Files         304      304              
  Lines       46619    47252     +633     
==========================================
+ Hits        30769    31494     +725     
+ Misses      13443    13323     -120     
- Partials     2407     2435      +28     
Flag Coverage Δ
e2e-tests 39.37% <54.54%> (?)
integration-tests 34.89% <54.54%> (+<0.01%) ⬆️
kind-e2e-tests 49.38% <54.54%> (+0.12%) ⬆️
unit-tests 45.01% <100.00%> (+0.04%) ⬆️
Impacted Files Coverage Δ
pkg/ovs/openflow/ofctrl_packetout.go 80.55% <100.00%> (+0.21%) ⬆️
pkg/cni/client.go 62.82% <0.00%> (-14.96%) ⬇️
pkg/agent/cniserver/ipam/ipam_service.go 51.68% <0.00%> (-12.36%) ⬇️
pkg/apiserver/certificate/certificate.go 70.37% <0.00%> (-6.49%) ⬇️
...r/ipseccertificate/ipsec_certificate_controller.go 57.52% <0.00%> (-6.00%) ⬇️
pkg/ipam/poolallocator/allocator.go 49.76% <0.00%> (-5.96%) ⬇️
pkg/agent/multicast/mcast_route.go 58.55% <0.00%> (-4.13%) ⬇️
pkg/util/ip/ip.go 82.11% <0.00%> (-3.26%) ⬇️
pkg/agent/route/route_linux.go 50.38% <0.00%> (-2.81%) ⬇️
...trollers/multicluster/resourceexport_controller.go 75.13% <0.00%> (-2.46%) ⬇️
... and 39 more

Test_ofPacketOutBuilder_Done relies on specific pseudo-random numbers to
be generated and will fail if another test also calls the pseudo-random
number generator. This patch creates a dedicated random number generator
for ofPacketOutBuilder and specifies a hardcoded seed for unit tests to
make test outputs predictable.

Signed-off-by: Quan Tian <qtian@vmware.com>
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM

@antoninbas
Copy link
Contributor

/test-all

@antoninbas antoninbas merged commit 52db699 into antrea-io:main Aug 25, 2022
wenqiq pushed a commit to wenqiq/antrea that referenced this pull request Oct 18, 2022
Test_ofPacketOutBuilder_Done relies on specific pseudo-random numbers to
be generated and will fail if another test also calls the pseudo-random
number generator. This patch creates a dedicated random number generator
for ofPacketOutBuilder and specifies a hardcoded seed for unit tests to
make test outputs predictable.

Signed-off-by: Quan Tian <qtian@vmware.com>
wenqiq pushed a commit to wenqiq/antrea that referenced this pull request Oct 19, 2022
Test_ofPacketOutBuilder_Done relies on specific pseudo-random numbers to
be generated and will fail if another test also calls the pseudo-random
number generator. This patch creates a dedicated random number generator
for ofPacketOutBuilder and specifies a hardcoded seed for unit tests to
make test outputs predictable.

Signed-off-by: Quan Tian <qtian@vmware.com>
heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
Test_ofPacketOutBuilder_Done relies on specific pseudo-random numbers to
be generated and will fail if another test also calls the pseudo-random
number generator. This patch creates a dedicated random number generator
for ofPacketOutBuilder and specifies a hardcoded seed for unit tests to
make test outputs predictable.

Signed-off-by: Quan Tian <qtian@vmware.com>
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.

2 participants