mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
Add configurable infra for Iperf2_Unidir, test, fixes
Add a possibility to use an "infrastructure YAML file" to configure both ends of the iperf2 call through a file. Fix bugs in Iperf2: at least on my machine, iperf2 start time is logged at 0.00 not 0.0, so update the regex to match both. Do not overwrite results if the matched regex (otherwise, the result might be None at the end) and suppress server output. Add a unit test to test that this function actually works (on my machine, with iperf v2.2.1), as well as a unit test for analysis.
This commit is contained in:
@@ -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<duration>[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P<bitrate>[0-9\.]+) (?P<magnitude>[kKMG])bits\/sec +(?P<jitter>[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P<packetloss>[0-9\.]+)%\))'
|
||||
statusTemplate = r'(?:|\[ *\d+\].*) +0\.0+-\s*(?P<duration>[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P<bitrate>[0-9\.]+) (?P<magnitude>[kKMG])bits\/sec +(?P<jitter>[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P<packetloss>[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}')
|
||||
|
||||
@@ -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()
|
||||
|
||||
39
ci-scripts/tests/log/iperf_udp_v2_ok.log
Normal file
39
ci-scripts/tests/log/iperf_udp_v2_ok.log
Normal file
@@ -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%)
|
||||
5
ci-scripts/tests/log/iperf_udp_v2_ok.txt
Normal file
5
ci-scripts/tests/log/iperf_udp_v2_ok.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Req Bitrate : 2.00
|
||||
Bitrate : 2.08
|
||||
Bitrate Perf: 104.00 %
|
||||
Jitter : 21.383
|
||||
Packet Loss : 0.0
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user