From: Ondrej Lichtner <olichtne(a)redhat.com>
Instead of waiting an arbitrary 60 seconds for the guest to start then
trying a single ssh connection we should be repeatedly trying to ssh
connect until it succeeds and set an upper limit.
For several past runs the guest startup time was much more unpredictable
(maybe due to more isolated cores on the host?) so this upper time limit
should be much larger. The implemented loop should try 60 times to
connect with 5s waits in between tries. In the worst case scenario this
should be enough of an upper bound.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
.../regression_tests/phase3/ovs-dpdk-pvp.py | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/recipes/regression_tests/phase3/ovs-dpdk-pvp.py
b/recipes/regression_tests/phase3/ovs-dpdk-pvp.py
index 6b16270..c46999f 100644
--- a/recipes/regression_tests/phase3/ovs-dpdk-pvp.py
+++ b/recipes/regression_tests/phase3/ovs-dpdk-pvp.py
@@ -4,6 +4,7 @@ import paramiko
import logging
from tempfile import NamedTemporaryFile
from lnst.Common.Utils import bool_it, std_deviation, dict_to_dot, Noop
+from lnst.Common.Logs import log_exc_traceback
from lnst.Controller.Task import ctl
from lnst.Controller.PerfRepoUtils import perfrepo_baseline_to_dict
from lnst.RecipeCommon.ModuleWrap import ping
@@ -298,7 +299,19 @@ h2.run("virsh start %s" % guest_virtname)
#============================================
# Host2 wait for guest start
#============================================
-ctl.wait(60)
+
+guest = paramiko.SSHClient()
+guest.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+tries = 60
+while tries:
+ logging.info("Connecting to guest, %d tries remaining" % tries)
+ tries -= 1
+ try:
+ guest.connect(guest_hostname, username=guest_username, password=guest_password)
+ break
+ except paramiko.ssh_exception.NoValidConnectionsError as e:
+ logging.debug(str(e))
+ ctl.wait(5)
#============================================
# Host2 add openvswitch flows between DPDK NICs and Guest NICs
@@ -314,10 +327,6 @@ h2.run("ovs-ofctl add-flow br0 in_port=22,action=12")
# Guest configure DPDK for vhostuser nics
#============================================
-guest = paramiko.SSHClient()
-guest.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-guest.connect(guest_hostname, username=guest_username, password=guest_password)
-
run_ssh_command_on_guest("service irqbalance stop", guest, h2, guest_virtname)
run_ssh_command_on_guest("MASK=1; for i in `ls -d /proc/irq/[0-9]*` ; do echo $MASK
> ${i}/smp_affinity ; done", guest, h2, guest_virtname)
--
2.19.0