main.py 39.3 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 73
	level=logging.DEBUG,
	format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s"
74 75
)

76

77

78 79 80 81 82 83 84

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



85
def CheckClassValidity(xml_class_list,action,id):
86 87 88 89 90 91
	if action not in xml_class_list:
		logging.debug('ERROR: test-case ' + id + ' has unlisted class ' + action + ' ##CHECK xml_class_list.yml')
		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 339 340
			if CiTestObj.iperf_profile != 'balanced' and CiTestObj.iperf_profile != 'unbalanced' and CiTestObj.iperf_profile != 'single-ue':
				logging.debug('ERROR: test-case has wrong profile ' + CiTestObj.iperf_profile)
				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 346 347
			if CiTestObj.iperf_options != 'check' and CiTestObj.iperf_options != 'sink':
				logging.debug('ERROR: test-case has wrong option ' + CiTestObj.iperf_options)
				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 == 'Deploy_EPC':
		string_field = test.findtext('parameters')
		if (string_field is not None):
			EPC.yamlPath = string_field

hardy's avatar
hardy committed
388 389 390 391 392 393 394 395 396 397
	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	

398 399 400 401 402 403 404 405 406 407 408 409 410 411
	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
412 413 414 415 416 417
		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(',')]
418

419
	elif action == 'DeployGenObject' or action == 'UndeployGenObject' or action == 'StatsFromGenObject':
420 421 422 423 424 425 426 427 428
		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)
429 430
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
431
			CONTAINERS.ran_checkers['d_retx_th'] = [float(x) for x in string_field.split(',')]
432 433
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
434
			CONTAINERS.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

	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
460

461 462 463 464 465 466 467 468 469 470 471
	elif action == 'Copy_Image_to_Test':
		string_field = test.findtext('image_name')
		if (string_field is not None):
			CONTAINERS.imageToCopy = string_field
		string_field = test.findtext('registry_svr_id')
		if (string_field is not None):
			CONTAINERS.registrySvrId = string_field
		string_field = test.findtext('test_svr_id')
		if (string_field is not None):
			CONTAINERS.testSvrId = string_field

Robert Schmidt's avatar
Robert Schmidt committed
472
	elif action == 'Run_LDPCTest' or action == 'Run_NRulsimTest':
473
		ldpc.runargs = test.findtext('physim_run_args')
474

475 476 477
	elif action == 'LicenceAndFormattingCheck':
		pass

478 479 480
	elif action == 'Cppcheck_Analysis':
		pass

481
	else:
482
		logging.error(f"unknown action {action}")
483

484

485 486 487 488 489 490 491 492 493 494 495 496
#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)

497 498 499 500 501





502
#-----------------------------------------------------------
503
# MAIN PART
504
#-----------------------------------------------------------
505 506 507

#loading xml action list from yaml
import yaml
508
xml_class_list_file='xml_class_list.yml'
hardy's avatar
hardy committed
509
if (os.path.isfile(xml_class_list_file)):
510 511 512
	yaml_file=xml_class_list_file
elif (os.path.isfile('ci-scripts/'+xml_class_list_file)):
	yaml_file='ci-scripts/'+xml_class_list_file
513 514 515
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
516

517 518 519 520 521
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
522

hardy's avatar
hardy committed
523 524 525 526 527 528 529 530 531 532

#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")
533
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
hardy's avatar
hardy committed
534
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
535 536


537

538
mode = ''
539

540
CiTestObj = cls_oaicitest.OaiCiTest()
541 542 543 544
 
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement()
RAN = ran.RANManagement()
545
HTML = cls_oai_html.HTMLManagement()
546
CONTAINERS = cls_containerize.Containerize()
547
SCA = cls_static_code_analysis.StaticCodeAnalysis()
548
PHYSIM = cls_physim1.PhySim()
549
CLUSTER = cls_cluster.Cluster()
550

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

553

554
#-----------------------------------------------------------
555
# Parsing Command Line Arguments
556 557
#-----------------------------------------------------------

558
import args_parse
559
py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER)
560

561

562

563
#-----------------------------------------------------------
564
# TEMPORARY params management (UNUSED)
565 566 567
#-----------------------------------------------------------
#temporary solution for testing:
if py_param_file_present == True:
568 569
	AssignParams(py_params)

570

571 572 573
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
574 575 576
#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)
577 578


579
#-----------------------------------------------------------
580
# mode amd XML class (action) analysis
581
#-----------------------------------------------------------
582
cwd = os.getcwd()
583

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

704 705
	CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
	CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
706
	HTML.CreateHtmlFooter(CiTestObj.finalStatus)
707
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
708
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
709
	logging.debug('\u001B[1m  Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
710
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
711
	if re.match('^TesteNB$', mode, re.IGNORECASE):
712
		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 == '':
713
			HELP.GenericHelp(CONST.Version)
714 715
			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)
716 717 718 719
			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)
720 721
			sys.exit('Insufficient Parameter')

722 723 724
		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")
725
	else:
726 727
		if CiTestObj.UEIPAddress == '' or CiTestObj.ranRepository == '' or CiTestObj.ranBranch == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
			HELP.GenericHelp(CONST.Version)
728
			sys.exit('UE: Insufficient Parameter')
729

730
	#read test_case_list.xml file
731
	# if no parameters for XML file, use default value
732
	if (HTML.nbTestXMLfiles != 1):
733
		xml_test_file = cwd + "/test_case_list.xml"
734
	else:
735
		xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[0]
736 737 738 739 740 741

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

	exclusion_tests=xmlRoot.findtext('TestCaseExclusionList',default='')
	requested_tests=xmlRoot.findtext('TestCaseRequestedList',default='')
742 743 744
	if (HTML.nbTestXMLfiles == 1):
		HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-0'))
		HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-0'))
745
		repeatCount = xmlRoot.findtext('repeatCount',default='1')
746
		testStability = xmlRoot.findtext('TestUnstable',default='False')
747
		CiTestObj.repeatCounts.append(int(repeatCount))
748 749 750 751 752 753
		if testStability == 'True':
			CiTestObj.testUnstable = True
			HTML.testUnstable = True
			CiTestObj.testMinStableId = xmlRoot.findtext('TestMinId',default='999999')
			HTML.testMinStableId = CiTestObj.testMinStableId
			logging.debug('Test is tagged as Unstable -- starting from TestID ' + str(CiTestObj.testMinStableId))
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
	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)):
			logging.debug('ERROR: exclusion test is invalidly formatted: ' + test)
			sys.exit(1)
		else:
			logging.debug(test)

	#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)):
			logging.debug('INFO: test group/case requested: ' + test)
		else:
			logging.debug('ERROR: requested test is invalidly formatted: ' + test)
			sys.exit(1)
779
	if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
780
		CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
781
		EPC.SetMmeIPAddress()
782
		EPC.SetAmfIPAddress()
783 784 785 786 787 788 789

	#get the list of tests to be done
	todo_tests=[]
	for test in requested_tests:
		if    (test_in_list(test, exclusion_tests)):
			logging.debug('INFO: test will be skipped: ' + test)
		else:
790
			#logging.debug('INFO: test will be run: ' + test)
791
			todo_tests.append(test)
792

793
	signal.signal(signal.SIGUSR1, receive_signal)
794

795
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
796 797 798
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
799 800
	elif (CiTestObj.ADBIPAddress == 'modules'):
		CiTestObj.UEDevices.append('COTS-Module')
801 802 803 804
	else:
		CiTestObj.UEDevices.append('OAI-UE')
	HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
	HTML.CreateHtmlTabHeader()
805

806
	# On CI bench w/ containers, we need to validate if IP routes are set
807
	if EPC.IPAddress == '172.21.16.136':
808
		CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
809
	if CONTAINERS.eNBIPAddress == '172.21.16.127':
810
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
811
	if CONTAINERS.eNB1IPAddress == '172.21.16.127':
812
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
813
	if CONTAINERS.eNBIPAddress == '172.21.16.128':
814
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
815
	if CONTAINERS.eNB1IPAddress == '172.21.16.128':
816
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
817
	if CONTAINERS.eNBIPAddress == '172.21.16.137':
818
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
819
	if CONTAINERS.eNB1IPAddress == '172.21.16.137':
820 821
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)

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