diff options
-rw-r--r-- | core/traffic_controller.py | 2 | ||||
-rw-r--r-- | testcases/testcase.py | 9 | ||||
-rw-r--r-- | tools/pkt_gen/trex/trex_client.py | 34 | ||||
-rwxr-xr-x | vsperf | 7 | ||||
-rw-r--r-- | vswitches/ovs.py | 36 |
5 files changed, 71 insertions, 17 deletions
diff --git a/core/traffic_controller.py b/core/traffic_controller.py index 1f21e57d..2a5b0350 100644 --- a/core/traffic_controller.py +++ b/core/traffic_controller.py @@ -164,6 +164,8 @@ class TrafficController(object): for(key, value) in list(item.items()): logging.info(" Key: " + str(key) + ", Value: " + str(value)) + if settings.getValue('CLEAN_OUTPUT'): + print(str(key) + ", " + str(value)) def get_results(self): """IResult interface implementation. diff --git a/testcases/testcase.py b/testcases/testcase.py index c13754bc..7f4ad9ac 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -207,7 +207,7 @@ class TestCase(object): self._k8s = S.getValue('K8S') if self._k8s: if S.getValue('EXT_VSWITCH'): - self._evfctl = extvswitchfctl.ExtVswitchFlowCtl() + self._evfctl = extvswitchflctl.ExtVswitchFlowCtl() def run_initialize(self): @@ -398,7 +398,8 @@ class TestCase(object): # dump vswitch flows before they are affected by VNF termination if not self._vswitch_none: - self._vswitch_ctl.dump_vswitch_connections() + if not S.getValue('CLEAN_OUTPUT'): + self._vswitch_ctl.dump_vswitch_connections() # garbage collection for case that TestSteps modify existing deployment self.step_stop_vnfs() @@ -413,7 +414,11 @@ class TestCase(object): self._testcase_start_time)) logging.info("Testcase execution time: %s", self._testcase_run_time) # report test results + if S.getValue('CLEAN_OUTPUT'): + print('BEGIN OF THE RESULTS') self.run_report() + if S.getValue('CLEAN_OUTPUT'): + print('END OF THE RESULTS') def _append_results(self, results): """ diff --git a/tools/pkt_gen/trex/trex_client.py b/tools/pkt_gen/trex/trex_client.py index ff9d5c79..680497ec 100644 --- a/tools/pkt_gen/trex/trex_client.py +++ b/tools/pkt_gen/trex/trex_client.py @@ -136,7 +136,15 @@ class Trex(ITrafficGenerator): else: raise RuntimeError('T-Rex: Trex host not defined') - ping = subprocess.Popen(cmd_ping, shell=True, stderr=subprocess.PIPE) + if settings.getValue('CLEAN_OUTPUT'): + ping = subprocess.Popen(cmd_ping, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + else: + ping = subprocess.Popen(cmd_ping, + shell=True, + stderr=subprocess.PIPE) output, error = ping.communicate() if ping.returncode: @@ -152,9 +160,16 @@ class Trex(ITrafficGenerator): self._trex_base_dir + "t-rex-64" - find_trex = subprocess.Popen(cmd_find_trex, - shell=True, - stderr=subprocess.PIPE) + if settings.getValue('CLEAN_OUTPUT'): + find_trex = subprocess.Popen(cmd_find_trex, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + else: + find_trex = subprocess.Popen(cmd_find_trex, + shell=True, + stderr=subprocess.PIPE) + output, error = find_trex.communicate() if find_trex.returncode: @@ -165,8 +180,12 @@ class Trex(ITrafficGenerator): % (self._trex_host_ip_addr, self._trex_base_dir)) try: - self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, - verbose_level='info') + if settings.getValue('CLEAN_OUTPUT'): + self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, + verbose_level='error') + else: + self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, + verbose_level='info') self._stlclient.connect() except STLError: raise RuntimeError('T-Rex: Cannot connect to T-Rex server. Please check if it is ' @@ -392,7 +411,8 @@ class Trex(ITrafficGenerator): self._stlclient.set_port_attr(my_ports, promiscuous=True) packet_1, packet_2 = self.create_packets(traffic, ports_info) - self.show_packet_info(packet_1, packet_2) + if not settings.getValue('CLEAN_OUTPUT'): + self.show_packet_info(packet_1, packet_2) stream_1, stream_2, stream_1_lat, stream_2_lat = Trex.create_streams(packet_1, packet_2, traffic) self._stlclient.add_streams(stream_1, ports=[0]) self._stlclient.add_streams(stream_2, ports=[1]) @@ -747,6 +747,13 @@ def main(): # if required, handle list-* operations handle_list_options(args) + # Using verbosity to run 'clean' test-runs. + if args['verbosity']: + settings.setValue('VERBOSITY', args['verbosity']) + settings.setValue('CLEAN_OUTPUT', True) + else: + settings.setValue('CLEAN_OUTPUT', False) + configure_logging(settings.getValue('VERBOSITY')) # CI build support diff --git a/vswitches/ovs.py b/vswitches/ovs.py index 853bef85..a77e898e 100644 --- a/vswitches/ovs.py +++ b/vswitches/ovs.py @@ -26,9 +26,9 @@ import pexpect from conf import settings from src.ovs import OFBridge, flow_key, flow_match -from vswitches.vswitch import IVSwitch from tools import tasks from tools.module_manager import ModuleManager +from vswitches.vswitch import IVSwitch # enable caching of flows if their number exceeds given limit _CACHE_FLOWS_LIMIT = 10 @@ -100,6 +100,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process): try: tasks.Process.start(self) + if settings.getValue('CLEAN_OUTPUT'): + self._disable_console_output() self.relinquish() except (pexpect.EOF, pexpect.TIMEOUT) as exc: self._logger.error("Exception during VSwitch start.") @@ -469,6 +471,15 @@ class IVSwitchOvs(IVSwitch, tasks.Process): self._logger.info('System reset after last run.') + def _disable_console_output(self): + """ + Configure vswitch to disable console output + """ + ovsappctl_tool_bin = settings.getValue('TOOLS')['ovs-appctl'] + tasks.run_task(['sudo', ovsappctl_tool_bin, 'vlog/set', ' console:off'], + self._logger, + 'Turning off the logs ...') + def _start_ovsdb(self): """Start ``ovsdb-server`` instance. @@ -483,13 +494,22 @@ class IVSwitchOvs(IVSwitch, tasks.Process): ovsdb_server_bin = settings.getValue('TOOLS')['ovsdb-server'] - tasks.run_background_task( - ['sudo', ovsdb_server_bin, - '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), - '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', - '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'], - self._logger, - 'Starting ovsdb-server...') + if settings.getValue('CLEAN_OUTPUT'): + tasks.run_background_task( + ['sudo', ovsdb_server_bin, + '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), + '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', + '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile', '--verbose=off'], + self._logger, + 'Starting ovsdb-server...') + else: + tasks.run_background_task( + ['sudo', ovsdb_server_bin, + '--remote=punix:%s' % os.path.join(settings.getValue('TOOLS')['ovs_var_tmp'], 'db.sock'), + '--remote=db:Open_vSwitch,Open_vSwitch,manager_options', + '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'], + self._logger, + 'Starting ovsdb-server...') def _kill_ovsdb(self): """Kill ``ovsdb-server`` instance. |