Skip to content

Commit 25d8177

Browse files
authored
Merge pull request #191 from kzys/relax-ping
Don't count pings while a guest OS is booting
2 parents aab917d + 3343033 commit 25d8177

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

network_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,23 @@ func startCNIMachine(t *testing.T, ctx context.Context, m *Machine) string {
453453
}
454454

455455
func testPing(t *testing.T, ip string, count int, timeout time.Duration) {
456+
// First, send one ping to make sure the machine is up
456457
pinger, err := ping.NewPinger(ip)
457458
require.NoError(t, err, "failed to create pinger")
459+
pinger.SetPrivileged(true)
460+
461+
pinger.Count = 1
462+
pinger.Timeout = 5 * time.Second
463+
pinger.Run()
464+
465+
// Then send multiple pings to check that the network is working correctly
466+
pinger, err = ping.NewPinger(ip)
467+
require.NoError(t, err, "failed to create pinger")
468+
pinger.SetPrivileged(true)
458469
pinger.Count = count
459470
pinger.Timeout = timeout
460-
pinger.SetPrivileged(true)
461471
pinger.Run()
472+
462473
pingStats := pinger.Statistics()
463474
assert.Equal(t, pinger.Count, pingStats.PacketsRecv, "machine did not respond to all pings")
464475
}

0 commit comments

Comments
 (0)