diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index bb1717d291..7bd0798e57 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -183,11 +183,10 @@ def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetlos return (False, 'Iperf UDP: Server report not found!') if (os.path.getsize(server_filename)==0): return (False, 'Iperf UDP: Log file is empty') - # Computing the requested bandwidth in float - statusTemplate = r'(?:|\[ *\d+\].*) +0\.0-\s*(?P[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P[0-9\.]+) (?P[kKMG])bits\/sec +(?P[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P[0-9\.]+)%\))' + statusTemplate = r'(?:|\[ *\d+\].*) +0\.0+-\s*(?P[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P[0-9\.]+) (?P[kKMG])bits\/sec +(?P[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P[0-9\.]+)%\))' with open(server_filename, 'r') as server_file: for line in server_file.readlines(): - result = re.search(statusTemplate, str(line)) + result = re.search(statusTemplate, str(line)) or result if result is None: return (False, 'Could not parse server report!') bitrate = float(result.group('bitrate')) @@ -555,11 +554,11 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', messages) return success - def Iperf2_Unidir(self,HTML,EPC,CONTAINERS): + def Iperf2_Unidir(self, HTML, EPC, CONTAINERS, infra_file="ci_infra.yaml"): if self.ue_ids == [] or self.svr_id == None or len(self.ue_ids) != 1: raise Exception("no module names in self.ue_ids or/and self.svr_id provided, multi UE scenario not supported") - ue = cls_module.Module_UE(self.ue_ids[0].strip(),self.nodes[0].strip()) - svr = cls_module.Module_UE(self.svr_id,self.svr_node) + ue = cls_module.Module_UE(self.ue_ids[0].strip(),self.nodes[0].strip(), infra_file) + svr = cls_module.Module_UE(self.svr_id,self.svr_node, infra_file) ueIP = ue.getIP() if not ueIP: return (False, f"UE {ue.getName()} has no IP address") @@ -577,7 +576,7 @@ class OaiCiTest(): with cls_cmd.getConnection(ue.getHost()) as cmd_ue, cls_cmd.getConnection(EPC.IPAddress) as cmd_svr: cmd_ue.run(f'rm /tmp/{server_filename}', reportNonZero=False) cmd_ue.run(f'{ue.getCmdPrefix()} timeout -vk3 {t} iperf -B {ueIP} -s -u -i1 >> /tmp/{server_filename} &', timeout=t) - cmd_svr.run(f'{svr.getCmdPrefix()} timeout -vk3 {t} iperf -c {ueIP} -B {svrIP} {iperf_opt} -i1', timeout=t) + cmd_svr.run(f'{svr.getCmdPrefix()} timeout -vk3 {t} iperf -c {ueIP} -B {svrIP} {iperf_opt} -i1 >> /dev/null', timeout=t) localPath = f'{os.getcwd()}' # note: copy iperf2 log to the directory for log collection cmd_ue.copyin(f'/tmp/{server_filename}', f'{localPath}/{logPath}/{server_filename}') diff --git a/ci-scripts/tests/iperf-analysis.py b/ci-scripts/tests/iperf-analysis.py index 53d5bdda1d..af261d6e4d 100644 --- a/ci-scripts/tests/iperf-analysis.py +++ b/ci-scripts/tests/iperf-analysis.py @@ -73,5 +73,17 @@ class TestIperfAnalysis(unittest.TestCase): self.assertEqual(msg, "Iperf3 UDP: Log file not present") self.assertFalse(success) + def test_iperf_analyzeV2UDP(self): + filename_ok = "tests/log/iperf_udp_v2_ok.log" + msg_filename_ok = "tests/log/iperf_udp_v2_ok.txt" + target_bitrate = "2.00" + bitrate_thresh = 80 + packetloss_thresh = 25 + with open(msg_filename_ok, 'r') as file: + expected_msg_ok = file.read().strip() + success, msg = cls_oaicitest.Iperf_analyzeV2UDP(filename_ok, bitrate_thresh, packetloss_thresh, target_bitrate) + self.assertEqual(msg, expected_msg_ok) + self.assertTrue(success) + if __name__ == '__main__': unittest.main() diff --git a/ci-scripts/tests/log/iperf_udp_v2_ok.log b/ci-scripts/tests/log/iperf_udp_v2_ok.log new file mode 100644 index 0000000000..ce53e36f4f --- /dev/null +++ b/ci-scripts/tests/log/iperf_udp_v2_ok.log @@ -0,0 +1,39 @@ +------------------------------------------------------------ +Server listening on UDP port 5001 +Binding to local address 10.0.2.2 +Receiving 1470 byte datagrams +UDP buffer size: 208 KByte (default) +------------------------------------------------------------ +[ 3] local 10.0.2.2 port 5001 connected with 10.0.2.1 port 45771 +[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams +[ 3] 0.0- 1.0 sec 258 KBytes 2.12 Mbits/sec 7.930 ms 0/ 180 (0%) +[ 3] 1.0- 2.0 sec 257 KBytes 2.11 Mbits/sec 7.839 ms 0/ 179 (0%) +[ 3] 2.0- 3.0 sec 256 KBytes 2.09 Mbits/sec 7.154 ms 0/ 178 (0%) +[ 3] 3.0- 4.0 sec 257 KBytes 2.11 Mbits/sec 7.834 ms 0/ 179 (0%) +[ 3] 4.0- 5.0 sec 258 KBytes 2.12 Mbits/sec 7.943 ms 0/ 180 (0%) +[ 3] 5.0- 6.0 sec 256 KBytes 2.09 Mbits/sec 6.986 ms 0/ 178 (0%) +[ 3] 6.0- 7.0 sec 250 KBytes 2.05 Mbits/sec 8.111 ms 0/ 174 (0%) +[ 3] 7.0- 8.0 sec 257 KBytes 2.11 Mbits/sec 8.026 ms 0/ 179 (0%) +[ 3] 8.0- 9.0 sec 258 KBytes 2.12 Mbits/sec 7.993 ms 0/ 180 (0%) +[ 3] 9.0-10.0 sec 258 KBytes 2.12 Mbits/sec 7.997 ms 0/ 180 (0%) +[ 3] 10.0-11.0 sec 251 KBytes 2.06 Mbits/sec 7.973 ms 0/ 175 (0%) +[ 3] 11.0-12.0 sec 258 KBytes 2.12 Mbits/sec 7.871 ms 0/ 180 (0%) +[ 3] 12.0-13.0 sec 257 KBytes 2.11 Mbits/sec 8.005 ms 0/ 179 (0%) +[ 3] 13.0-14.0 sec 258 KBytes 2.12 Mbits/sec 7.890 ms 0/ 180 (0%) +[ 3] 14.0-15.0 sec 250 KBytes 2.05 Mbits/sec 8.119 ms 0/ 174 (0%) +[ 3] 15.0-16.0 sec 260 KBytes 2.13 Mbits/sec 7.940 ms 0/ 181 (0%) +[ 3] 16.0-17.0 sec 258 KBytes 2.12 Mbits/sec 8.078 ms 0/ 180 (0%) +[ 3] 17.0-18.0 sec 251 KBytes 2.06 Mbits/sec 7.839 ms 0/ 175 (0%) +[ 3] 18.0-19.0 sec 257 KBytes 2.11 Mbits/sec 8.033 ms 0/ 179 (0%) +[ 3] 19.0-20.0 sec 260 KBytes 2.13 Mbits/sec 7.936 ms 0/ 181 (0%) +[ 3] 20.0-21.0 sec 250 KBytes 2.05 Mbits/sec 8.032 ms 0/ 174 (0%) +[ 3] 21.0-22.0 sec 260 KBytes 2.13 Mbits/sec 8.089 ms 0/ 181 (0%) +[ 3] 22.0-23.0 sec 256 KBytes 2.09 Mbits/sec 7.889 ms 0/ 178 (0%) +[ 3] 23.0-24.0 sec 258 KBytes 2.12 Mbits/sec 8.115 ms 0/ 180 (0%) +[ 3] 24.0-25.0 sec 253 KBytes 2.07 Mbits/sec 7.976 ms 0/ 176 (0%) +[ 3] 25.0-26.0 sec 256 KBytes 2.09 Mbits/sec 7.597 ms 0/ 178 (0%) +[ 3] 26.0-27.0 sec 258 KBytes 2.12 Mbits/sec 7.924 ms 0/ 180 (0%) +[ 3] 27.0-28.0 sec 254 KBytes 2.08 Mbits/sec 7.957 ms 0/ 177 (0%) +[ 3] 28.0-29.0 sec 257 KBytes 2.11 Mbits/sec 7.276 ms 0/ 179 (0%) +[ 3] 29.0-30.0 sec 253 KBytes 2.07 Mbits/sec 21.383 ms 0/ 176 (0%) +[ 3] 0.0-30.2 sec 7.50 MBytes 2.08 Mbits/sec 21.383 ms 0/ 5350 (0%) diff --git a/ci-scripts/tests/log/iperf_udp_v2_ok.txt b/ci-scripts/tests/log/iperf_udp_v2_ok.txt new file mode 100644 index 0000000000..edf56efbde --- /dev/null +++ b/ci-scripts/tests/log/iperf_udp_v2_ok.txt @@ -0,0 +1,5 @@ +Req Bitrate : 2.00 +Bitrate : 2.08 +Bitrate Perf: 104.00 % +Jitter : 21.383 +Packet Loss : 0.0 diff --git a/ci-scripts/tests/ping-iperf.py b/ci-scripts/tests/ping-iperf.py index 39d08823ff..94186de606 100644 --- a/ci-scripts/tests/ping-iperf.py +++ b/ci-scripts/tests/ping-iperf.py @@ -53,5 +53,17 @@ class TestPingIperf(unittest.TestCase): success = self.ci.Iperf(self.html, self.epc, self.cont, infra_file=infra_file) self.assertTrue(success) + def test_iperf2_unidir(self): + self.ci.iperf_args = "-u -t 5 -b 1M" + self.ci.svr_id = "test" + self.ci.svr_node = "localhost" + self.ci.iperf_packetloss_threshold = "0" + self.ci.iperf_bitrate_threshold = "0" + self.ci.iperf_profile = "balanced" + infra_file = "tests/config/infra_ping_iperf.yaml" + # TODO Should need nothing but options and UE(s) to use + success = self.ci.Iperf2_Unidir(self.html, self.epc, self.cont, infra_file=infra_file) + self.assertTrue(success) + if __name__ == '__main__': unittest.main()