Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | from osmo_gsm_tester.testenv import * |
| 3 | |
Pau Espin Pedrol | fa02b9c | 2020-05-06 21:11:39 +0200 | [diff] [blame] | 4 | import time |
| 5 | |
| 6 | test_config = tenv.config_test_specific() |
| 7 | duration = int(test_config.get('duration', 0)) # 0 = one HO loop |
| 8 | threshold = int(test_config.get('threshold', 2)) |
| 9 | |
| 10 | import pprint |
| 11 | print("TEST_CONFIG:\n" + pprint.pformat(test_config)) |
| 12 | |
| 13 | # attenuation from 0 to 10, then back to 0 |
| 14 | cell1_att_li = list(range(0, 11, 1)) + list(range(9, -1, -1)) |
| 15 | # attenuation from 10 to 0, then back to 10 |
| 16 | cell2_att_li = list(range(10, 0, -1)) + list(range(0, 11, 1)) |
| 17 | |
| 18 | def do_one_ho_loop(rfemu_cell1, rfemu_cell2): |
| 19 | step = 0 |
| 20 | while step < len(cell1_att_li): |
| 21 | rfemu_cell1.set_attenuation(cell1_att_li[step]) |
| 22 | rfemu_cell2.set_attenuation(cell2_att_li[step]) |
| 23 | step += 1 |
| 24 | sleep(1) |
| 25 | |
| 26 | epc = tenv.epc() |
| 27 | enb = tenv.enb() |
| 28 | ue = tenv.modem() |
| 29 | iperf3srv = tenv.iperf3srv({'addr': epc.tun_addr()}) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 30 | iperf3srv.set_run_node(epc.run_node()) |
| 31 | iperf3cli = iperf3srv.create_client() |
| 32 | iperf3cli.set_run_node(ue.run_node()) |
| 33 | |
| 34 | epc.subscriber_add(ue) |
| 35 | epc.start() |
| 36 | enb.ue_add(ue) |
| 37 | enb.start(epc) |
| 38 | |
| 39 | print('waiting for ENB to connect to EPC...') |
| 40 | wait(epc.enb_is_connected, enb) |
| 41 | print('ENB is connected to EPC') |
| 42 | |
| 43 | ue.connect(enb) |
| 44 | |
| 45 | iperf3srv.start() |
Pau Espin Pedrol | f4ab97f | 2020-05-25 13:54:30 +0200 | [diff] [blame] | 46 | proc = iperf3cli.prepare_test_proc(iperf3cli.DIR_UL, ue.netns(), duration + 30) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 47 | |
| 48 | print('waiting for UE to attach...') |
Pau Espin Pedrol | 57e37f9 | 2020-06-11 17:12:26 +0200 | [diff] [blame] | 49 | wait(ue.is_registered) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 50 | print('UE is attached') |
| 51 | |
| 52 | rfemu_cell1 = enb.get_rfemu(0) |
| 53 | rfemu_cell2 = enb.get_rfemu(1) |
| 54 | |
Pau Espin Pedrol | fa02b9c | 2020-05-06 21:11:39 +0200 | [diff] [blame] | 55 | print('Iterating for %d seconds to produce at least %d handovers...' % (duration, threshold)) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 56 | try: |
| 57 | proc.launch() |
Pau Espin Pedrol | fa02b9c | 2020-05-06 21:11:39 +0200 | [diff] [blame] | 58 | t_end = time.time() + duration |
| 59 | if duration == 0: |
| 60 | t_end += 1 # allow loop to run once |
| 61 | while time.time() < t_end: |
| 62 | do_one_ho_loop(rfemu_cell1, rfemu_cell2) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 63 | num_handovers = ue.get_counter('handover_success') |
Pau Espin Pedrol | fa02b9c | 2020-05-06 21:11:39 +0200 | [diff] [blame] | 64 | if num_handovers < threshold: |
| 65 | raise Exception('Wrong number of handovers %d < threshold %d during %d seconds' % (num_handovers, threshold, duration)) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 66 | except Exception as e: |
| 67 | try: |
| 68 | proc.terminate() # make sure we always terminate the process |
| 69 | except Exception: |
| 70 | print("Exception while terminating process %r" % repr(process)) |
| 71 | raise e |
| 72 | |
Andre Puschmann | 0767920 | 2020-06-01 10:52:22 +0200 | [diff] [blame] | 73 | res_str = 'Got %d successful handovers (>= %d) during %d seconds' % (num_handovers, threshold, duration) |
Pau Espin Pedrol | eaefe6b | 2020-04-20 13:29:59 +0200 | [diff] [blame] | 74 | print(res_str) |
| 75 | test.set_report_stdout(res_str) |
| 76 | proc.terminate() |
| 77 | proc.wait() |
| 78 | print("Done") |