blob: 8bfb585813bbe5268ffb7664cf6234e5f29f1d3b [file] [log] [blame]
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +02001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
3
Pau Espin Pedrolfa02b9c2020-05-06 21:11:39 +02004import time
5
6test_config = tenv.config_test_specific()
7duration = int(test_config.get('duration', 0)) # 0 = one HO loop
8threshold = int(test_config.get('threshold', 2))
9
10import pprint
11print("TEST_CONFIG:\n" + pprint.pformat(test_config))
12
13# attenuation from 0 to 10, then back to 0
14cell1_att_li = list(range(0, 11, 1)) + list(range(9, -1, -1))
15# attenuation from 10 to 0, then back to 10
16cell2_att_li = list(range(10, 0, -1)) + list(range(0, 11, 1))
17
18def 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
26epc = tenv.epc()
27enb = tenv.enb()
28ue = tenv.modem()
29iperf3srv = tenv.iperf3srv({'addr': epc.tun_addr()})
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020030iperf3srv.set_run_node(epc.run_node())
31iperf3cli = iperf3srv.create_client()
32iperf3cli.set_run_node(ue.run_node())
33
34epc.subscriber_add(ue)
35epc.start()
36enb.ue_add(ue)
37enb.start(epc)
38
39print('waiting for ENB to connect to EPC...')
40wait(epc.enb_is_connected, enb)
41print('ENB is connected to EPC')
42
43ue.connect(enb)
44
45iperf3srv.start()
Pau Espin Pedrolf4ab97f2020-05-25 13:54:30 +020046proc = iperf3cli.prepare_test_proc(iperf3cli.DIR_UL, ue.netns(), duration + 30)
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020047
48print('waiting for UE to attach...')
Pau Espin Pedrol57e37f92020-06-11 17:12:26 +020049wait(ue.is_registered)
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020050print('UE is attached')
51
52rfemu_cell1 = enb.get_rfemu(0)
53rfemu_cell2 = enb.get_rfemu(1)
54
Pau Espin Pedrolfa02b9c2020-05-06 21:11:39 +020055print('Iterating for %d seconds to produce at least %d handovers...' % (duration, threshold))
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020056try:
57 proc.launch()
Pau Espin Pedrolfa02b9c2020-05-06 21:11:39 +020058 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 Pedroleaefe6b2020-04-20 13:29:59 +020063 num_handovers = ue.get_counter('handover_success')
Pau Espin Pedrolfa02b9c2020-05-06 21:11:39 +020064 if num_handovers < threshold:
65 raise Exception('Wrong number of handovers %d < threshold %d during %d seconds' % (num_handovers, threshold, duration))
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020066except 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 Puschmann07679202020-06-01 10:52:22 +020073res_str = 'Got %d successful handovers (>= %d) during %d seconds' % (num_handovers, threshold, duration)
Pau Espin Pedroleaefe6b2020-04-20 13:29:59 +020074print(res_str)
75test.set_report_stdout(res_str)
76proc.terminate()
77proc.wait()
78print("Done")