Skip to content

Commit 3343033

Browse files
committed
Don't count pings while a guest OS is booting
This test is sending ICMP pings to microVMs. However since Machine#Start() only *starts* a microVM and not aware about the status of the guest OS, some packets are sent while the OS is booting, which would be the cause of the flakiness of the test. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent aab917d commit 3343033

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)