[PATCH tck v2 1/5] Ping test: use domifstats to wait for dhcp to be setup in guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some guests may be slower to start than 30 seconds. Use domifstats
to wait for 10 packets to be sent by the guest (usually the DHCP ones
are the first ones).
---
 scripts/nwfilter/100-ping-still-working.t | 13 +++++++++++--
 scripts/nwfilter/210-no-mac-spoofing.t    | 13 +++++++++++--
 scripts/nwfilter/230-no-mac-broadcast.t   | 13 +++++++++++--
 scripts/nwfilter/240-no-arp-spoofing.t    | 13 +++++++++++--
 4 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/100-ping-still-working.t
index f65bf37..a20b95d 100644
--- a/scripts/nwfilter/100-ping-still-working.t
+++ b/scripts/nwfilter/100-ping-still-working.t
@@ -54,8 +54,17 @@ diag "Start domain";
 $dom->create;
 ok($dom->get_id() > 0, "running domain has an ID > 0");
 
-diag "Waiting 30 seconds for guest to finish booting";
-sleep(30);
+diag "Waiting for guest to finish booting";
+my $stats;
+my $tries = 0;
+do {
+    sleep(10);
+    $stats  = $dom->interface_stats("vnet0");
+    $tries++;
+} while ($stats->{"tx_packets"} < 10 && $tries < 10);
+
+# Wait a little bit more to make sure dhcp is started in the guest
+sleep(10);
 
 my $mac = get_first_macaddress($dom);
 diag "mac is $mac";
diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t
index 7e80216..b81fc4a 100644
--- a/scripts/nwfilter/210-no-mac-spoofing.t
+++ b/scripts/nwfilter/210-no-mac-spoofing.t
@@ -53,8 +53,17 @@ diag "Start domain";
 $dom->create;
 ok($dom->get_id() > 0, "running domain has an ID > 0");
 
-diag "Waiting 30 seconds for guest to finish booting";
-sleep(30);
+diag "Waiting for guest to finish booting";
+my $stats;
+my $tries = 0;
+do {
+    sleep(10);
+    $stats  = $dom->interface_stats("vnet0");
+    $tries++;
+} while ($stats->{"tx_packets"} < 10 && $tries < 10);
+
+# Wait a little bit more to make sure dhcp is started in the guest
+sleep(10);
 
 # ping guest first nic
 my $mac =  get_first_macaddress($dom);
diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t
index 2e616d6..16ce60d 100644
--- a/scripts/nwfilter/230-no-mac-broadcast.t
+++ b/scripts/nwfilter/230-no-mac-broadcast.t
@@ -52,8 +52,17 @@ diag "Start domain";
 $dom->create;
 ok($dom->get_id() > 0, "running domain has an ID > 0");
 
-diag "Waiting 30 seconds for guest to finish booting";
-sleep(30);
+diag "Waiting for guest to finish booting";
+my $stats;
+my $tries = 0;
+do {
+    sleep(10);
+    $stats  = $dom->interface_stats("vnet0");
+    $tries++;
+} while ($stats->{"tx_packets"} < 10 && $tries < 10);
+
+# Wait a little bit more to make sure dhcp is started in the guest
+sleep(10);
 
 # ping guest first nic
 my $mac =  get_first_macaddress($dom);
diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-no-arp-spoofing.t
index 596a0ce..6b346aa 100644
--- a/scripts/nwfilter/240-no-arp-spoofing.t
+++ b/scripts/nwfilter/240-no-arp-spoofing.t
@@ -54,8 +54,17 @@ diag "Start domain";
 $dom->create;
 ok($dom->get_id() > 0, "running domain has an ID > 0");
 
-diag "Waiting 30 seconds for guest to finish booting";
-sleep(30);
+diag "Waiting for guest to finish booting";
+my $stats;
+my $tries = 0;
+do {
+    sleep(10);
+    $stats  = $dom->interface_stats("vnet0");
+    $tries++;
+} while ($stats->{"tx_packets"} < 10 && $tries < 10);
+
+# Wait a little bit more to make sure dhcp is started in the guest
+sleep(10);
 
 # ping guest first nic
 my $mac =  get_first_macaddress($dom);
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]