X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FTrafficGenerator.py;h=88adcc4542bfe58454da3e11bc35c8ded7e4f886;hb=refs%2Fchanges%2F66%2F9366%2F14;hp=0f25ebe42e52d7f0eaa53110cd2f36c0969e2079;hpb=b92b5be7d4bbbf523812f774bb2e539ab2081cf6;p=csit.git diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 0f25ebe42e..88adcc4542 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -184,19 +184,17 @@ class TrafficGenerator(object): self._node = tg_node if tg_node['subtype'] == NodeSubTypeTG.TREX: - trex_path = "/opt/trex-core-2.25" + trex_path = "/opt/trex-core-2.34" ssh = SSH() ssh.connect(tg_node) - (ret, stdout, stderr) = ssh.exec_command( - "sudo -E sh -c '{}/resources/tools/t-rex/" - "t-rex-installer.sh'".format(Constants.REMOTE_FW_DIR), + (ret, _, _) = ssh.exec_command( + "sudo -E sh -c '{}/resources/tools/trex/" + "trex_installer.sh'".format(Constants.REMOTE_FW_DIR), timeout=1800) if int(ret) != 0: - logger.error('trex installation failed: {0}'.format( - stdout + stderr)) - raise RuntimeError('Installation of TG failed') + raise RuntimeError('TRex installation failed.') if1_pci = topo.get_interface_pci_addr(tg_node, tg_if1) if2_pci = topo.get_interface_pci_addr(tg_node, tg_if2) @@ -229,7 +227,7 @@ class TrafficGenerator(object): if1_adj_mac_hex = "0x"+if1_adj_mac.replace(":", ",0x") if2_adj_mac_hex = "0x"+if2_adj_mac.replace(":", ",0x") - (ret, stdout, stderr) = ssh.exec_command( + (ret, _, _) = ssh.exec_command( "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n" "- port_limit : 2\n" " version : 2\n" @@ -244,8 +242,6 @@ class TrafficGenerator(object): if1_adj_mac_hex, if1_mac_hex, if2_adj_mac_hex, if2_mac_hex)) if int(ret) != 0: - logger.error("failed to create t-rex config: {}"\ - .format(stdout + stderr)) raise RuntimeError('trex config generation error') max_startup_retries = 3 @@ -255,26 +251,26 @@ class TrafficGenerator(object): "sh -c 'pgrep t-rex && sudo pkill t-rex && sleep 3'") # configure T-rex - (ret, stdout, stderr) = ssh.exec_command( + (ret, _, _) = ssh.exec_command( "sh -c 'cd {0}/scripts/ && sudo ./trex-cfg'"\ .format(trex_path)) if int(ret) != 0: - logger.error('trex-cfg failed: {0}'.format(stdout + stderr)) raise RuntimeError('trex-cfg failed') # start T-rex (ret, _, _) = ssh.exec_command( "sh -c 'cd {0}/scripts/ && " - "sudo nohup ./t-rex-64 -i -c 7 --iom 0 > /dev/null 2>&1 &'" - "> /dev/null"\ + "sudo nohup ./t-rex-64 -i -c 7 --iom 0 > /tmp/trex.log " + "2>&1 &' > /dev/null"\ .format(trex_path)) if int(ret) != 0: + ssh.exec_command("sh -c 'cat /tmp/trex.log'") raise RuntimeError('t-rex-64 startup failed') # get T-rex server info (ret, _, _) = ssh.exec_command( "sh -c 'sleep 3; " - "{0}/resources/tools/t-rex/t-rex-server-info.py'"\ + "{0}/resources/tools/trex/trex_server_info.py'"\ .format(Constants.REMOTE_FW_DIR), timeout=120) if int(ret) == 0: @@ -301,10 +297,9 @@ class TrafficGenerator(object): if node['subtype'] == NodeSubTypeTG.TREX: ssh = SSH() ssh.connect(node) - (ret, stdout, stderr) = ssh.exec_command( + (ret, _, _) = ssh.exec_command( "sh -c 'sudo pkill t-rex && sleep 3'") if int(ret) != 0: - logger.error('pkill t-rex failed: {0}'.format(stdout + stderr)) raise RuntimeError('pkill t-rex failed') @staticmethod @@ -320,8 +315,8 @@ class TrafficGenerator(object): ssh.connect(node) (ret, _, _) = ssh.exec_command( - "sh -c '{}/resources/tools/t-rex/" - "t-rex-stateless-stop.py'".format(Constants.REMOTE_FW_DIR)) + "sh -c '{}/resources/tools/trex/" + "trex_stateless_stop.py'".format(Constants.REMOTE_FW_DIR)) if int(ret) != 0: raise RuntimeError('T-rex stateless runtime error') @@ -355,12 +350,12 @@ class TrafficGenerator(object): _latency = "--latency" if latency else "" _p0, _p1 = (2, 1) if self._ifaces_reordered else (1, 2) - profile_path = ("{0}/resources/tools/t-rex/stream_profiles/" + profile_path = ("{0}/resources/traffic_profiles/trex/" "{1}.py".format(Constants.REMOTE_FW_DIR, traffic_type)) (ret, stdout, _) = ssh.exec_command( "sh -c " - "'{0}/resources/tools/t-rex/t-rex-stateless-profile.py " + "'{0}/resources/tools/trex/trex_stateless_profile.py " "--profile {1} " "--duration {2} " "--frame_size {3} "