Skip to content

Commit 26ee0e2

Browse files
wangling142aboch
authored andcommitted
1. fix rule test failed when rule add slow.
1 parent 976bd8d commit 26ee0e2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

rule_test.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package netlink
66
import (
77
"net"
88
"testing"
9+
"time"
910

1011
"golang.org/x/sys/unix"
1112
)
@@ -583,11 +584,18 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) {
583584
for _, tt := range tests {
584585
t.Run(tt.name, func(t *testing.T) {
585586
rule := tt.preRun()
587+
wantRules, wantErr := tt.setupWant(rule)
588+
586589
rules, err := RuleListFiltered(family, tt.ruleFilter, tt.filterMask)
590+
for i := 0; i < len(wantRules); i++ {
591+
if len(wantRules) == len(rules) {
592+
break
593+
}
594+
time.Sleep(1 * time.Second) // wait rule take effect
595+
rules, err = RuleListFiltered(family, tt.ruleFilter, tt.filterMask)
596+
}
587597
tt.postRun(rule)
588598

589-
wantRules, wantErr := tt.setupWant(rule)
590-
591599
if len(wantRules) != len(rules) {
592600
t.Errorf("Expected len: %d, got: %d", len(wantRules), len(rules))
593601
} else {

0 commit comments

Comments
 (0)