main.py 40.2 KB
Newer Older
Raphael Defosseux's avatar
Raphael Defosseux committed
1
#/*
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements.  See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *      http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# *      contact@openairinterface.org
# */
21 22 23 24 25 26 27 28 29 30
#---------------------------------------------------------------------
# Python for CI of OAI-eNB + COTS-UE
#
#   Required Python Version
#     Python 3.x
#
#   Required Python Package
#     pexpect
#---------------------------------------------------------------------

31 32 33 34 35 36 37


#-----------------------------------------------------------
# Import Components
#-----------------------------------------------------------

import helpreadme as HELP
38 39
import constants as CONST

40

41 42 43 44 45
import cls_oaicitest            #main class for OAI CI test framework
import cls_physim               #class PhySim for physical simulators build and test
import cls_cots_ue              #class CotsUe for Airplane mode control
import cls_containerize         #class Containerize for all container-based operations on RAN/UE objects
import cls_static_code_analysis #class for static code analysis
hardy's avatar
hardy committed
46
import cls_ci_ueinfra			#class defining the multi Ue infrastrucure
47
import cls_physim1          #class PhySim for physical simulators deploy and run
48
import cls_cluster              # class for building/deploying on cluster
49

50 51 52
import sshconnection 
import epc
import ran
53
import cls_oai_html
54

55

56
#-----------------------------------------------------------
57
# Import Libs
58 59 60
#-----------------------------------------------------------
import sys		# arg
import re		# reg
61
import pexpect	# pexpect
62 63
import time		# sleep
import os
64
import subprocess
65 66 67 68
import xml.etree.ElementTree as ET
import logging
import datetime
import signal
69
import subprocess
Raphael Defosseux's avatar
CI:  
Raphael Defosseux committed
70
from multiprocessing import Process, Lock, SimpleQueue
71
logging.basicConfig(
72
	level=logging.DEBUG,
73
	format="[%(asctime)s] %(levelname)8s: %(message)s"
74 75
)

76

77

78 79 80 81 82 83 84

#-----------------------------------------------------------
# General Functions
#-----------------------------------------------------------



85
def CheckClassValidity(xml_class_list,action,id):
86
	if action not in xml_class_list:
87
		logging.error('test-case ' + id + ' has unlisted class ' + action + ' ##CHECK xml_class_list.yml')
88 89 90 91
		resp=False
	else:
		resp=True
	return resp
92

93 94 95

#assigning parameters to object instance attributes (even if the attributes do not exist !!)
def AssignParams(params_dict):
96

97
	for key,value in params_dict.items():
98
		setattr(CiTestObj, key, value)
99 100 101 102 103 104
		setattr(RAN, key, value)
		setattr(HTML, key, value)
		setattr(ldpc, key, value)



105
def GetParametersFromXML(action):
106
	if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy' or action == "Build_Cluster_Image":
107
		RAN.Build_eNB_args=test.findtext('Build_eNB_args')
108
		CONTAINERS.imageKind=test.findtext('kind')
109
		forced_workspace_cleanup = test.findtext('forced_workspace_cleanup')
110 111
		RAN.Build_eNB_forced_workspace_cleanup=False
		CONTAINERS.forcedWorkspaceCleanup=False
112
		CLUSTER.forcedWorkspaceCleanup = False
113 114 115
		if forced_workspace_cleanup is not None and re.match('true', forced_workspace_cleanup, re.IGNORECASE):
			RAN.Build_eNB_forced_workspace_cleanup = True
			CONTAINERS.forcedWorkspaceCleanup = True
116
			CLUSTER.forcedWorkspaceCleanup = True
117 118 119
		eNB_instance=test.findtext('eNB_instance')
		if (eNB_instance is None):
			RAN.eNB_instance=0
120
			CONTAINERS.eNB_instance=0
121 122
		else:
			RAN.eNB_instance=int(eNB_instance)
123
			CONTAINERS.eNB_instance=int(eNB_instance)
124 125 126
		eNB_serverId=test.findtext('eNB_serverId')
		if (eNB_serverId is None):
			RAN.eNB_serverId[RAN.eNB_instance]='0'
127
			CONTAINERS.eNB_serverId[RAN.eNB_instance]='0'
128 129
		else:
			RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId
130
			CONTAINERS.eNB_serverId[CONTAINERS.eNB_instance]=eNB_serverId
131 132
		xmlBgBuildField = test.findtext('backgroundBuild')
		if (xmlBgBuildField is None):
133
			RAN.backgroundBuild=False
134 135
		else:
			if re.match('true', xmlBgBuildField, re.IGNORECASE):
136
				RAN.backgroundBuild=True
137
			else:
138
				RAN.backgroundBuild=False
139 140 141
		proxy_commit = test.findtext('proxy_commit')
		if proxy_commit is not None:
			CONTAINERS.proxyCommit = proxy_commit
142

143
	elif action == 'WaitEndBuild_eNB':
144
		RAN.Build_eNB_args=test.findtext('Build_eNB_args')
145 146
		eNB_instance=test.findtext('eNB_instance')
		if (eNB_instance is None):
Raphael Defosseux's avatar
Raphael Defosseux committed
147
			RAN.eNB_instance=0
148 149
		else:
			RAN.eNB_instance=int(eNB_instance)
150 151 152 153 154
		eNB_serverId=test.findtext('eNB_serverId')
		if (eNB_serverId is None):
			RAN.eNB_serverId[RAN.eNB_instance]='0'
		else:
			RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId
155

156
	elif action == 'Initialize_eNB':
157
		RAN.eNB_Trace=test.findtext('eNB_Trace')
hardy's avatar
hardy committed
158
		RAN.eNB_Stats=test.findtext('eNB_Stats')
159 160 161 162 163
		datalog_rt_stats_file=test.findtext('rt_stats_cfg')
		if datalog_rt_stats_file is None:
			RAN.datalog_rt_stats_file='datalog_rt_stats.default.yaml'
		else:
			RAN.datalog_rt_stats_file=datalog_rt_stats_file
164
		RAN.Initialize_eNB_args=test.findtext('Initialize_eNB_args')
165
		eNB_instance=test.findtext('eNB_instance')
hardy's avatar
hardy committed
166 167 168 169 170
		USRPIPAddress=test.findtext('USRP_IPAddress')
		if USRPIPAddress is None:
			RAN.USRPIPAddress=''
		else:
			RAN.USRPIPAddress=USRPIPAddress
171 172 173 174
		if (eNB_instance is None):
			RAN.eNB_instance=0
		else:
			RAN.eNB_instance=int(eNB_instance)
175 176 177 178 179
		eNB_serverId=test.findtext('eNB_serverId')
		if (eNB_serverId is None):
			RAN.eNB_serverId[RAN.eNB_instance]='0'
		else:
			RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId
hardy's avatar
hardy committed
180 181 182 183
			
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
184
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
185
		elif (air_interface.lower() in ['nr','lte']):
186
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
187
		else :
188
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
189

190
	elif action == 'Terminate_eNB':
191
		eNB_instance=test.findtext('eNB_instance')
192
		if (eNB_instance is None):
193 194 195
			RAN.eNB_instance=0
		else:
			RAN.eNB_instance=int(eNB_instance)
196 197 198 199 200 201
		eNB_serverId=test.findtext('eNB_serverId')
		if (eNB_serverId is None):
			RAN.eNB_serverId[RAN.eNB_instance]='0'
		else:
			RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId

202 203 204 205 206 207 208 209
		#retx checkers
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
			RAN.ran_checkers['d_retx_th'] = [float(x) for x in string_field.split(',')]
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
			RAN.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]

hardy's avatar
hardy committed
210 211 212
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
213
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
214
		elif (air_interface.lower() in ['nr','lte']):
215
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
216
		else :
217
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
218

219 220
	elif action == 'Initialize_UE':
		ue_id = test.findtext('id')
Remi Hardy's avatar
Remi Hardy committed
221
		CiTestObj.ue_trace=test.findtext('UE_Trace')#temporary variable, to be passed to Module_UE in Initialize_UE call
222 223 224 225 226
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id

227 228 229 230 231 232
	elif action == 'Detach_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
233

234
	elif action == 'Attach_UE':
235 236 237 238 239
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
240 241
		nbMaxUEtoAttach = test.findtext('nbMaxUEtoAttach')
		if (nbMaxUEtoAttach is None):
242
			CiTestObj.nbMaxUEtoAttach = -1
243
		else:
244
			CiTestObj.nbMaxUEtoAttach = int(nbMaxUEtoAttach)
245

246 247 248 249 250 251 252 253
	elif action == 'Terminate_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id


254
	elif action == 'CheckStatusUE':
255 256
		expectedNBUE = test.findtext('expectedNbOfConnectedUEs')
		if (expectedNBUE is None):
257
			CiTestObj.expectedNbOfConnectedUEs = -1
258
		else:
259
			CiTestObj.expectedNbOfConnectedUEs = int(expectedNBUE)
260

261
	elif action == 'Build_OAI_UE':
262
		CiTestObj.Build_OAI_UE_args = test.findtext('Build_OAI_UE_args')
263 264 265
		CiTestObj.clean_repository = test.findtext('clean_repository')
		if (CiTestObj.clean_repository == 'false'):
			CiTestObj.clean_repository = False
266
		else:
267
			CiTestObj.clean_repository = True
Boris Djalal's avatar
Boris Djalal committed
268

269
	elif action == 'Initialize_OAI_UE':
270
		CiTestObj.Initialize_OAI_UE_args = test.findtext('Initialize_OAI_UE_args')
271 272 273 274 275
		UE_instance = test.findtext('UE_instance')
		if (UE_instance is None):
			CiTestObj.UE_instance = 0
		else:
			CiTestObj.UE_instance = UE_instance
hardy's avatar
hardy committed
276 277 278 279
			
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
280
			CiTestObj.air_interface = 'lte-uesoftmodem'
hardy's avatar
hardy committed
281
		elif (air_interface.lower() in ['nr','lte']):
282
			CiTestObj.air_interface = air_interface.lower() +'-uesoftmodem'
hardy's avatar
hardy committed
283
		else :
284 285
			#CiTestObj.air_interface = 'ocp-enb'
			logging.error('OCP UE -- NOT SUPPORTED')
Boris Djalal's avatar
Boris Djalal committed
286

287
	elif action == 'Terminate_OAI_UE':
288 289
		UE_instance=test.findtext('UE_instance')
		if (UE_instance is None):
290
			CiTestObj.UE_instance = '0'
291 292
		else:
			CiTestObj.UE_instance = int(UE_instance)
293 294 295 296 297 298 299 300 301 302
		
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
			CiTestObj.air_interface = 'lte-uesoftmodem'
		elif (air_interface.lower() in ['nr','lte']):
			CiTestObj.air_interface = air_interface.lower() +'-uesoftmodem'
		else :
			#CiTestObj.air_interface = 'ocp-enb'
			logging.error('OCP UE -- NOT SUPPORTED')
Boris Djalal's avatar
Boris Djalal committed
303

304
	elif (action == 'Ping') or (action == 'Ping_CatM_module'):
305 306
		CiTestObj.ping_args = test.findtext('ping_args')
		CiTestObj.ping_packetloss_threshold = test.findtext('ping_packetloss_threshold')
307 308 309 310 311
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
312 313 314 315 316
		ping_rttavg_threshold = test.findtext('ping_rttavg_threshold')
		if (ping_rttavg_threshold is None):
			CiTestObj.ping_rttavg_threshold = ""
		else:
			CiTestObj.ping_rttavg_threshold = ping_rttavg_threshold
317

318
	elif action == 'Iperf':
319
		CiTestObj.iperf_args = test.findtext('iperf_args')
320 321 322 323 324
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
325
		CiTestObj.iperf_direction = test.findtext('direction')#used for modules only
326
		CiTestObj.iperf_packetloss_threshold = test.findtext('iperf_packetloss_threshold')
hardy's avatar
hardy committed
327 328 329 330 331 332 333
		iperf_bitrate_threshold = test.findtext('iperf_bitrate_threshold')
		if (iperf_bitrate_threshold is None):
			CiTestObj.iperf_bitrate_threshold = "90" #if no threshold is specified, default will be 90%
		else:
			CiTestObj.iperf_bitrate_threshold = iperf_bitrate_threshold


334 335 336
		CiTestObj.iperf_profile = test.findtext('iperf_profile')
		if (CiTestObj.iperf_profile is None):
			CiTestObj.iperf_profile = 'balanced'
337
		else:
338
			if CiTestObj.iperf_profile != 'balanced' and CiTestObj.iperf_profile != 'unbalanced' and CiTestObj.iperf_profile != 'single-ue':
339
				logging.error('test-case has wrong profile ' + CiTestObj.iperf_profile)
340
				CiTestObj.iperf_profile = 'balanced'
341 342 343
		CiTestObj.iperf_options = test.findtext('iperf_options')
		if (CiTestObj.iperf_options is None):
			CiTestObj.iperf_options = 'check'
344
		else:
345
			if CiTestObj.iperf_options != 'check' and CiTestObj.iperf_options != 'sink':
346
				logging.error('test-case has wrong option ' + CiTestObj.iperf_options)
347
				CiTestObj.iperf_options = 'check'
348

349
	elif action == 'IdleSleep':
350 351
		string_field = test.findtext('idle_sleep_time_in_sec')
		if (string_field is None):
352
			CiTestObj.idle_sleep_time = 5
353
		else:
354
			CiTestObj.idle_sleep_time = int(string_field)
355

356
	elif action == 'Perform_X2_Handover':
357 358
		string_field = test.findtext('x2_ho_options')
		if (string_field is None):
359
			CiTestObj.x2_ho_options = 'network'
360 361 362
		else:
			if string_field != 'network':
				logging.error('ERROR: test-case has wrong option ' + string_field)
363
				CiTestObj.x2_ho_options = 'network'
364
			else:
365
				CiTestObj.x2_ho_options = string_field
366

367
	elif action == 'Build_PhySim':
368
		ldpc.buildargs  = test.findtext('physim_build_args')
Remi Hardy's avatar
Remi Hardy committed
369 370 371 372 373 374 375 376
		forced_workspace_cleanup = test.findtext('forced_workspace_cleanup')
		if (forced_workspace_cleanup is None):
			ldpc.forced_workspace_cleanup=False
		else:
			if re.match('true', forced_workspace_cleanup, re.IGNORECASE):
				ldpc.forced_workspace_cleanup=True
			else:
				ldpc.forced_workspace_cleanup=False
377

378 379 380 381 382
	elif action == 'Initialize_MME':
		string_field = test.findtext('option')
		if (string_field is not None):
			EPC.mmeConfFile = string_field

383 384 385 386 387
	elif action == 'Initialize_HSS' or action == 'Initialize_SPGW':
		pass
	elif action == 'Terminate_HSS' or action == 'Terminate_MME' or action == 'Terminate_SPGW':
		pass

388 389 390 391 392
	elif action == 'Deploy_EPC':
		string_field = test.findtext('parameters')
		if (string_field is not None):
			EPC.yamlPath = string_field

hardy's avatar
hardy committed
393 394 395 396 397 398 399 400 401 402
	elif action == 'Initialize_5GCN':
		string_field = test.findtext('args')
		if (string_field is not None):
			EPC.cfgDeploy = string_field	

	elif action == 'Terminate_5GCN':
		string_field = test.findtext('args')
		if (string_field is not None):
			EPC.cfgUnDeploy = string_field	

403 404 405 406 407 408 409 410 411 412 413 414 415 416
	elif action == 'Deploy_Object' or action == 'Undeploy_Object':
		eNB_instance=test.findtext('eNB_instance')
		if (eNB_instance is None):
			CONTAINERS.eNB_instance=0
		else:
			CONTAINERS.eNB_instance=int(eNB_instance)
		eNB_serverId=test.findtext('eNB_serverId')
		if (eNB_serverId is None):
			CONTAINERS.eNB_serverId[CONTAINERS.eNB_instance]='0'
		else:
			CONTAINERS.eNB_serverId[CONTAINERS.eNB_instance]=eNB_serverId
		string_field = test.findtext('yaml_path')
		if (string_field is not None):
			CONTAINERS.yamlPath[CONTAINERS.eNB_instance] = string_field
417 418 419 420 421 422
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
			CONTAINERS.ran_checkers['d_retx_th'] = [float(x) for x in string_field.split(',')]
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
			CONTAINERS.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]
423

424
	elif action == 'DeployGenObject' or action == 'UndeployGenObject' or action == 'StatsFromGenObject':
425 426 427 428 429 430 431 432 433
		string_field=test.findtext('yaml_path')
		if (string_field is not None):
			CONTAINERS.yamlPath[0] = string_field
		string_field=test.findtext('services')
		if (string_field is not None):
			CONTAINERS.services[0] = string_field
		string_field=test.findtext('nb_healthy')
		if (string_field is not None):
			CONTAINERS.nb_healthy[0] = int(string_field)
434 435
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
436
			CONTAINERS.ran_checkers['d_retx_th'] = [float(x) for x in string_field.split(',')]
437 438
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
439
			CONTAINERS.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464

	elif action == 'PingFromContainer':
		string_field = test.findtext('container_name')
		if (string_field is not None):
			CONTAINERS.pingContName = string_field
		string_field = test.findtext('options')
		if (string_field is not None):
			CONTAINERS.pingOptions = string_field
		string_field = test.findtext('loss_threshold')
		if (string_field is not None):
			CONTAINERS.pingLossThreshold = string_field

	elif action == 'IperfFromContainer':
		string_field = test.findtext('server_container_name')
		if (string_field is not None):
			CONTAINERS.svrContName = string_field
		string_field = test.findtext('server_options')
		if (string_field is not None):
			CONTAINERS.svrOptions = string_field
		string_field = test.findtext('client_container_name')
		if (string_field is not None):
			CONTAINERS.cliContName = string_field
		string_field = test.findtext('client_options')
		if (string_field is not None):
			CONTAINERS.cliOptions = string_field
465

Robert Schmidt's avatar
Robert Schmidt committed
466
	elif action == 'Run_LDPCTest' or action == 'Run_NRulsimTest':
467
		ldpc.runargs = test.findtext('physim_run_args')
468

469 470 471
	elif action == 'LicenceAndFormattingCheck':
		pass

472 473 474
	elif action == 'Cppcheck_Analysis':
		pass

475 476 477 478 479 480 481 482 483
	elif action == 'Push_Local_Registry':
		string_field = test.findtext('registry_svr_id')
		if (string_field is not None):
			CONTAINERS.registrySvrId = string_field

	elif action == 'Pull_Local_Registry':
		string_field = test.findtext('test_svr_id')
		if (string_field is not None):
			CONTAINERS.testSvrId = string_field
484
		CONTAINERS.imageToPull.clear()
485 486 487
		string_field = test.findtext('images_to_pull')
		if (string_field is not None):
			CONTAINERS.imageToPull = string_field.split()
488 489 490 491 492 493

	elif action == 'Clean_Test_Server_Images':
		string_field = test.findtext('test_svr_id')
		if (string_field is not None):
			CONTAINERS.testSvrId = string_field

494
	else:
495
		logging.warning(f"unknown action {action} from option-parsing point-of-view")
496

497

498 499 500 501 502 503 504 505 506 507 508 509
#check if given test is in list
#it is in list if one of the strings in 'list' is at the beginning of 'test'
def test_in_list(test, list):
	for check in list:
		check=check.replace('+','')
		if (test.startswith(check)):
			return True
	return False

def receive_signal(signum, frame):
	sys.exit(1)

510 511 512 513 514





515
#-----------------------------------------------------------
516
# MAIN PART
517
#-----------------------------------------------------------
518 519 520

#loading xml action list from yaml
import yaml
521
xml_class_list_file='xml_class_list.yml'
hardy's avatar
hardy committed
522
if (os.path.isfile(xml_class_list_file)):
523 524 525
	yaml_file=xml_class_list_file
elif (os.path.isfile('ci-scripts/'+xml_class_list_file)):
	yaml_file='ci-scripts/'+xml_class_list_file
526 527 528
else:
	logging.error("XML action list yaml file cannot be found")
	sys.exit("XML action list yaml file cannot be found")
Remi Hardy's avatar
Remi Hardy committed
529

530 531 532 533 534
with open(yaml_file,'r') as f:
    # The FullLoader parameter handles the conversion-$
    #from YAML scalar values to Python dictionary format$
    xml_class_list = yaml.load(f,Loader=yaml.FullLoader)

hardy's avatar
hardy committed
535

hardy's avatar
hardy committed
536 537 538 539 540 541 542 543 544 545

#loading UE infrastructure from yaml
ue_infra_file='ci_ueinfra.yaml'
if (os.path.isfile(ue_infra_file)):
	yaml_file=ue_infra_file
elif (os.path.isfile('ci-scripts/'+ue_infra_file)):
	yaml_file='ci-scripts/'+ue_infra_file
else:
	logging.error("UE infrastructure yaml file cannot be found")
	sys.exit("UE infrastructure file cannot be found")
546
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
hardy's avatar
hardy committed
547
InfraUE.Get_UE_Infra(yaml_file) #read the UE infra, filename is hardcoded and unique for the moment but should be passed as parameter from the test suite
548 549


550

551
mode = ''
552

553
CiTestObj = cls_oaicitest.OaiCiTest()
554 555 556 557
 
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement()
RAN = ran.RANManagement()
558
HTML = cls_oai_html.HTMLManagement()
559
CONTAINERS = cls_containerize.Containerize()
560
SCA = cls_static_code_analysis.StaticCodeAnalysis()
561
PHYSIM = cls_physim1.PhySim()
562
CLUSTER = cls_cluster.Cluster()
563

564 565
ldpc=cls_physim.PhySim()    #create an instance for LDPC test using GPU or CPU build

566

567
#-----------------------------------------------------------
568
# Parsing Command Line Arguments
569 570
#-----------------------------------------------------------

571
import args_parse
572
py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER)
573

574

575

576
#-----------------------------------------------------------
577
# TEMPORARY params management (UNUSED)
578 579 580
#-----------------------------------------------------------
#temporary solution for testing:
if py_param_file_present == True:
581 582
	AssignParams(py_params)

583

584 585 586
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
587 588 589
#COTS_UE instanciation and ADB server init
#ue id and ue mode are retrieved from xml
COTS_UE=cls_cots_ue.CotsUe(CiTestObj.ADBIPAddress, CiTestObj.ADBUserName,CiTestObj.ADBPassword)
590 591


592
#-----------------------------------------------------------
593
# mode amd XML class (action) analysis
594
#-----------------------------------------------------------
595
cwd = os.getcwd()
596

597
if re.match('^TerminateeNB$', mode, re.IGNORECASE):
598
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '':
599
		HELP.GenericHelp(CONST.Version)
600
		sys.exit('Insufficient Parameter')
601 602
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
Raphael Defosseux's avatar
Raphael Defosseux committed
603
	RAN.eNB_instance=0
604
	RAN.eNB_serverId[0]='0'
605
	RAN.eNBSourceCodePath='/tmp/'
606
	RAN.TerminateeNB(HTML, EPC)
607
elif re.match('^TerminateUE$', mode, re.IGNORECASE):
608
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
609
		HELP.GenericHelp(CONST.Version)
610 611
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
612
	CiTestObj.TerminateUE(HTML,COTS_UE,InfraUE,CiTestObj.ue_trace)
Boris Djalal's avatar
Boris Djalal committed
613
elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE):
614
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '':
615
		HELP.GenericHelp(CONST.Version)
Boris Djalal's avatar
Boris Djalal committed
616 617
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
618
	CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
619
elif re.match('^TerminateHSS$', mode, re.IGNORECASE):
620
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
621
		HELP.GenericHelp(CONST.Version)
622
		sys.exit('Insufficient Parameter')
623
	EPC.TerminateHSS(HTML)
624
elif re.match('^TerminateMME$', mode, re.IGNORECASE):
625
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
626
		HELP.GenericHelp(CONST.Version)
627
		sys.exit('Insufficient Parameter')
628
	EPC.TerminateMME(HTML)
629
elif re.match('^TerminateSPGW$', mode, re.IGNORECASE):
630
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath== '':
631
		HELP.GenericHelp(CONST.Version)
632
		sys.exit('Insufficient Parameter')
633
	EPC.TerminateSPGW(HTML)
634
elif re.match('^LogCollectBuild$', mode, re.IGNORECASE):
635
	if (RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '') and (CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == ''):
636
		HELP.GenericHelp(CONST.Version)
637
		sys.exit('Insufficient Parameter')
638 639
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
640
	CiTestObj.LogCollectBuild(RAN)
641
elif re.match('^LogCollecteNB$', mode, re.IGNORECASE):
642
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '':
643
		HELP.GenericHelp(CONST.Version)
644
		sys.exit('Insufficient Parameter')
645
	if RAN.eNBIPAddress == 'none':
646
		cmd = 'zip -r enb.log.' + RAN.BuildId + '.zip cmake_targets/log'
647
		logging.info(cmd)
648
		zipStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=60)
649
		sys.exit(0)
650
	RAN.LogCollecteNB()
651
elif re.match('^LogCollectHSS$', mode, re.IGNORECASE):
652
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
653
		HELP.GenericHelp(CONST.Version)
654
		sys.exit('Insufficient Parameter')
655
	EPC.LogCollectHSS()
656
elif re.match('^LogCollectMME$', mode, re.IGNORECASE):
657
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
658
		HELP.GenericHelp(CONST.Version)
659
		sys.exit('Insufficient Parameter')
660
	EPC.LogCollectMME()
661
elif re.match('^LogCollectSPGW$', mode, re.IGNORECASE):
662
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
663
		HELP.GenericHelp(CONST.Version)
664
		sys.exit('Insufficient Parameter')
665
	EPC.LogCollectSPGW()
666
elif re.match('^LogCollectPing$', mode, re.IGNORECASE):
667
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
668
		HELP.GenericHelp(CONST.Version)
669
		sys.exit('Insufficient Parameter')
670
	CiTestObj.LogCollectPing(EPC)
671
elif re.match('^LogCollectIperf$', mode, re.IGNORECASE):
672
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
673
		HELP.GenericHelp(CONST.Version)
674
		sys.exit('Insufficient Parameter')
675
	CiTestObj.LogCollectIperf(EPC)
Boris Djalal's avatar
Boris Djalal committed
676
elif re.match('^LogCollectOAIUE$', mode, re.IGNORECASE):
677
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
678
		HELP.GenericHelp(CONST.Version)
679
		sys.exit('Insufficient Parameter')
680
	CiTestObj.LogCollectOAIUE()
681
elif re.match('^InitiateHtml$', mode, re.IGNORECASE):
682
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
683
		HELP.GenericHelp(CONST.Version)
684 685
		sys.exit('Insufficient Parameter')
	count = 0
686
	foundCount = 0
687
	while (count < HTML.nbTestXMLfiles):
688
		#xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[count]
689
		xml_test_file = sys.path[0] + "/" + CiTestObj.testXMLfiles[count]
690
		if (os.path.isfile(xml_test_file)):
691 692 693 694
			try:
				xmlTree = ET.parse(xml_test_file)
			except:
				print("Error while parsing file: " + xml_test_file)
695
			xmlRoot = xmlTree.getroot()
696 697 698
			HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-' + str(count)))
			HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='test-tab-' + str(count)))
			HTML.htmlTabIcons.append(xmlRoot.findtext('htmlTabIcon',default='info-sign'))
699
			foundCount += 1
700
		count += 1
701 702
	if foundCount != HTML.nbTestXMLfiles:
		HTML.nbTestXMLfiles=foundCount
703
	
704
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
705 706 707 708
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
		HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
709 710
		HTML.htmlNb_Smartphones=len(CiTestObj.UEDevices)
		HTML.htmlNb_CATM_Modules=len(CiTestObj.CatMDevices)
711
	HTML.CreateHtmlHeader(CiTestObj.ADBIPAddress)
712
elif re.match('^FinalizeHtml$', mode, re.IGNORECASE):
713 714 715
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
	logging.info('\u001B[1m  Creating HTML footer \u001B[0m')
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
716

717 718
	CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
	CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
719
	HTML.CreateHtmlFooter(CiTestObj.finalStatus)
720
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
721 722 723
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
	logging.info('\u001B[1m  Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
724
	if re.match('^TesteNB$', mode, re.IGNORECASE):
725
		if RAN.eNBIPAddress == '' or RAN.ranRepository == '' or RAN.ranBranch == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '' or EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '' or CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == '':
726
			HELP.GenericHelp(CONST.Version)
727 728
			if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '' or EPC.Type == '':
				HELP.EPCSrvHelp(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath, EPC.Type)
729 730 731 732
			if RAN.ranRepository == '':
				HELP.GitSrvHelp(RAN.ranRepository, RAN.ranBranch, RAN.ranCommitID, RAN.ranAllowMerge, RAN.ranTargetBranch)
			if RAN.eNBIPAddress == ''  or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '':
				HELP.eNBSrvHelp(RAN.eNBIPAddress, RAN.eNBUserName, RAN.eNBPassword, RAN.eNBSourceCodePath)
733 734
			sys.exit('Insufficient Parameter')

735 736 737
		if (EPC.IPAddress!= '') and (EPC.IPAddress != 'none'):
			SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, cwd + "/tcp_iperf_stats.awk", "/tmp")
			SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, cwd + "/active_net_interfaces.awk", "/tmp")
738
	else:
739 740
		if CiTestObj.UEIPAddress == '' or CiTestObj.ranRepository == '' or CiTestObj.ranBranch == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
			HELP.GenericHelp(CONST.Version)
741
			sys.exit('UE: Insufficient Parameter')
742

743
	#read test_case_list.xml file
744
	# if no parameters for XML file, use default value
745
	if (HTML.nbTestXMLfiles != 1):
746
		xml_test_file = cwd + "/test_case_list.xml"
747
	else:
748
		xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[0]
749 750 751 752 753 754

	xmlTree = ET.parse(xml_test_file)
	xmlRoot = xmlTree.getroot()

	exclusion_tests=xmlRoot.findtext('TestCaseExclusionList',default='')
	requested_tests=xmlRoot.findtext('TestCaseRequestedList',default='')
755 756 757
	if (HTML.nbTestXMLfiles == 1):
		HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-0'))
		HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-0'))
758
		repeatCount = xmlRoot.findtext('repeatCount',default='1')
759
		testStability = xmlRoot.findtext('TestUnstable',default='False')
760
		CiTestObj.repeatCounts.append(int(repeatCount))
761 762 763 764 765
		if testStability == 'True':
			CiTestObj.testUnstable = True
			HTML.testUnstable = True
			CiTestObj.testMinStableId = xmlRoot.findtext('TestMinId',default='999999')
			HTML.testMinStableId = CiTestObj.testMinStableId
766
			logging.warning('Test is tagged as Unstable -- starting from TestID ' + str(CiTestObj.testMinStableId))
767 768 769 770 771 772 773 774 775 776
	all_tests=xmlRoot.findall('testCase')

	exclusion_tests=exclusion_tests.split()
	requested_tests=requested_tests.split()

	#check that exclusion tests are well formatted
	#(6 digits or less than 6 digits followed by +)
	for test in exclusion_tests:
		if     (not re.match('^[0-9]{6}$', test) and
				not re.match('^[0-9]{1,5}\+$', test)):
777
			logging.error('exclusion test is invalidly formatted: ' + test)
778 779
			sys.exit(1)
		else:
780
			logging.info(test)
781 782 783 784 785 786 787

	#check that requested tests are well formatted
	#(6 digits or less than 6 digits followed by +)
	#be verbose
	for test in requested_tests:
		if     (re.match('^[0-9]{6}$', test) or
				re.match('^[0-9]{1,5}\+$', test)):
788
			logging.info('test group/case requested: ' + test)
789
		else:
790
			logging.error('requested test is invalidly formatted: ' + test)
791
			sys.exit(1)
792
	if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
793
		CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
794
		EPC.SetMmeIPAddress()
795
		EPC.SetAmfIPAddress()
796 797 798 799 800

	#get the list of tests to be done
	todo_tests=[]
	for test in requested_tests:
		if    (test_in_list(test, exclusion_tests)):
801
			logging.info('test will be skipped: ' + test)
802
		else:
803
			#logging.info('test will be run: ' + test)
804
			todo_tests.append(test)
805

806
	signal.signal(signal.SIGUSR1, receive_signal)
807

808
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
809 810 811
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
812 813
	elif (CiTestObj.ADBIPAddress == 'modules'):
		CiTestObj.UEDevices.append('COTS-Module')
814 815 816 817
	else:
		CiTestObj.UEDevices.append('OAI-UE')
	HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
	HTML.CreateHtmlTabHeader()
818

819
	# On CI bench w/ containers, we need to validate if IP routes are set
820
	if EPC.IPAddress == '172.21.16.136':
821
		CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
822
	if CONTAINERS.eNBIPAddress == '172.21.16.127':
823
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
824
	if CONTAINERS.eNB1IPAddress == '172.21.16.127':
825
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
826
	if CONTAINERS.eNBIPAddress == '172.21.16.128':
827
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
828
	if CONTAINERS.eNB1IPAddress == '172.21.16.128':
829
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
830
	if CONTAINERS.eNBIPAddress == '172.21.16.137':
831
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
832
	if CONTAINERS.eNB1IPAddress == '172.21.16.137':
833 834
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)

835
	CiTestObj.FailReportCnt = 0
836
	RAN.prematureExit=True
837
	HTML.startTime=int(round(time.time() * 1000))
838 839
	while CiTestObj.FailReportCnt < CiTestObj.repeatCounts[0] and RAN.prematureExit:
		RAN.prematureExit=False
840
		# At every iteration of the retry loop, a separator will be added
841 842
		# pass CiTestObj.FailReportCnt as parameter of HTML.CreateHtmlRetrySeparator
		HTML.CreateHtmlRetrySeparator(CiTestObj.FailReportCnt)
843
		for test_case_id in todo_tests:
844
			if RAN.prematureExit:
845
				break
846
			for test in all_tests:
847
				if RAN.prematureExit:
848
					break
849 850 851
				id = test.get('id')
				if test_case_id != id:
					continue
852
				CiTestObj.testCase_id = id
853 854
				HTML.testCase_id=CiTestObj.testCase_id
				EPC.testCase_id=CiTestObj.testCase_id
855
				CiTestObj.desc = test.findtext('desc')
856
				HTML.desc=CiTestObj.desc
857
				action = test.findtext('class')
858
				if (CheckClassValidity(xml_class_list, action, id) == False):
859
					continue
860
				CiTestObj.ShowTestID()
861 862
				GetParametersFromXML(action)
				if action == 'Initialize_UE' or action == 'Attach_UE' or action == 'Detach_UE' or action == 'Ping' or action == 'Iperf' or action == 'Reboot_UE' or action == 'DataDisable_UE' or action == 'DataEnable_UE' or action == 'CheckStatusUE':
863
					if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
864 865
						#in these cases, having no devices is critical, GetAllUEDevices function has to manage it as a critical error, reason why terminate_ue_flag is set to True
						terminate_ue_flag = True 
866 867 868 869 870
						# Now we stop properly the test-suite --> clean reporting
						status = CiTestObj.GetAllUEDevices(terminate_ue_flag)
						if not status:
							RAN.prematureExit = True
							break
871
				if action == 'Build_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
872
					RAN.BuildeNB(HTML)
873
				elif action == 'WaitEndBuild_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
874
					RAN.WaitBuildeNBisFinished(HTML)
875
				elif action == 'Initialize_eNB':
876 877
					check_eNB = False
					check_OAI_UE = False
878
					RAN.pStatus=CiTestObj.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
Raphael Defosseux's avatar
Raphael Defosseux committed
879
					RAN.InitializeeNB(HTML, EPC)
880
					if RAN.prematureExit:
hardy's avatar
hardy committed
881
						CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
882
				elif action == 'Terminate_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
883
					RAN.TerminateeNB(HTML, EPC)
884
				elif action == 'Initialize_UE':
885
					CiTestObj.InitializeUE(HTML,RAN, EPC, COTS_UE, InfraUE, CiTestObj.ue_trace, CONTAINERS)
886
				elif action == 'Terminate_UE':
Remi Hardy's avatar
Remi Hardy committed
887
					CiTestObj.TerminateUE(HTML,COTS_UE, InfraUE, CiTestObj.ue_trace)
888
				elif action == 'Attach_UE':
889
					CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
890
				elif action == 'Detach_UE':
891
					CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
892
				elif action == 'DataDisable_UE':
893
					CiTestObj.DataDisableUE(HTML)
894
				elif action == 'DataEnable_UE':
895
					CiTestObj.DataEnableUE(HTML)
896
				elif action == 'CheckStatusUE':
897
					CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
898
				elif action == 'Build_OAI_UE':
899
					CiTestObj.BuildOAIUE(HTML)
900
				elif action == 'Initialize_OAI_UE':
901
					CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
902
				elif action == 'Terminate_OAI_UE':
903
					CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
904
				elif action == 'Initialize_CatM_module':
905
					CiTestObj.InitializeCatM(HTML)
906
				elif action == 'Terminate_CatM_module':
907
					CiTestObj.TerminateCatM(HTML)
908
				elif action == 'Attach_CatM_module':
909
					CiTestObj.AttachCatM(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
910
				elif action == 'Detach_CatM_module':
911
					CiTestObj.TerminateCatM(HTML)
912
				elif action == 'Ping_CatM_module':
913
					CiTestObj.PingCatM(HTML,RAN,EPC,COTS_UE,EPC,InfraUE,CONTAINERS)
914
				elif action == 'Ping':
915
					CiTestObj.Ping(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS)
916
				elif action == 'Iperf':
917
					CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS)
918
				elif action == 'Reboot_UE':
919
					CiTestObj.RebootUE(HTML,RAN,EPC)
920
				elif action == 'Initialize_HSS':
Raphael Defosseux's avatar
Raphael Defosseux committed
921
					EPC.InitializeHSS(HTML)
922
				elif action == 'Terminate_HSS':
Raphael Defosseux's avatar
Raphael Defosseux committed
923
					EPC.TerminateHSS(HTML)
924
				elif action == 'Initialize_MME':
Raphael Defosseux's avatar
Raphael Defosseux committed
925
					EPC.InitializeMME(HTML)
926
				elif action == 'Terminate_MME':
Raphael Defosseux's avatar
Raphael Defosseux committed
927
					EPC.TerminateMME(HTML)
928
				elif action == 'Initialize_SPGW':
Raphael Defosseux's avatar
Raphael Defosseux committed
929
					EPC.InitializeSPGW(HTML)
930
				elif action == 'Terminate_SPGW':
Raphael Defosseux's avatar
Raphael Defosseux committed
931
					EPC.TerminateSPGW(HTML)
932 933 934 935
				elif action == 'Initialize_5GCN':
					EPC.Initialize5GCN(HTML)
				elif action == 'Terminate_5GCN':
					EPC.Terminate5GCN(HTML)
936
				elif action == 'Deploy_EPC':
Raphael Defosseux's avatar
Raphael Defosseux committed
937
					EPC.DeployEpc(HTML)
938
				elif action == 'Undeploy_EPC':
Raphael Defosseux's avatar
Raphael Defosseux committed
939
					EPC.UndeployEpc(HTML)
940
				elif action == 'Initialize_FlexranCtrl':
941
					CiTestObj.InitializeFlexranCtrl(HTML,RAN,EPC)
942
				elif action == 'Terminate_FlexranCtrl':
943
					CiTestObj.TerminateFlexranCtrl(HTML,RAN,EPC)
944
				elif action == 'IdleSleep':
945
					CiTestObj.IdleSleep(HTML)
946
				elif action == 'Perform_X2_Handover':
947
					CiTestObj.Perform_X2_Handover(HTML,RAN,EPC)
948 949
				elif action == 'Build_PhySim':
					HTML=ldpc.Build_PhySim(HTML,CONST)
950
					if ldpc.exitStatus==1:
951
						RAN.prematureExit = True
952 953 954 955
				elif action == 'Run_LDPCTest':
					HTML=ldpc.Run_LDPCTest(HTML,CONST,id)
					if ldpc.exitStatus==1:
						RAN.prematureExit = True
Robert Schmidt's avatar
Robert Schmidt committed
956 957 958 959
				elif action == 'Run_NRulsimTest':
					HTML=ldpc.Run_NRulsimTest(HTML,CONST,id)
					if ldpc.exitStatus==1:
						RAN.prematureExit = True
960 961 962
				elif action == 'Build_Cluster_Image':
					if not CLUSTER.BuildClusterImage(HTML):
						RAN.prematureExit = True
963
				elif action == 'Build_Image':
Raphael Defosseux's avatar
Raphael Defosseux committed
964
					CONTAINERS.BuildImage(HTML)
965 966
				elif action == 'Build_Proxy':
					CONTAINERS.BuildProxy(HTML)
967 968 969 970 971 972 973 974 975 976
				elif action == 'Push_Local_Registry':
					success = CONTAINERS.Push_Image_to_Local_Registry(HTML)
					if not success:
						RAN.prematureExit = True
				elif action == 'Pull_Local_Registry':
					success = CONTAINERS.Pull_Image_from_Local_Registry(HTML)
					if not success:
						RAN.prematureExit = True
				elif action == 'Clean_Test_Server_Images':
					success = CONTAINERS.Clean_Test_Server_Images(HTML)
977 978
					if not success:
						RAN.prematureExit = True
979
				elif action == 'Deploy_Object':
Raphael Defosseux's avatar
Raphael Defosseux committed
980
					CONTAINERS.DeployObject(HTML, EPC)
981
					if CONTAINERS.exitStatus==1:
982
						CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
983
						RAN.prematureExit = True
984
				elif action == 'Undeploy_Object':
Raphael Defosseux's avatar
Raphael Defosseux committed
985
					CONTAINERS.UndeployObject(HTML, RAN)
986 987
				elif action == 'Cppcheck_Analysis':
					SCA.CppCheckAnalysis(HTML)
988
				elif action == 'LicenceAndFormattingCheck':
989 990 991
					ret = SCA.LicenceAndFormattingCheck(HTML)
					if ret != 0:
						RAN.prematureExit = True
992
				elif action == 'Deploy_Run_PhySim':
993
					PHYSIM.Deploy_PhySim(HTML, RAN)
994
				elif action == 'DeployGenObject':
995
					CONTAINERS.DeployGenObject(HTML, RAN, CiTestObj)
996 997 998
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'UndeployGenObject':
999
					CONTAINERS.UndeployGenObject(HTML, RAN, CiTestObj)
1000 1001 1002
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'PingFromContainer':
1003
					CONTAINERS.PingFromContainer(HTML, RAN, CiTestObj)
1004 1005 1006
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'IperfFromContainer':
1007
					CONTAINERS.IperfFromContainer(HTML, RAN)
1008 1009
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
1010 1011
				elif action == 'StatsFromGenObject':
					CONTAINERS.StatsFromGenObject(HTML)
1012 1013
				elif action == 'Push_Images_To_Test_Servers':
					logging.debug('To be implemented')
1014
				else:
1015
					sys.exit('Invalid class (action) from xml')
1016
				if RAN.prematureExit:
1017
					if CiTestObj.testCase_id == CiTestObj.testMinStableId:
1018
						logging.warning('Scenario has reached minimal stability point')
1019 1020
						CiTestObj.testStabilityPointReached = True
						HTML.testStabilityPointReached = True
1021
		CiTestObj.FailReportCnt += 1
1022
	if CiTestObj.FailReportCnt == CiTestObj.repeatCounts[0] and RAN.prematureExit:
1023
		logging.error('\u001B[1;37;41mScenario failed ' + str(CiTestObj.FailReportCnt) + ' time(s)\u001B[0m')
1024
		HTML.CreateHtmlTabFooter(False)
1025
		if CiTestObj.testUnstable and (CiTestObj.testStabilityPointReached or CiTestObj.testMinStableId == '999999'):
1026
			logging.warning('\u001B[1;30;43mScenario has reached minimal stability point -- Not a Failure\u001B[0m')
1027 1028
		else:
			sys.exit('Failed Scenario')
1029
	else:
1030
		logging.info('\u001B[1;37;42mScenario passed after ' + str(CiTestObj.FailReportCnt) + ' time(s)\u001B[0m')
1031
		HTML.CreateHtmlTabFooter(True)
1032 1033
elif re.match('^LoadParams$', mode, re.IGNORECASE):
	pass
1034
else:
1035
	HELP.GenericHelp(CONST.Version)
1036
	sys.exit('Invalid mode')
1037
sys.exit(0)