Skip to content

Commit

Permalink
1. fix rule test failed when rule add slow.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangling142 authored and aboch committed Dec 27, 2024
1 parent 976bd8d commit 26ee0e2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package netlink
import (
"net"
"testing"
"time"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -583,11 +584,18 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rule := tt.preRun()
wantRules, wantErr := tt.setupWant(rule)

rules, err := RuleListFiltered(family, tt.ruleFilter, tt.filterMask)
for i := 0; i < len(wantRules); i++ {
if len(wantRules) == len(rules) {
break
}
time.Sleep(1 * time.Second) // wait rule take effect
rules, err = RuleListFiltered(family, tt.ruleFilter, tt.filterMask)
}
tt.postRun(rule)

wantRules, wantErr := tt.setupWant(rule)

if len(wantRules) != len(rules) {
t.Errorf("Expected len: %d, got: %d", len(wantRules), len(rules))
} else {
Expand Down

0 comments on commit 26ee0e2

Please sign in to comment.