blob: 8d4cb5a04f89ab557f716ab01aa5fcc8a4beca63 [file] [log] [blame]
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +01001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
Andre Puschmann44620672021-04-15 10:50:36 +02003import os
4
5# Overlay suite-specific templates folder if it exists
6if os.path.isdir(os.path.join(os.path.dirname(__file__), 'templates')):
7 tenv.set_overlay_template_dir(os.path.join(os.path.dirname(__file__), 'templates'))
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +01008
AlaiaL63d33de2021-05-10 16:30:25 +02009# Retrieve the number of physical ue from the test suite configuration.
10test_config = tenv.config_test_specific()
11nof_ue = int(test_config.get("nof_physical_ue", 1))
12
13print(f'Number of physical ue: {nof_ue}')
14
15ue_li = []
16
17# Get the ue from the test configuration.
18for n in range(0, nof_ue):
19 ue_li.append(tenv.modem())
20 print(f'ue index{n}: {ue_li[n]}')
21
Pau Espin Pedrol40c7bc72020-05-05 13:41:42 +020022epc = tenv.epc()
23enb = tenv.enb()
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010024
AlaiaL63d33de2021-05-10 16:30:25 +020025iperf3srv = []
26for n in range(0, nof_ue):
27 iperf3srv.append(tenv.iperf3srv({'addr': epc.tun_addr()}))
28 iperf3srv[n].set_run_node(epc.run_node())
29 iperf3srv[n].set_port(iperf3srv[n].DEFAULT_SRV_PORT + n)
30
31# Set the iperf clients in the ue.
32iperf3cli = []
33for n in range(0, nof_ue):
34 iperf3cli.append(iperf3srv[n].create_client())
35 iperf3cli[n].set_run_node(ue_li[n].run_node())
36
37for n in range(0, nof_ue):
38 epc.subscriber_add(ue_li[n])
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010039epc.start()
AlaiaL63d33de2021-05-10 16:30:25 +020040
41enb.ue_add(ue_li[0])
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010042enb.start(epc)
43
44print('waiting for ENB to connect to EPC...')
45wait(epc.enb_is_connected, enb)
46print('ENB is connected to EPC')
47
AlaiaL63d33de2021-05-10 16:30:25 +020048for n in range(0, nof_ue):
49 ue_li[n].connect(enb)
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010050
AlaiaL63d33de2021-05-10 16:30:25 +020051for n in range(0, nof_ue):
52 iperf3srv[n].start()
Pau Espin Pedrold84a8382020-05-25 14:23:37 +020053
AlaiaL63d33de2021-05-10 16:30:25 +020054proc_li = []
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010055
AlaiaL63d33de2021-05-10 16:30:25 +020056# Attach all the ue's.
57for n in range(0, nof_ue):
58 max_rate = enb.ue_max_rate(downlink=True, num_carriers=ue_li[n].num_carriers);
59 client = iperf3cli[n].prepare_test_proc(iperf3cli[n].DIR_DL, ue_li[n].netns(), bitrate=max_rate)
60 print(f'Iperf client type: {type(client)}')
61 proc_li.append(client)
Pau Espin Pedrolc8b0f932020-02-11 17:45:26 +010062
AlaiaL63d33de2021-05-10 16:30:25 +020063# Wait until all ue are attached.
64for n in range(0, nof_ue):
65 print(f'waiting for UE {n} to attach...')
66 wait(ue_li[n].is_registered)
67 print(f'UE {n} is attached')
Pau Espin Pedrol3a0dea62020-05-21 14:54:46 +020068
AlaiaL63d33de2021-05-10 16:30:25 +020069# Execute the iperfs and wait for its finish.
70try:
71 for proc in proc_li:
72 proc.launch()
73 for proc in proc_li:
74 proc.wait()
75except Exception as e:
76 for proc in proc_li:
77 try:
78 proc.terminate()
79 except Exception:
80 print("Exception while terminanting process %r" % repr(process))
81 raise e
82
83for n in range(0, nof_ue):
84 iperf3cli[n].print_results()
85 iperf3srv[n].print_results(iperf3cli[n].proto() == iperf3cli[n].PROTO_UDP)
Pau Espin Pedrol151b08a2020-03-02 14:14:27 +010086
Andre Puschmannd253a102020-10-28 21:11:14 +010087# 80% of the maximum rate for half of the test duration
AlaiaL63d33de2021-05-10 16:30:25 +020088out = ''
89for n in range(0, nof_ue):
90 half_duration = int(round(iperf3cli[n].time_sec() / 2))
91 max_rate = enb.ue_max_rate(downlink=True, num_carriers=ue_li[n].num_carriers);
92 res_str = ue_li[n].verify_metric(max_rate * 0.8, operation='max_rolling_avg', metric='dl_brate', criterion='gt', window=half_duration)
93 print(res_str)
94 out += res_str
95 if n != nof_ue - 1:
96 out += '\n'
97
98test.set_report_stdout(out)