Commit 050af61d authored by Shweta Shrivastava's avatar Shweta Shrivastava
Browse files

Included XML parsing and updating Ansible scripts

parent 5a886d68
......@@ -165,11 +165,11 @@ class OaiCiTest():
def BuildOAIUE(self,HTML):
if self.UEIPAddress == '' or self.ranRepository == '' or self.ranBranch == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
SSH = sshconnection.SSHConnection()
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
# if self.UEIPAddress == '' or self.ranRepository == '' or self.ranBranch == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
# HELP.GenericHelp(CONST.Version)
# sys.exit('Insufficient Parameter')
# SSH = sshconnection.SSHConnection()
# SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
result = re.search('--nrUE', self.Build_OAI_UE_args)
if result is not None:
self.air_interface='nr-uesoftmodem'
......@@ -182,91 +182,91 @@ class OaiCiTest():
full_ran_repo_name = self.ranRepository.replace('git/', 'git')
else:
full_ran_repo_name = self.ranRepository + '.git'
SSH.command('mkdir -p ' + self.UESourceCodePath, '\$', 5)
SSH.command('cd ' + self.UESourceCodePath, '\$', 5)
SSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600)
# here add a check if git clone or git fetch went smoothly
SSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5)
SSH.command('git config user.name "OAI Jenkins"', '\$', 5)
if self.clean_repository:
SSH.command('ls *.txt', '\$', 5)
result = re.search('LAST_BUILD_INFO', SSH.getBefore())
if result is not None:
mismatch = False
SSH.command('grep SRC_COMMIT LAST_BUILD_INFO.txt', '\$', 2)
result = re.search(self.ranCommitID, SSH.getBefore())
if result is None:
mismatch = True
SSH.command('grep MERGED_W_TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2)
if self.ranAllowMerge:
result = re.search('YES', SSH.getBefore())
if result is None:
mismatch = True
SSH.command('grep TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2)
if self.ranTargetBranch == '':
result = re.search('develop', SSH.getBefore())
else:
result = re.search(self.ranTargetBranch, SSH.getBefore())
if result is None:
mismatch = True
else:
result = re.search('NO', SSH.getBefore())
if result is None:
mismatch = True
if not mismatch:
SSH.close()
HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', CONST.ALL_PROCESSES_OK)
return
SSH.command('echo ' + self.UEPassword + ' | sudo -S git clean -x -d -ff', '\$', 30)
# if the commit ID is provided use it to point to it
if self.ranCommitID != '':
SSH.command('git checkout -f ' + self.ranCommitID, '\$', 30)
# if the branch is not develop, then it is a merge request and we need to do
# the potential merge. Note that merge conflicts should already been checked earlier
if self.ranAllowMerge:
if self.ranTargetBranch == '':
if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'):
SSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5)
else:
logging.debug('Merging with the target branch: ' + self.ranTargetBranch)
SSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5)
SSH.command('source oaienv', '\$', 5)
SSH.command('cd cmake_targets', '\$', 5)
SSH.command('mkdir -p log', '\$', 5)
SSH.command('chmod 777 log', '\$', 5)
# no need to remove in log (git clean did the trick)
SSH.command('stdbuf -o0 ./build_oai ' + self.Build_OAI_UE_args + ' 2>&1 | stdbuf -o0 tee compile_oai_ue.log', 'Bypassing the Tests|build have failed', 1200)
SSH.command('ls ran_build/build', '\$', 3)
SSH.command('ls ran_build/build', '\$', 3)
buildStatus = True
result = re.search(self.air_interface, SSH.getBefore())
if result is None:
buildStatus = False
SSH.command('mkdir -p build_log_' + self.testCase_id, '\$', 5)
SSH.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5)
SSH.command('mv compile_oai_ue.log ' + 'build_log_' + self.testCase_id, '\$', 5)
if buildStatus:
# Generating a BUILD INFO file
SSH.command('echo "SRC_BRANCH: ' + self.ranBranch + '" > ../LAST_BUILD_INFO.txt', '\$', 2)
SSH.command('echo "SRC_COMMIT: ' + self.ranCommitID + '" >> ../LAST_BUILD_INFO.txt', '\$', 2)
if self.ranAllowMerge:
SSH.command('echo "MERGED_W_TGT_BRANCH: YES" >> ../LAST_BUILD_INFO.txt', '\$', 2)
if self.ranTargetBranch == '':
SSH.command('echo "TGT_BRANCH: develop" >> ../LAST_BUILD_INFO.txt', '\$', 2)
else:
SSH.command('echo "TGT_BRANCH: ' + self.ranTargetBranch + '" >> ../LAST_BUILD_INFO.txt', '\$', 2)
else:
SSH.command('echo "MERGED_W_TGT_BRANCH: NO" >> ../LAST_BUILD_INFO.txt', '\$', 2)
SSH.close()
HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', CONST.ALL_PROCESSES_OK, 'OAI UE')
else:
SSH.close()
logging.error('\u001B[1m Building OAI UE Failed\u001B[0m')
HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'KO', CONST.ALL_PROCESSES_OK, 'OAI UE')
HTML.CreateHtmlTabFooter(False)
self.ConditionalExit()
# SSH.command('mkdir -p ' + self.UESourceCodePath, '\$', 5)
# SSH.command('cd ' + self.UESourceCodePath, '\$', 5)
# SSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600)
# # here add a check if git clone or git fetch went smoothly
# SSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5)
# SSH.command('git config user.name "OAI Jenkins"', '\$', 5)
# if self.clean_repository:
# SSH.command('ls *.txt', '\$', 5)
# result = re.search('LAST_BUILD_INFO', SSH.getBefore())
# if result is not None:
# mismatch = False
# SSH.command('grep SRC_COMMIT LAST_BUILD_INFO.txt', '\$', 2)
# result = re.search(self.ranCommitID, SSH.getBefore())
# if result is None:
# mismatch = True
# SSH.command('grep MERGED_W_TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2)
# if self.ranAllowMerge:
# result = re.search('YES', SSH.getBefore())
# if result is None:
# mismatch = True
# SSH.command('grep TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2)
# if self.ranTargetBranch == '':
# result = re.search('develop', SSH.getBefore())
# else:
# result = re.search(self.ranTargetBranch, SSH.getBefore())
# if result is None:
# mismatch = True
# else:
# result = re.search('NO', SSH.getBefore())
# if result is None:
# mismatch = True
# if not mismatch:
# SSH.close()
# HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', CONST.ALL_PROCESSES_OK)
# return
# SSH.command('echo ' + self.UEPassword + ' | sudo -S git clean -x -d -ff', '\$', 30)
# # if the commit ID is provided use it to point to it
# if self.ranCommitID != '':
# SSH.command('git checkout -f ' + self.ranCommitID, '\$', 30)
# # if the branch is not develop, then it is a merge request and we need to do
# # the potential merge. Note that merge conflicts should already been checked earlier
# if self.ranAllowMerge:
# if self.ranTargetBranch == '':
# if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'):
# SSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5)
# else:
# logging.debug('Merging with the target branch: ' + self.ranTargetBranch)
# SSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5)
# SSH.command('source oaienv', '\$', 5)
# SSH.command('cd cmake_targets', '\$', 5)
# SSH.command('mkdir -p log', '\$', 5)
# SSH.command('chmod 777 log', '\$', 5)
# # no need to remove in log (git clean did the trick)
# SSH.command('stdbuf -o0 ./build_oai ' + self.Build_OAI_UE_args + ' 2>&1 | stdbuf -o0 tee compile_oai_ue.log', 'Bypassing the Tests|build have failed', 1200)
# SSH.command('ls ran_build/build', '\$', 3)
# SSH.command('ls ran_build/build', '\$', 3)
# buildStatus = True
# result = re.search(self.air_interface, SSH.getBefore())
# if result is None:
# buildStatus = False
# SSH.command('mkdir -p build_log_' + self.testCase_id, '\$', 5)
# SSH.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5)
# SSH.command('mv compile_oai_ue.log ' + 'build_log_' + self.testCase_id, '\$', 5)
# if buildStatus:
# # Generating a BUILD INFO file
# SSH.command('echo "SRC_BRANCH: ' + self.ranBranch + '" > ../LAST_BUILD_INFO.txt', '\$', 2)
# SSH.command('echo "SRC_COMMIT: ' + self.ranCommitID + '" >> ../LAST_BUILD_INFO.txt', '\$', 2)
# if self.ranAllowMerge:
# SSH.command('echo "MERGED_W_TGT_BRANCH: YES" >> ../LAST_BUILD_INFO.txt', '\$', 2)
# if self.ranTargetBranch == '':
# SSH.command('echo "TGT_BRANCH: develop" >> ../LAST_BUILD_INFO.txt', '\$', 2)
# else:
# SSH.command('echo "TGT_BRANCH: ' + self.ranTargetBranch + '" >> ../LAST_BUILD_INFO.txt', '\$', 2)
# else:
# SSH.command('echo "MERGED_W_TGT_BRANCH: NO" >> ../LAST_BUILD_INFO.txt', '\$', 2)
# SSH.close()
# HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', CONST.ALL_PROCESSES_OK, 'OAI UE')
# else:
# SSH.close()
# logging.error('\u001B[1m Building OAI UE Failed\u001B[0m')
# HTML.CreateHtmlTestRow(self.Build_OAI_UE_args, 'KO', CONST.ALL_PROCESSES_OK, 'OAI UE')
# HTML.CreateHtmlTabFooter(False)
# self.ConditionalExit()
def CheckFlexranCtrlInstallation(self,RAN,EPC,CONTAINERS):
if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '':
......@@ -408,9 +408,9 @@ class OaiCiTest():
def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,InfraUE):
if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
# if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
# HELP.GenericHelp(CONST.Version)
# sys.exit('Insufficient Parameter')
if self.air_interface == 'lte-uesoftmodem':
......@@ -426,212 +426,214 @@ class OaiCiTest():
UE_prefix = ''
else:
UE_prefix = 'NR '
SSH = sshconnection.SSHConnection()
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
# b2xx_fx3_utils reset procedure
SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90)
result = re.search('type: b200', SSH.getBefore())
if result is not None:
logging.debug('Found a B2xx device --> resetting it')
SSH.command('echo ' + self.UEPassword + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 10)
# Reloading FGPA bin firmware
SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90)
result = re.search('type: n3xx', str(SSH.getBefore()))
if result is not None:
logging.debug('Found a N3xx device --> resetting it')
SSH.command('cd ' + self.UESourceCodePath, '\$', 5)
# Initialize_OAI_UE_args usually start with -C and followed by the location in repository
SSH.command('source oaienv', '\$', 5)
SSH.command('cd cmake_targets/ran_build/build', '\$', 5)
if self.air_interface == 'lte-uesoftmodem':
result = re.search('--no-L2-connect', str(self.Initialize_OAI_UE_args))
# We may have to regenerate the .u* files
if result is None:
SSH.command('ls /tmp/*.sed', '\$', 5)
result = re.search('adapt_usim_parameters', SSH.getBefore())
if result is not None:
SSH.command('sed -f /tmp/adapt_usim_parameters.sed ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5)
else:
SSH.command('sed -e "s#93#92#" -e "s#8baf473f2f8fd09487cccbd7097c6862#fec86ba6eb707ed08905757b1bb44b8f#" -e "s#e734f8734007d6c5ce7a0508809e7e9c#C42449363BBAD02B66D16BC975D77CC1#" ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5)
SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf .u*', '\$', 5)
SSH.command('echo ' + self.UEPassword + ' | sudo -S ../../../targets/bin/conf2uedata -c ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf -o .', '\$', 5)
else:
SSH.command('if [ -e rbconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm rbconfig.raw; fi', '\$', 5)
SSH.command('if [ -e reconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm reconfig.raw; fi', '\$', 5)
# Copy the RAW files from gNB running directory (maybe on another machine)
copyin_res = SSH.copyin(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, RAN.eNBSourceCodePath + '/cmake_targets/rbconfig.raw', '.')
if (copyin_res == 0):
SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './rbconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build')
copyin_res = SSH.copyin(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, RAN.eNBSourceCodePath + '/cmake_targets/reconfig.raw', '.')
if (copyin_res == 0):
SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './reconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build')
SSH.command('echo "ulimit -c unlimited && ./'+ self.air_interface +' ' + self.Initialize_OAI_UE_args + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
SSH.command('chmod 775 ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5)
self.UELogFile = 'ue_' + self.testCase_id + '.log'
# We are now looping several times to hope we really sync w/ an eNB
doOutterLoop = True
outterLoopCounter = 5
gotSyncStatus = True
fullSyncStatus = True
while (doOutterLoop):
SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets/ran_build/build', '\$', 5)
SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5)
SSH.command('echo $USER; nohup sudo -E ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh' + ' > ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log ' + ' 2>&1 &', self.UEUserName, 5)
time.sleep(6)
SSH.command('cd ../..', '\$', 5)
doLoop = True
loopCounter = 10
gotSyncStatus = True
# the 'got sync' message is for the UE threads synchronization
while (doLoop):
loopCounter = loopCounter - 1
if (loopCounter == 0):
# Here should never occur
logging.error('"got sync" message never showed!')
gotSyncStatus = False
doLoop = False
continue
SSH.command('stdbuf -o0 cat ue_' + self.testCase_id + '.log | egrep --text --color=never -i "wait|sync"', '\$', 4)
if self.air_interface == 'nr-uesoftmodem':
result = re.search('Starting sync detection', SSH.getBefore())
else:
result = re.search('got sync', SSH.getBefore())
if result is None:
time.sleep(10)
else:
doLoop = False
logging.debug('Found "got sync" message!')
if gotSyncStatus == False:
# we certainly need to stop the lte-uesoftmodem process if it is still running!
SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
result = re.search('-uesoftmodem', SSH.getBefore())
if result is not None:
SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT -r *-uesoftmodem', '\$', 4)
time.sleep(3)
outterLoopCounter = outterLoopCounter - 1
if (outterLoopCounter == 0):
doOutterLoop = False
continue
# We are now checking if sync w/ eNB DOES NOT OCCUR
# Usually during the cell synchronization stage, the UE returns with No cell synchronization message
# That is the case for LTE
# In NR case, it's a positive message that will show if synchronization occurs
doLoop = True
if self.air_interface == 'nr-uesoftmodem':
loopCounter = 10
else:
# We are now checking if sync w/ eNB DOES NOT OCCUR
# Usually during the cell synchronization stage, the UE returns with No cell synchronization message
loopCounter = 10
while (doLoop):
loopCounter = loopCounter - 1
if (loopCounter == 0):
if self.air_interface == 'nr-uesoftmodem':
# Here we do have great chances that UE did NOT cell-sync w/ gNB
doLoop = False
fullSyncStatus = False
logging.debug('Never seen the NR-Sync message (Measured Carrier Frequency) --> try again')
time.sleep(6)
# Stopping the NR-UE
SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
result = re.search('nr-uesoftmodem', SSH.getBefore())
if result is not None:
SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT nr-uesoftmodem', '\$', 4)
time.sleep(6)
else:
# Here we do have a great chance that the UE did cell-sync w/ eNB
doLoop = False
doOutterLoop = False
fullSyncStatus = True
continue
SSH.command('stdbuf -o0 cat ue_' + self.testCase_id + '.log | egrep --text --color=never -i "wait|sync|Frequency"', '\$', 4)
if self.air_interface == 'nr-uesoftmodem':
# Positive messaging -->
result = re.search('Measured Carrier Frequency', SSH.getBefore())
if result is not None:
doLoop = False
doOutterLoop = False
fullSyncStatus = True
else:
time.sleep(6)
else:
# Negative messaging -->
result = re.search('No cell synchronization found', SSH.getBefore())
if result is None:
time.sleep(6)
else:
doLoop = False
fullSyncStatus = False
logging.debug('Found: "No cell synchronization" message! --> try again')
time.sleep(6)
SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
result = re.search('lte-uesoftmodem', SSH.getBefore())
if result is not None:
SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT lte-uesoftmodem', '\$', 4)
outterLoopCounter = outterLoopCounter - 1
if (outterLoopCounter == 0):
doOutterLoop = False
if fullSyncStatus and gotSyncStatus:
doInterfaceCheck = False
if self.air_interface == 'lte-uesoftmodem':
result = re.search('--no-L2-connect', str(self.Initialize_OAI_UE_args))
if result is None:
doInterfaceCheck = True
# For the moment, only in explicit noS1 without kernel module (ie w/ tunnel interface)
if self.air_interface == 'nr-uesoftmodem':
result = re.search('--noS1 --nokrnmod 1', str(self.Initialize_OAI_UE_args))
if result is not None:
doInterfaceCheck = True
if doInterfaceCheck:
SSH.command('ifconfig oaitun_ue1', '\$', 4)
SSH.command('ifconfig oaitun_ue1', '\$', 4)
# ifconfig output is different between ubuntu 16 and ubuntu 18
result = re.search('inet addr:[0-9]|inet [0-9]', SSH.getBefore())
if result is not None:
logging.debug('\u001B[1m oaitun_ue1 interface is mounted and configured\u001B[0m')
tunnelInterfaceStatus = True
else:
logging.debug(SSH.getBefore())
logging.error('\u001B[1m oaitun_ue1 interface is either NOT mounted or NOT configured\u001B[0m')
tunnelInterfaceStatus = False
if RAN.eNBmbmsEnables[0]:
SSH.command('ifconfig oaitun_uem1', '\$', 4)
result = re.search('inet addr', SSH.getBefore())
if result is not None:
logging.debug('\u001B[1m oaitun_uem1 interface is mounted and configured\u001B[0m')
tunnelInterfaceStatus = tunnelInterfaceStatus and True
else:
logging.error('\u001B[1m oaitun_uem1 interface is either NOT mounted or NOT configured\u001B[0m')
tunnelInterfaceStatus = False
else:
tunnelInterfaceStatus = True
else:
tunnelInterfaceStatus = True
SSH.close()
if fullSyncStatus and gotSyncStatus and tunnelInterfaceStatus:
HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'OK', CONST.ALL_PROCESSES_OK, 'OAI UE')
logging.debug('\u001B[1m Initialize OAI UE Completed\u001B[0m')
if (self.ADBIPAddress != 'none'):
self.UEDevices = []
self.UEDevices.append('OAI-UE')
self.UEDevicesStatus = []
self.UEDevicesStatus.append(CONST.UE_STATUS_DETACHED)
else:
if self.air_interface == 'lte-uesoftmodem':
if RAN.eNBmbmsEnables[0]:
HTML.htmlUEFailureMsg='oaitun_ue1/oaitun_uem1 interfaces are either NOT mounted or NOT configured'
else:
HTML.htmlUEFailureMsg='oaitun_ue1 interface is either NOT mounted or NOT configured'
HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'KO', CONST.OAI_UE_PROCESS_NO_TUNNEL_INTERFACE, 'OAI UE')
else:
HTML.htmlUEFailureMsg='nr-uesoftmodem did NOT synced'
HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'KO', CONST.OAI_UE_PROCESS_COULD_NOT_SYNC, 'OAI UE')
logging.error('\033[91mInitialize OAI UE Failed! \033[0m')
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE)
logging.debug('UE args' + str(self.Initialize_OAI_UE_args))
os.system('sed -i "s/<< ue_args >>/' + str(self.Initialize_OAI_UE_args) + '/g" ../colosseum-cm/ansible/oai.yml')
# SSH = sshconnection.SSHConnection()
# SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
# # b2xx_fx3_utils reset procedure
# SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90)
# result = re.search('type: b200', SSH.getBefore())
# if result is not None:
# logging.debug('Found a B2xx device --> resetting it')
# SSH.command('echo ' + self.UEPassword + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 10)
# # Reloading FGPA bin firmware
# SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90)
# result = re.search('type: n3xx', str(SSH.getBefore()))
# if result is not None:
# logging.debug('Found a N3xx device --> resetting it')
# SSH.command('cd ' + self.UESourceCodePath, '\$', 5)
# # Initialize_OAI_UE_args usually start with -C and followed by the location in repository
# SSH.command('source oaienv', '\$', 5)
# SSH.command('cd cmake_targets/ran_build/build', '\$', 5)
# if self.air_interface == 'lte-uesoftmodem':
# result = re.search('--no-L2-connect', str(self.Initialize_OAI_UE_args))
# # We may have to regenerate the .u* files
# if result is None:
# SSH.command('ls /tmp/*.sed', '\$', 5)
# result = re.search('adapt_usim_parameters', SSH.getBefore())
# if result is not None:
# SSH.command('sed -f /tmp/adapt_usim_parameters.sed ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5)
# else:
# SSH.command('sed -e "s#93#92#" -e "s#8baf473f2f8fd09487cccbd7097c6862#fec86ba6eb707ed08905757b1bb44b8f#" -e "s#e734f8734007d6c5ce7a0508809e7e9c#C42449363BBAD02B66D16BC975D77CC1#" ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5)
# SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf .u*', '\$', 5)
# SSH.command('echo ' + self.UEPassword + ' | sudo -S ../../../targets/bin/conf2uedata -c ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf -o .', '\$', 5)
# else:
# SSH.command('if [ -e rbconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm rbconfig.raw; fi', '\$', 5)
# SSH.command('if [ -e reconfig.raw ]; then echo ' + self.UEPassword + ' | sudo -S rm reconfig.raw; fi', '\$', 5)
# # Copy the RAW files from gNB running directory (maybe on another machine)
# copyin_res = SSH.copyin(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, RAN.eNBSourceCodePath + '/cmake_targets/rbconfig.raw', '.')
# if (copyin_res == 0):
# SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './rbconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build')
# copyin_res = SSH.copyin(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, RAN.eNBSourceCodePath + '/cmake_targets/reconfig.raw', '.')
# if (copyin_res == 0):
# SSH.copyout(self.UEIPAddress, self.UEUserName, self.UEPassword, './reconfig.raw', self.UESourceCodePath + '/cmake_targets/ran_build/build')
# SSH.command('echo "ulimit -c unlimited && ./'+ self.air_interface +' ' + self.Initialize_OAI_UE_args + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
# SSH.command('chmod 775 ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
# SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5)
# self.UELogFile = 'ue_' + self.testCase_id + '.log'
# # We are now looping several times to hope we really sync w/ an eNB
# doOutterLoop = True
# outterLoopCounter = 5
# gotSyncStatus = True
# fullSyncStatus = True
# while (doOutterLoop):
# SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets/ran_build/build', '\$', 5)
# SSH.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5)
# SSH.command('echo $USER; nohup sudo -E ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh' + ' > ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log ' + ' 2>&1 &', self.UEUserName, 5)
# time.sleep(6)
# SSH.command('cd ../..', '\$', 5)
# doLoop = True
# loopCounter = 10
# gotSyncStatus = True
# # the 'got sync' message is for the UE threads synchronization
# while (doLoop):
# loopCounter = loopCounter - 1
# if (loopCounter == 0):
# # Here should never occur
# logging.error('"got sync" message never showed!')
# gotSyncStatus = False
# doLoop = False
# continue
# SSH.command('stdbuf -o0 cat ue_' + self.testCase_id + '.log | egrep --text --color=never -i "wait|sync"', '\$', 4)
# if self.air_interface == 'nr-uesoftmodem':
# result = re.search('Starting sync detection', SSH.getBefore())
# else:
# result = re.search('got sync', SSH.getBefore())
# if result is None:
# time.sleep(10)
# else:
# doLoop = False
# logging.debug('Found "got sync" message!')
# if gotSyncStatus == False:
# # we certainly need to stop the lte-uesoftmodem process if it is still running!
# SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
# result = re.search('-uesoftmodem', SSH.getBefore())
# if result is not None:
# SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT -r *-uesoftmodem', '\$', 4)
# time.sleep(3)
# outterLoopCounter = outterLoopCounter - 1
# if (outterLoopCounter == 0):
# doOutterLoop = False
# continue
# # We are now checking if sync w/ eNB DOES NOT OCCUR
# # Usually during the cell synchronization stage, the UE returns with No cell synchronization message
# # That is the case for LTE
# # In NR case, it's a positive message that will show if synchronization occurs
# doLoop = True
# if self.air_interface == 'nr-uesoftmodem':
# loopCounter = 10
# else:
# # We are now checking if sync w/ eNB DOES NOT OCCUR
# # Usually during the cell synchronization stage, the UE returns with No cell synchronization message
# loopCounter = 10
# while (doLoop):
# loopCounter = loopCounter - 1
# if (loopCounter == 0):
# if self.air_interface == 'nr-uesoftmodem':
# # Here we do have great chances that UE did NOT cell-sync w/ gNB
# doLoop = False
# fullSyncStatus = False
# logging.debug('Never seen the NR-Sync message (Measured Carrier Frequency) --> try again')
# time.sleep(6)
# # Stopping the NR-UE
# SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
# result = re.search('nr-uesoftmodem', SSH.getBefore())
# if result is not None:
# SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT nr-uesoftmodem', '\$', 4)
# time.sleep(6)
# else:
# # Here we do have a great chance that the UE did cell-sync w/ eNB
# doLoop = False
# doOutterLoop = False
# fullSyncStatus = True
# continue
# SSH.command('stdbuf -o0 cat ue_' + self.testCase_id + '.log | egrep --text --color=never -i "wait|sync|Frequency"', '\$', 4)
# if self.air_interface == 'nr-uesoftmodem':
# # Positive messaging -->
# result = re.search('Measured Carrier Frequency', SSH.getBefore())
# if result is not None:
# doLoop = False
# doOutterLoop = False
# fullSyncStatus = True
# else:
# time.sleep(6)
# else:
# # Negative messaging -->
# result = re.search('No cell synchronization found', SSH.getBefore())
# if result is None:
# time.sleep(6)
# else:
# doLoop = False
# fullSyncStatus = False
# logging.debug('Found: "No cell synchronization" message! --> try again')
# time.sleep(6)
# SSH.command('ps -aux | grep --text --color=never softmodem | grep -v grep', '\$', 4)
# result = re.search('lte-uesoftmodem', SSH.getBefore())
# if result is not None:
# SSH.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT lte-uesoftmodem', '\$', 4)
# outterLoopCounter = outterLoopCounter - 1
# if (outterLoopCounter == 0):
# doOutterLoop = False
# if fullSyncStatus and gotSyncStatus:
# doInterfaceCheck = False
# if self.air_interface == 'lte-uesoftmodem':
# result = re.search('--no-L2-connect', str(self.Initialize_OAI_UE_args))
# if result is None:
# doInterfaceCheck = True
# # For the moment, only in explicit noS1 without kernel module (ie w/ tunnel interface)
# if self.air_interface == 'nr-uesoftmodem':
# result = re.search('--noS1 --nokrnmod 1', str(self.Initialize_OAI_UE_args))
# if result is not None:
# doInterfaceCheck = True
# if doInterfaceCheck:
# SSH.command('ifconfig oaitun_ue1', '\$', 4)
# SSH.command('ifconfig oaitun_ue1', '\$', 4)
# # ifconfig output is different between ubuntu 16 and ubuntu 18
# result = re.search('inet addr:[0-9]|inet [0-9]', SSH.getBefore())
# if result is not None:
# logging.debug('\u001B[1m oaitun_ue1 interface is mounted and configured\u001B[0m')
# tunnelInterfaceStatus = True
# else:
# logging.debug(SSH.getBefore())
# logging.error('\u001B[1m oaitun_ue1 interface is either NOT mounted or NOT configured\u001B[0m')
# tunnelInterfaceStatus = False
# if RAN.eNBmbmsEnables[0]:
# SSH.command('ifconfig oaitun_uem1', '\$', 4)
# result = re.search('inet addr', SSH.getBefore())
# if result is not None:
# logging.debug('\u001B[1m oaitun_uem1 interface is mounted and configured\u001B[0m')
# tunnelInterfaceStatus = tunnelInterfaceStatus and True
# else:
# logging.error('\u001B[1m oaitun_uem1 interface is either NOT mounted or NOT configured\u001B[0m')
# tunnelInterfaceStatus = False
# else: