Terminate the ixia traffic generator at the end of the test run 53/40853/2
authorDeepak S <deepak.s@linux.intel.com>
Fri, 1 Sep 2017 05:55:33 +0000 (22:55 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Mon, 18 Sep 2017 05:27:41 +0000 (22:27 -0700)
Change-Id: I80501ab3662a58930939d849f0bde0e810154a39
Signed-off-by: Deepak S <deepak.s@linux.intel.com>
yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py

index 93e4969..1b2efe3 100644 (file)
@@ -60,6 +60,7 @@ class IxiaResourceHelper(ClientResourceHelper):
         self.rfc_helper = rfc_helper_type(self.scenario_helper)
         self.priv_ports = None
         self.pub_ports = None
+        self._connect()
 
     def _connect(self, client=None):
         self.client._connect(self.vnfd_helper)
@@ -68,8 +69,8 @@ class IxiaResourceHelper(ClientResourceHelper):
         return self.client.ix_get_statistics()
 
     def stop_collect(self):
-        self._terminated.value = 0
-        if self.client and self.client.ixnet:
+        self._terminated.value = 1
+        if self.client:
             self.client.ix_stop_traffic()
 
     def generate_samples(self, ports, key=None, default=None):
@@ -117,7 +118,6 @@ class IxiaResourceHelper(ClientResourceHelper):
         default = "00:00:00:00:00:00"
 
         self._build_ports()
-        self._connect()
 
         # we don't know client_file_name until runtime as instantiate
         client_file_name = \
@@ -142,24 +142,27 @@ class IxiaResourceHelper(ClientResourceHelper):
         ixia_file = find_relative_file("ixia_traffic.cfg",
                                        self.scenario_helper.scenario_cfg["task_path"])
         # Generate ixia traffic config...
-        while not self._terminated.value:
-            traffic_profile.execute_traffic(self, self.client, mac, ixia_file)
-            self.client_started.value = 1
-            time.sleep(WAIT_FOR_TRAFFIC)
+        try:
+            while not self._terminated.value:
+                traffic_profile.execute(self, self.client, mac, ixia_file)
+                self.client_started.value = 1
+                time.sleep(WAIT_FOR_TRAFFIC)
+                self.client.ix_stop_traffic()
+                samples = self.generate_samples()
+                self._queue.put(samples)
+                status, samples = traffic_profile.get_drop_percentage(self, samples, min_tol,
+                                                                      max_tol, self.client, mac,
+                                                                      ixia_file)
+
+                current = samples['CurrentDropPercentage']
+                if min_tol <= current <= max_tol or status == 'Completed':
+                    self._terminated.value = 1
+
             self.client.ix_stop_traffic()
-            samples = self.generate_samples(traffic_profile.ports)
             self._queue.put(samples)
-            status, samples = traffic_profile.get_drop_percentage(self, samples, min_tol,
-                                                                  max_tol, self.client, mac,
-                                                                  ixia_file)
-
-            current = samples['CurrentDropPercentage']
-            if min_tol <= current <= max_tol or status == 'Completed' or \
-                self.rfc_helper.is_done():
-                break
-
-        self.client.ix_stop_traffic()
-        self._queue.put(samples)
+        except Exception:
+            LOG.info("Run Traffic terminated")
+            pass
 
         if not self.rfc_helper.is_done():
             self._terminated.value = 1