From deea27f8e9c99b0a547b4c8c2f39dd99d5c4f1a8 Mon Sep 17 00:00:00 2001 From: DanielMartinBuckley Date: Wed, 23 Jan 2019 11:11:00 +0000 Subject: Trex client not starting in 4 port baremetal JIRA: YARDSTICK-1589 After calling STLclient.connect() there is no check if connection was sucessfull or not. Added a check for success on connect, retry if failure and disconnect and connect on timeout. If still connect failed then do not resume .. end with LOG.critial and exit. Change-Id: Ifd306b7920d9acbc16681cf79bf952d5af31eb64 Signed-off-by: Daniel Martin Buckley --- .../network_services/vnf_generic/vnf/sample_vnf.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py index 6ae393bc4..aec085057 100644 --- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py @@ -405,6 +405,10 @@ class ClientResourceHelper(ResourceHelper): try: self._build_ports() self.client = self._connect() + if self.client is None: + LOG.critical("Failure to Connect ... unable to continue") + return + self.client.reset(ports=self.all_ports) self.client.remove_all_streams(self.all_ports) # remove all streams traffic_profile.register_generator(self) @@ -454,16 +458,28 @@ class ClientResourceHelper(ResourceHelper): server=self.vnfd_helper.mgmt_interface["ip"], verbose_level=LoggerApi.VERBOSE_QUIET) - # try to connect with 5s intervals, 30s max + # try to connect with 5s intervals for idx in range(6): try: client.connect() - break + for idx2 in range(6): + if client.is_connected(): + return client + LOG.info("Waiting to confirm connection %s .. Attempt %s", + idx, idx2) + time.sleep(1) + client.disconnect(stop_traffic=True, release_ports=True) except STLError: LOG.info("Unable to connect to Trex Server.. Attempt %s", idx) time.sleep(5) - return client + if client.is_connected(): + return client + else: + LOG.critical("Connection failure ..TRex username: %s server: %s", + self.vnfd_helper.mgmt_interface["user"], + self.vnfd_helper.mgmt_interface["ip"]) + return None class Rfc2544ResourceHelper(object): -- cgit 1.2.3-korg