diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index a31edee7d4..d1f972d708 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -59,6 +59,40 @@ logging.getLogger("matplotlib").setLevel(logging.WARNING) import matplotlib.pyplot as plt import numpy as np +#----------------------------------------------------------- +# Helper functions used here and in other classes +#----------------------------------------------------------- +def Iperf_ComputeModifiedBW(idx, ue_num, profile, args): + result = re.search('-b\s*(?P[0-9\.]+)(?P[KMG])', str(args)) + if result is None: + raise Exception('Iperf bandwidth not found or in incorrect format!') + iperf_bandwidth = result.group('iperf_bandwidth') + if profile == 'balanced': + iperf_bandwidth_new = float(iperf_bandwidth)/ue_num + if profile == 'single-ue': + iperf_bandwidth_new = float(iperf_bandwidth) + if profile == 'unbalanced': + # residual is 2% of max bw + residualBW = float(iperf_bandwidth) / 50 + if idx == 0: + iperf_bandwidth_new = float(iperf_bandwidth) - ((ue_num - 1) * residualBW) + else: + iperf_bandwidth_new = residualBW + iperf_bandwidth_str = result.group(0) + iperf_bandwidth_unit = result.group(2) + iperf_bandwidth_str_new = f"-b {'%.2f' % iperf_bandwidth_new}{iperf_bandwidth_unit}" + result = re.sub(iperf_bandwidth_str, iperf_bandwidth_str_new, str(args)) + if result is None: + raise Exception('Calculate Iperf bandwidth failed!') + return result + +def Iperf_ComputeTime(args): + result = re.search('-t\s*(?P\d+)', str(args)) + if result is None: + raise Exception('Iperf time not found!') + return int(result.group('iperf_time')) + + #----------------------------------------------------------- # OaiCiTest Class Definition #----------------------------------------------------------- @@ -605,38 +639,6 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', messages) self.AutoTerminateUEandeNB(HTML,RAN,EPC,CONTAINERS) - def Iperf_ComputeTime(self): - result = re.search('-t (?P\d+)', str(self.iperf_args)) - if result is None: - logging.debug('\u001B[1;37;41m Iperf time Not Found! \u001B[0m') - sys.exit(1) - return result.group('iperf_time') - - def Iperf_ComputeModifiedBW(self, idx, ue_num): - result = re.search('-b (?P[0-9\.]+)[KMG]', str(self.iperf_args)) - if result is None: - logging.error('\u001B[1;37;41m Iperf bandwidth Not Found! \u001B[0m') - sys.exit(1) - iperf_bandwidth = result.group('iperf_bandwidth') - if self.iperf_profile == 'balanced': - iperf_bandwidth_new = float(iperf_bandwidth)/ue_num - if self.iperf_profile == 'single-ue': - iperf_bandwidth_new = float(iperf_bandwidth) - if self.iperf_profile == 'unbalanced': - # residual is 2% of max bw - residualBW = float(iperf_bandwidth) / 50 - if idx == 0: - iperf_bandwidth_new = float(iperf_bandwidth) - ((ue_num - 1) * residualBW) - else: - iperf_bandwidth_new = residualBW - iperf_bandwidth_str = f'-b {iperf_bandwidth}' - iperf_bandwidth_str_new = f"-b {'%.2f' % iperf_bandwidth_new}" - result = re.sub(iperf_bandwidth_str, iperf_bandwidth_str_new, str(self.iperf_args)) - if result is None: - logging.error('\u001B[1;37;41m Calculate Iperf bandwidth Failed! \u001B[0m') - sys.exit(1) - return result - def Iperf_analyzeV2TCPOutput(self, SSH, filename): SSH.command(f'awk -f /tmp/tcp_iperf_stats.awk {filename}', '\$', 5)