blob: addbda5c832754b8a0e0793173ca5f981f70dc45 [file] [log] [blame]
Pau Espin Pedrol998be652020-10-22 11:59:48 +02001#!/usr/bin/env python3
2from osmo_gsm_tester.testenv import *
3
4import 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()
27enbA = tenv.enb()
28enbB = tenv.enb()
29ue = tenv.modem()
30iperf3srv = tenv.iperf3srv({'addr': epc.tun_addr()})
31iperf3srv.set_run_node(epc.run_node())
32iperf3cli = iperf3srv.create_client()
33iperf3cli.set_run_node(ue.run_node())
34
35epc.subscriber_add(ue)
36epc.start()
37enbA.ue_add(ue)
38enbB.ue_add(ue)
39enbA.start(epc)
40enbB.start(epc)
41
42print('waiting for ENB to connect to EPC...')
43wait(epc.enb_is_connected, enbA)
44wait(epc.enb_is_connected, enbB)
45print('ENB is connected to EPC')
46
47ue.connect(enbA)
48
49iperf3srv.start()
50proc = iperf3cli.prepare_test_proc(iperf3cli.DIR_UL, ue.netns(), duration + 30)
51
52print('waiting for UE to attach...')
53wait(ue.is_registered)
54print('UE is attached')
55
56rfemu_cell1 = enbA.get_rfemu(0)
57rfemu_cell2 = enbB.get_rfemu(0)
58
59print('Iterating for %d seconds to produce at least %d handovers...' % (duration, threshold))
60try:
61 proc.launch()
62 t_end = time.time() + duration
63 if duration == 0:
64 t_end += 1 # allow loop to run once
65 while time.time() < t_end:
66 do_one_ho_loop(rfemu_cell1, rfemu_cell2)
67 num_handovers = ue.get_counter('handover_success')
68 if num_handovers < threshold:
69 raise Exception('Wrong number of handovers %d < threshold %d during %d seconds' % (num_handovers, threshold, duration))
70except Exception as e:
71 try:
72 proc.terminate() # make sure we always terminate the process
73 except Exception:
74 print("Exception while terminating process %r" % repr(process))
75 raise e
76
77res_str = 'Got %d successful handovers (>= %d) during %d seconds' % (num_handovers, threshold, duration)
78print(res_str)
79test.set_report_stdout(res_str)
80proc.terminate()
81proc.wait()
82print("Done")