Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
Andre Puschmann | 4462067 | 2021-04-15 10:50:36 +0200 | [diff] [blame] | 3 | import os |
| 4 | |
| 5 | # Overlay suite-specific templates folder if it exists |
| 6 | if 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 Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 8 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 9 | # Retrieve the number of physical ue from the test suite configuration. |
| 10 | test_config = tenv.config_test_specific() |
| 11 | nof_ue = int(test_config.get("nof_physical_ue", 1)) |
| 12 | |
| 13 | print(f'Number of physical ue: {nof_ue}') |
| 14 | |
| 15 | ue_li = [] |
| 16 | |
| 17 | # Get the ue from the test configuration. |
| 18 | for n in range(0, nof_ue): |
| 19 | ue_li.append(tenv.modem()) |
| 20 | print(f'ue index{n}: {ue_li[n]}') |
| 21 | |
Pau Espin Pedrol | 40c7bc7 | 2020-05-05 13:41:42 +0200 | [diff] [blame] | 22 | epc = tenv.epc() |
| 23 | enb = tenv.enb() |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 24 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 25 | iperf3srv = [] |
| 26 | for 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. |
| 32 | iperf3cli = [] |
| 33 | for 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 | |
| 37 | for n in range(0, nof_ue): |
| 38 | epc.subscriber_add(ue_li[n]) |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 39 | epc.start() |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 40 | |
| 41 | enb.ue_add(ue_li[0]) |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 42 | enb.start(epc) |
| 43 | |
| 44 | print('waiting for ENB to connect to EPC...') |
| 45 | wait(epc.enb_is_connected, enb) |
| 46 | print('ENB is connected to EPC') |
| 47 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 48 | for n in range(0, nof_ue): |
| 49 | ue_li[n].connect(enb) |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 50 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 51 | for n in range(0, nof_ue): |
| 52 | iperf3srv[n].start() |
Pau Espin Pedrol | d84a838 | 2020-05-25 14:23:37 +0200 | [diff] [blame] | 53 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 54 | proc_li = [] |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 55 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 56 | # Attach all the ue's. |
| 57 | for n in range(0, nof_ue): |
| 58 | max_rate = enb.ue_max_rate(downlink=False, num_carriers=ue_li[n].num_carriers) |
| 59 | client = iperf3cli[n].prepare_test_proc(iperf3cli[n].DIR_UL, ue_li[n].netns(), bitrate=max_rate) |
| 60 | print(f'Iperf client type: {type(client)}') |
| 61 | proc_li.append(client) |
Pau Espin Pedrol | c8b0f93 | 2020-02-11 17:45:26 +0100 | [diff] [blame] | 62 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 63 | for n in range(0, nof_ue): |
| 64 | print(f'waiting for UE {n} to attach...') |
| 65 | wait(ue_li[n].is_registered) |
| 66 | print(f'UE {n} is attached') |
Pau Espin Pedrol | 3a0dea6 | 2020-05-21 14:54:46 +0200 | [diff] [blame] | 67 | |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 68 | # Execute the iperfs and wait for its finish. |
| 69 | try: |
| 70 | for proc in proc_li: |
| 71 | proc.launch() |
| 72 | for proc in proc_li: |
| 73 | proc.wait() |
| 74 | except Exception as e: |
| 75 | for proc in proc_li: |
| 76 | try: |
| 77 | proc.terminate() |
| 78 | except Exception: |
| 79 | print("Exception while terminanting process %r" % repr(process)) |
| 80 | raise e |
| 81 | |
| 82 | for n in range(0, nof_ue): |
| 83 | iperf3cli[n].print_results() |
| 84 | iperf3srv[n].print_results(iperf3cli[n].proto() == iperf3cli[n].PROTO_UDP) |
Pau Espin Pedrol | 151b08a | 2020-03-02 14:14:27 +0100 | [diff] [blame] | 85 | |
Andre Puschmann | d253a10 | 2020-10-28 21:11:14 +0100 | [diff] [blame] | 86 | # 80% of the maximum rate for half of the test duration |
AlaiaL | 8ff2939 | 2021-05-10 16:21:17 +0200 | [diff] [blame] | 87 | out = '' |
| 88 | for n in range(0, nof_ue): |
| 89 | half_duration = int(round(iperf3cli[n].time_sec() / 2)) |
| 90 | max_rate = enb.ue_max_rate(downlink=False, num_carriers=ue_li[n].num_carriers) |
| 91 | res_str = ue_li[n].verify_metric(max_rate * 0.8, operation='max_rolling_avg', metric='ul_brate', criterion='gt', window=half_duration) |
| 92 | print(res_str) |
| 93 | out += res_str |
| 94 | if n != nof_ue - 1: |
| 95 | out += '\n' |
| 96 | |
| 97 | test.set_report_stdout(out) |