sysmocom: emergency_preemptive_call.py: Avoid test failure if 2nd call not fully established

It may happen that the non-emergency call MT leg is still not properly
released when the emergency call MT leg is to be assigned a TCH, meaning
BSC will fail with an Assignment Failure upon Assignment request from
MSC.
The test sometimes passed and sometimes didn't, due to above mentioned
race condition. Let's relax a bit the test expectancies to have it
always passing, while still verifying preemption happens, and MT phone
is reached.

Related: OS#4549
Change-Id: I3697227cac56a1327f9ea08c5c2f52568e8d2a8a
This commit is contained in:
Pau Espin 2020-10-21 17:37:53 +02:00
parent fbb8611381
commit 17f7c38755
2 changed files with 18 additions and 13 deletions

View File

@ -773,6 +773,15 @@ class Modem(MS):
MainLoop.wait(lambda: self._find_call_msisdn_state(caller_msisdn, 'incoming') is not None, timeout=timeout)
return self._find_call_msisdn_state(caller_msisdn, 'incoming')
def call_wait_dialing(self, caller_msisdn_or_modem, timeout=60):
if isinstance(caller_msisdn_or_modem, Modem):
caller_msisdn = caller_msisdn_or_modem.msisdn()
else:
caller_msisdn = str(caller_msisdn_or_modem)
self.dbg('Waiting for dialing call from:', caller_msisdn)
MainLoop.wait(lambda: self._find_call_msisdn_state(caller_msisdn, 'dialing') is not None, timeout=timeout)
return self._find_call_msisdn_state(caller_msisdn, 'dialing')
def call_answer(self, call_id):
self.dbg('Answer call %s' % call_id)
assert self.call_state(call_id) == 'incoming'

View File

@ -80,20 +80,16 @@ emerg_numbers = ms_mo_emerg.emergency_numbers()
assert len(emerg_numbers) > 0
print('dialing Emergency Number %s' % (emerg_numbers[0]))
mo_cid_emerg = ms_mo_emerg.call_dial(emerg_numbers[0])
mt_cid_emerg = ms_mt_emerg.call_wait_incoming(ms_mo_emerg)
# In here we'd ideally wait for incoming call and accept it, but there may be a
# race condition in previous MT TCH not being yet released, so BSC will only be
# able to allocate a SDCCH for not a TCH, and will fail later with Assignment
# Failure:
mt_cid_emerg = ms_mt_emerg.call_wait_dialing(ms_mo_emerg)
print('dial success')
assert not ms_mo_emerg.call_is_active(mo_cid_emerg) and not ms_mt_emerg.call_is_active(mt_cid_emerg)
ms_mt_emerg.call_answer(mt_cid_emerg)
wait(ms_mo_emerg.call_is_active, mo_cid_emerg)
wait(ms_mt_emerg.call_is_active, mt_cid_emerg)
print('answer success, call established and ongoing')
assert ms_mo_emerg.call_state(mo_cid_emerg) == 'alerting'
# Now the emergency call is ongoing, and the previous one should have been gone:
assert len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0
wait(lambda: len(ms_mo.call_id_list()) == 0 and len(ms_mt.call_id_list()) == 0)
print('preemption worked')
sleep(5) # maintain the emergency call active for 5 seconds
assert ms_mo_emerg.call_is_active(mo_cid_emerg) and ms_mt.call_is_active(mt_cid_emerg)
ms_mt_emerg.call_hangup(mt_cid_emerg)
wait(lambda: len(ms_mo_emerg.call_id_list()) == 0 and len(ms_mt_emerg.call_id_list()) == 0)
print('hangup success')
print('done sleepig, success')