Merge "Added NSB descriptors for vCMTS testcase"
[yardstick.git] / yardstick / network_services / vnf_generic / vnf / prox_helpers.py
index 5d98003..3507315 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Intel Corporation
+# Copyright (c) 2018-2019 Intel Corporation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -347,7 +347,7 @@ class ProxSocketHelper(object):
         LOG.debug("Received data from socket: [%s]", ret_str)
         return status, ret_str
 
-    def get_data(self, pkt_dump_only=False, timeout=0.01):
+    def get_data(self, pkt_dump_only=False, timeout=10.0):
         """ read data from the socket """
 
         # This method behaves slightly differently depending on whether it is
@@ -870,6 +870,30 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
         file_str[1] = self.additional_files[base_name]
         return '"'.join(file_str)
 
+    def _make_core_list(self, inputStr):
+
+        my_input = inputStr.split("core ", 1)[1]
+        ok_list = set()
+
+        substrs = [x.strip() for x in my_input.split(',')]
+        for i in substrs:
+            try:
+                ok_list.add(int(i))
+
+            except ValueError:
+                try:
+                    substr = [int(k.strip()) for k in i.split('-')]
+                    if len(substr) > 1:
+                        startstr = substr[0]
+                        endstr = substr[len(substr) - 1]
+                        for z in range(startstr, endstr + 1):
+                            ok_list.add(z)
+                except ValueError:
+                    LOG.error("Error in cores list ... resuming ")
+                    return ok_list
+
+        return ok_list
+
     def generate_prox_config_file(self, config_path):
         sections = []
         prox_config = ConfigParser(config_path, sections)
@@ -889,6 +913,18 @@ class ProxDpdkVnfSetupEnvHelper(DpdkVnfSetupEnvHelper):
                     if section_data[0] == "mac":
                         section_data[1] = "hardware"
 
+        # adjust for range of cores
+        new_sections = []
+        for section_name, section in sections:
+            if section_name.startswith('core') and section_name.find('$') == -1:
+                    core_list = self._make_core_list(section_name)
+                    for core in core_list:
+                        new_sections.append(["core " + str(core), section])
+            else:
+                new_sections.append([section_name, section])
+
+        sections = new_sections
+
         # search for dst mac
         for _, section in sections:
             for section_data in section:
@@ -1110,7 +1146,7 @@ class ProxResourceHelper(ClientResourceHelper):
             self._test_type = self.setup_helper.find_in_section('global', 'name', None)
         return self._test_type
 
-    def run_traffic(self, traffic_profile, *args):
+    def run_traffic(self, traffic_profile):
         self._queue.cancel_join_thread()
         self.lower = 0.0
         self.upper = 100.0