X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FTrafficGenerator.py;h=b7c8d6ef4eb449bd6ff9dccb158b4769fdf0242c;hb=f491bc6a03bae995321dc912661c4c628f4d156f;hp=a8083381d1abd6d3e197ca43701d99dac4c9da5f;hpb=92cbb44a89ca808df32e4a4cb137bed076a68a94;p=csit.git diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index a8083381d1..b7c8d6ef4e 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -33,7 +33,7 @@ class TGDropRateSearchImpl(DropRateSearch): super(TGDropRateSearchImpl, self).__init__() def measure_loss(self, rate, frame_size, loss_acceptance, - loss_acceptance_type, traffic_type): + loss_acceptance_type, traffic_type, skip_warmup=False): """Runs the traffic and evaluate the measured results. :param rate: Offered traffic load. @@ -41,11 +41,13 @@ class TGDropRateSearchImpl(DropRateSearch): :param loss_acceptance: Permitted drop ratio or frames count. :param loss_acceptance_type: Type of permitted loss. :param traffic_type: Traffic profile ([2,3]-node-L[2,3], ...). + :param skip_warmup: Start TRex without warmup traffic if true. :type rate: int :type frame_size: str :type loss_acceptance: float :type loss_acceptance_type: LossAcceptanceType :type traffic_type: str + :type skip_warmup: bool :returns: Drop threshold exceeded? (True/False) :rtype: bool :raises: NotImplementedError if TG is not supported. @@ -60,9 +62,15 @@ class TGDropRateSearchImpl(DropRateSearch): raise RuntimeError('TG subtype not defined') elif tg_instance.node['subtype'] == NodeSubTypeTG.TREX: unit_rate = str(rate) + self.get_rate_type_str() - tg_instance.trex_stl_start_remote_exec(self.get_duration(), - unit_rate, frame_size, - traffic_type) + if skip_warmup: + tg_instance.trex_stl_start_remote_exec(self.get_duration(), + unit_rate, frame_size, + traffic_type, + warmup_time=0) + else: + tg_instance.trex_stl_start_remote_exec(self.get_duration(), + unit_rate, frame_size, + traffic_type) loss = tg_instance.get_loss() sent = tg_instance.get_sent() if self.loss_acceptance_type_is_percentage(): @@ -185,8 +193,9 @@ class TrafficGenerator(object): ssh.connect(tg_node) (ret, _, _) = ssh.exec_command( - "sudo -E sh -c '{}/resources/tools/trex/" - "trex_installer.sh'".format(Constants.REMOTE_FW_DIR), + "sudo -E sh -c '{0}/resources/tools/trex/" + "trex_installer.sh {1}'".format(Constants.REMOTE_FW_DIR, + Constants.TREX_INSTALL_VERSION), timeout=1800) if int(ret) != 0: raise RuntimeError('TRex installation failed.') @@ -306,6 +315,24 @@ class TrafficGenerator(object): # critical error occurred raise RuntimeError('t-rex-64 startup failed') + @staticmethod + def is_trex_running(node): + """Check if TRex is running using pidof. + + :param node: Traffic generator node. + :type node: dict + :returns: True if TRex is running otherwise False. + :rtype: bool + :raises: RuntimeError if node type is not a TG. + """ + if node['type'] != NodeType.TG: + raise RuntimeError('Node type is not a TG') + + ssh = SSH() + ssh.connect(node) + ret, _, _ = ssh.exec_command_sudo("pidof t-rex") + return bool(int(ret) == 0) + @staticmethod def teardown_traffic_generator(node): """TG teardown.