X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FTrafficGenerator.py;h=e7c8c4829ae6bd575bb4256ce048bb4eb8edfae3;hb=6e9d38fbad8198f8647e3e71d12b5859490c21f2;hp=aa839dd80efd176828d1e6045f1589297e63caa9;hpb=35175924550d67f98fb1c2c50b0634656d29169e;p=csit.git diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index aa839dd80e..e7c8c4829a 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -520,9 +520,20 @@ class TrafficGenerator(AbstractRateProvider): :raises Exception: If loss occured. """ if self._loss is None: - raise Exception('The traffic generation has not been issued') + raise RuntimeError('The traffic generation has not been issued') if self._loss != '0': - raise Exception('Traffic loss occurred: {0}'.format(self._loss)) + raise RuntimeError('Traffic loss occurred: {0}'.format(self._loss)) + + def fail_if_no_traffic_forwarded(self): + """Fail if no traffic forwarded. + + :returns: nothing + :raises Exception: If no traffic forwarded. + """ + if self._received is None: + raise RuntimeError('The traffic generation has not been issued') + if self._received == '0': + raise RuntimeError('No traffic forwarded') def partial_traffic_loss_accepted(self, loss_acceptance, loss_acceptance_type):