Skip to content

Commit

Permalink
tests: Fix filtering of whole-second durations.
Browse files Browse the repository at this point in the history
Current macros are unable to filter whole seconds, e.g. 'duration:6s'.
This is causing random test failures, most frequently in CirrusCI:

  ./dpif-netdev.at:370: ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers
  --- -
  +++ /tmp/cirrus-ci-build/tests/testsuite.dir/at-groups/990/stdout
  @@ -1,5 +1,5 @@
   OFPST_METER reply (OF1.3) (xid=0x2):
  -meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands:
  +meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:6s bands:

Fix sed matches to correctly handle that scenario.
Repeating the [0-9\.] twice because it is hard to write a shorter
portable version with sed.

Acked-by: Mike Pattrick <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Oct 25, 2022
1 parent 77f7399 commit f7ae3f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests/dpif-netdev.at
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ m4_divert_push([PREPARE_TESTS])
# that vary from one run to another (e.g., timing and bond actions).
strip_timers () {
sed '
s/duration:[0-9]*\.[0-9]*/duration:0.0/
s/used:[0-9]*\.[0-9]*/used:0.0/
s/duration:[0-9\.][0-9\.]*/duration:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
'
}

strip_xout () {
sed '
s/mega_ufid:[-0-9a-f]* //
s/ufid:[-0-9a-f]* //
s/used:[0-9]*\.[0-9]*/used:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
s/actions:.*/actions: <del>/
s/packets:[0-9]*/packets:0/
s/bytes:[0-9]*/bytes:0/
Expand All @@ -26,7 +26,7 @@ strip_xout_keep_actions () {
sed '
s/mega_ufid:[-0-9a-f]* //
s/ufid:[-0-9a-f]* //
s/used:[0-9]*\.[0-9]*/used:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
s/packets:[0-9]*/packets:0/
s/bytes:[0-9]*/bytes:0/
' | sort
Expand All @@ -51,7 +51,7 @@ filter_hw_packet_netdev_dummy () {
filter_flow_dump () {
grep 'flow_dump ' | sed '
s/.*flow_dump //
s/used:[0-9]*\.[0-9]*/used:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
' | sort | uniq
}

Expand Down
2 changes: 1 addition & 1 deletion tests/stp.at
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ AT_CLEANUP
# Strips out uninteresting parts of flow output, as well as parts
# that vary from one run to another (e.g., timing and bond actions).
m4_define([STRIP_USED], [[sed '
s/used:[0-9]*\.[0-9]*/used:0.0/
s/used:[0-9\.][0-9\.]*/used:0.0/
s/duration=[0-9.]*s*/duration=Xs/
s/idle_age=[0-9]*,/idle_age=X,/
']])
Expand Down

0 comments on commit f7ae3f9

Please sign in to comment.