blob: 70a2fdef411d9c465a0aaf59f49ec16355bbc0a6 [file] [log] [blame]
Andre Puschmann6246a9d2021-03-12 19:03:58 +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'))
Andre Puschmann6246a9d2021-03-12 19:03:58 +01008
AlaiaL5f9a7632021-05-10 16:36:40 +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
Andre Puschmann6246a9d2021-03-12 19:03:58 +010022epc = tenv.epc()
23enb = tenv.enb()
Andre Puschmann6246a9d2021-03-12 19:03:58 +010024
AlaiaL5f9a7632021-05-10 16:36:40 +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])
Andre Puschmann6246a9d2021-03-12 19:03:58 +010039epc.start()
AlaiaL5f9a7632021-05-10 16:36:40 +020040
41enb.ue_add(ue_li[0])
Andre Puschmann6246a9d2021-03-12 19:03:58 +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
AlaiaL5f9a7632021-05-10 16:36:40 +020048for n in range(0, nof_ue):
49 ue_li[n].connect(enb)
Andre Puschmann6246a9d2021-03-12 19:03:58 +010050
AlaiaL5f9a7632021-05-10 16:36:40 +020051for n in range(0, nof_ue):
52 iperf3srv[n].start()
Andre Puschmann6246a9d2021-03-12 19:03:58 +010053
AlaiaL5f9a7632021-05-10 16:36:40 +020054proc_li = []
Andre Puschmann6246a9d2021-03-12 19:03:58 +010055
AlaiaL5f9a7632021-05-10 16:36:40 +020056# Attach all the ue's.
57for n in range(0, nof_ue):
58 max_rate_dl = enb.ue_max_rate(downlink=True, num_carriers=ue_li[n].num_carriers)
59 client = iperf3cli[n].prepare_test_proc(iperf3cli[n].DIR_BI, ue_li[n].netns(), bitrate=max_rate_dl)
60 print(f'Iperf client type: {type(client)}')
61 proc_li.append(client)
Andre Puschmann6246a9d2021-03-12 19:03:58 +010062
AlaiaL5f9a7632021-05-10 16:36:40 +020063# Wait for all the ue's attach.
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')
Andre Puschmann6246a9d2021-03-12 19:03:58 +010068
AlaiaL5f9a7632021-05-10 16:36:40 +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)
Andre Puschmann6246a9d2021-03-12 19:03:58 +010086
87# 80% of the maximum rate for half of the test duration
AlaiaL5f9a7632021-05-10 16:36:40 +020088max_rate_ratio = 0.8
89out = ''
90for n in range(0, nof_ue):
91 half_duration = int(round(iperf3cli[n].time_sec() / 2))
92 max_rate_dl = enb.ue_max_rate(downlink=True, num_carriers=ue_li[n].num_carriers)
93 max_rate_ul = enb.ue_max_rate(downlink=False, num_carriers=ue_li[n].num_carriers)
94 res_str = ue_li[n].verify_metric((max_rate_dl + max_rate_ul) * max_rate_ratio, operation='max_rolling_avg', metric='dl_brate+ul_brate', criterion='gt', window=half_duration)
95 print(res_str)
96 out += res_str
97 if n != nof_ue - 1:
98 out += '\n'
99
100test.set_report_stdout(out)