main.py 36.7 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

49 50 51 52 53
import sshconnection 
import epc
import ran
import html

54

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

75

76

77 78 79 80 81 82 83

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



84
def CheckClassValidity(xml_class_list,action,id):
85 86 87 88 89 90
	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
91

92 93 94

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

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



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

142
	elif action == 'WaitEndBuild_eNB':
143
		RAN.Build_eNB_args=test.findtext('Build_eNB_args')
144 145
		eNB_instance=test.findtext('eNB_instance')
		if (eNB_instance is None):
Raphael Defosseux's avatar
Raphael Defosseux committed
146
			RAN.eNB_instance=0
147 148
		else:
			RAN.eNB_instance=int(eNB_instance)
149 150 151 152 153
		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
154

155
	elif action == 'Initialize_eNB':
156
		RAN.eNB_Trace=test.findtext('eNB_Trace')
hardy's avatar
hardy committed
157
		RAN.eNB_Stats=test.findtext('eNB_Stats')
158
		RAN.Initialize_eNB_args=test.findtext('Initialize_eNB_args')
159
		eNB_instance=test.findtext('eNB_instance')
hardy's avatar
hardy committed
160 161 162 163 164
		USRPIPAddress=test.findtext('USRP_IPAddress')
		if USRPIPAddress is None:
			RAN.USRPIPAddress=''
		else:
			RAN.USRPIPAddress=USRPIPAddress
165 166 167 168
		if (eNB_instance is None):
			RAN.eNB_instance=0
		else:
			RAN.eNB_instance=int(eNB_instance)
169 170 171 172 173
		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
174 175 176 177
			
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
178
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
179
		elif (air_interface.lower() in ['nr','lte']):
180
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
181
		else :
182
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
183

184
	elif action == 'Terminate_eNB':
185
		eNB_instance=test.findtext('eNB_instance')
186
		if (eNB_instance is None):
187 188 189
			RAN.eNB_instance=0
		else:
			RAN.eNB_instance=int(eNB_instance)
190 191 192 193 194 195
		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
196 197 198
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
199
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
200
		elif (air_interface.lower() in ['nr','lte']):
201
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
202
		else :
203
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
204

205 206
	elif action == 'Initialize_UE':
		ue_id = test.findtext('id')
Remi Hardy's avatar
Remi Hardy committed
207
		CiTestObj.ue_trace=test.findtext('UE_Trace')#temporary variable, to be passed to Module_UE in Initialize_UE call
208 209 210 211 212
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id

213 214 215 216 217 218
	elif action == 'Detach_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
219

220
	elif action == 'Attach_UE':
221 222 223 224 225
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
226 227
		nbMaxUEtoAttach = test.findtext('nbMaxUEtoAttach')
		if (nbMaxUEtoAttach is None):
228
			CiTestObj.nbMaxUEtoAttach = -1
229
		else:
230
			CiTestObj.nbMaxUEtoAttach = int(nbMaxUEtoAttach)
231

232 233 234 235 236 237 238 239
	elif action == 'Terminate_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id


240
	elif action == 'CheckStatusUE':
241 242
		expectedNBUE = test.findtext('expectedNbOfConnectedUEs')
		if (expectedNBUE is None):
243
			CiTestObj.expectedNbOfConnectedUEs = -1
244
		else:
245
			CiTestObj.expectedNbOfConnectedUEs = int(expectedNBUE)
246

247
	elif action == 'Build_OAI_UE':
248
		CiTestObj.Build_OAI_UE_args = test.findtext('Build_OAI_UE_args')
249 250 251
		CiTestObj.clean_repository = test.findtext('clean_repository')
		if (CiTestObj.clean_repository == 'false'):
			CiTestObj.clean_repository = False
252
		else:
253
			CiTestObj.clean_repository = True
Boris Djalal's avatar
Boris Djalal committed
254

255
	elif action == 'Initialize_OAI_UE':
256
		CiTestObj.Initialize_OAI_UE_args = test.findtext('Initialize_OAI_UE_args')
257 258 259 260 261
		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
262 263 264 265
			
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
266
			CiTestObj.air_interface = 'lte-uesoftmodem'
hardy's avatar
hardy committed
267
		elif (air_interface.lower() in ['nr','lte']):
268
			CiTestObj.air_interface = air_interface.lower() +'-uesoftmodem'
hardy's avatar
hardy committed
269
		else :
270 271
			#CiTestObj.air_interface = 'ocp-enb'
			logging.error('OCP UE -- NOT SUPPORTED')
Boris Djalal's avatar
Boris Djalal committed
272

273
	elif action == 'Terminate_OAI_UE':
274 275
		UE_instance=test.findtext('UE_instance')
		if (UE_instance is None):
276
			CiTestObj.UE_instance = '0'
277 278
		else:
			CiTestObj.UE_instance = int(UE_instance)
279 280 281 282 283 284 285 286 287 288
		
		#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
289

290
	elif (action == 'Ping') or (action == 'Ping_CatM_module'):
291 292
		CiTestObj.ping_args = test.findtext('ping_args')
		CiTestObj.ping_packetloss_threshold = test.findtext('ping_packetloss_threshold')
293 294 295 296 297
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
298 299 300 301 302
		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
303

304
	elif action == 'Iperf':
305
		CiTestObj.iperf_args = test.findtext('iperf_args')
306 307 308 309 310 311
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
		CiTestObj.iperf_direction = test.findtext('direction')#used for modules only	
312
		CiTestObj.iperf_packetloss_threshold = test.findtext('iperf_packetloss_threshold')
hardy's avatar
hardy committed
313 314 315 316 317 318 319
		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


320 321 322
		CiTestObj.iperf_profile = test.findtext('iperf_profile')
		if (CiTestObj.iperf_profile is None):
			CiTestObj.iperf_profile = 'balanced'
323
		else:
324 325 326
			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'
327 328 329
		CiTestObj.iperf_options = test.findtext('iperf_options')
		if (CiTestObj.iperf_options is None):
			CiTestObj.iperf_options = 'check'
330
		else:
331 332 333
			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'
334

335
	elif action == 'IdleSleep':
336 337
		string_field = test.findtext('idle_sleep_time_in_sec')
		if (string_field is None):
338
			CiTestObj.idle_sleep_time = 5
339
		else:
340
			CiTestObj.idle_sleep_time = int(string_field)
341

342
	elif action == 'Perform_X2_Handover':
343 344
		string_field = test.findtext('x2_ho_options')
		if (string_field is None):
345
			CiTestObj.x2_ho_options = 'network'
346 347 348
		else:
			if string_field != 'network':
				logging.error('ERROR: test-case has wrong option ' + string_field)
349
				CiTestObj.x2_ho_options = 'network'
350
			else:
351
				CiTestObj.x2_ho_options = string_field
352

353
	elif action == 'Build_PhySim':
354
		ldpc.buildargs  = test.findtext('physim_build_args')
Remi Hardy's avatar
Remi Hardy committed
355 356 357 358 359 360 361 362
		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
363

364 365 366 367 368
	elif action == 'Initialize_MME':
		string_field = test.findtext('option')
		if (string_field is not None):
			EPC.mmeConfFile = string_field

369 370 371 372 373
	elif action == 'Deploy_EPC':
		string_field = test.findtext('parameters')
		if (string_field is not None):
			EPC.yamlPath = string_field

374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
	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

389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
	elif action == 'DeployGenObject' or action == 'UndeployGenObject':
		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)

	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
424

425 426 427 428 429 430 431 432 433 434 435
	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

436
	else: # ie action == 'Run_PhySim':
437
		ldpc.runargs = test.findtext('physim_run_args')
438
		
439

440 441 442 443 444 445 446 447 448 449 450 451
#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)

452 453 454 455 456





457
#-----------------------------------------------------------
458
# MAIN PART
459
#-----------------------------------------------------------
460 461 462

#loading xml action list from yaml
import yaml
463
xml_class_list_file='xml_class_list.yml'
hardy's avatar
hardy committed
464
if (os.path.isfile(xml_class_list_file)):
465 466 467
	yaml_file=xml_class_list_file
elif (os.path.isfile('ci-scripts/'+xml_class_list_file)):
	yaml_file='ci-scripts/'+xml_class_list_file
468 469 470
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
471

472 473 474 475 476
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
477

hardy's avatar
hardy committed
478 479 480 481 482 483 484 485 486 487

#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")
488
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
hardy's avatar
hardy committed
489
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
490 491


492

493
mode = ''
494

495
CiTestObj = cls_oaicitest.OaiCiTest()
496 497 498 499 500
 
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement()
RAN = ran.RANManagement()
HTML = html.HTMLManagement()
501
CONTAINERS = cls_containerize.Containerize()
502
SCA = cls_static_code_analysis.StaticCodeAnalysis()
503
PHYSIM = cls_physim1.PhySim()
504

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

507

508
#-----------------------------------------------------------
509
# Parsing Command Line Arguments
510 511
#-----------------------------------------------------------

512
import args_parse
Mohammed Ismail's avatar
Mohammed Ismail committed
513
py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM)
514

515

516

517
#-----------------------------------------------------------
518
# TEMPORARY params management (UNUSED)
519 520 521
#-----------------------------------------------------------
#temporary solution for testing:
if py_param_file_present == True:
522 523
	AssignParams(py_params)

524

525 526 527
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
528 529 530
#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)
531 532


533
#-----------------------------------------------------------
534
# mode amd XML class (action) analysis
535
#-----------------------------------------------------------
536
cwd = os.getcwd()
537

538
if re.match('^TerminateeNB$', mode, re.IGNORECASE):
539
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '':
540
		HELP.GenericHelp(CONST.Version)
541
		sys.exit('Insufficient Parameter')
542 543
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
Raphael Defosseux's avatar
Raphael Defosseux committed
544
	RAN.eNB_instance=0
545
	RAN.eNB_serverId[0]='0'
546
	RAN.eNBSourceCodePath='/tmp/'
547
	RAN.TerminateeNB(HTML, EPC)
548
elif re.match('^TerminateUE$', mode, re.IGNORECASE):
549
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
550
		HELP.GenericHelp(CONST.Version)
551 552
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
553
	CiTestObj.TerminateUE(HTML,COTS_UE,InfraUE,CiTestObj.ue_trace)
Boris Djalal's avatar
Boris Djalal committed
554
elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE):
555
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '':
556
		HELP.GenericHelp(CONST.Version)
Boris Djalal's avatar
Boris Djalal committed
557 558
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
559
	CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
560
elif re.match('^TerminateHSS$', mode, re.IGNORECASE):
561
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
562
		HELP.GenericHelp(CONST.Version)
563
		sys.exit('Insufficient Parameter')
564
	EPC.TerminateHSS(HTML)
565
elif re.match('^TerminateMME$', mode, re.IGNORECASE):
566
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
567
		HELP.GenericHelp(CONST.Version)
568
		sys.exit('Insufficient Parameter')
569
	EPC.TerminateMME(HTML)
570
elif re.match('^TerminateSPGW$', mode, re.IGNORECASE):
571
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath== '':
572
		HELP.GenericHelp(CONST.Version)
573
		sys.exit('Insufficient Parameter')
574
	EPC.TerminateSPGW(HTML)
575
elif re.match('^LogCollectBuild$', mode, re.IGNORECASE):
576
	if (RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '') and (CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == ''):
577
		HELP.GenericHelp(CONST.Version)
578
		sys.exit('Insufficient Parameter')
579 580
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
581
	CiTestObj.LogCollectBuild(RAN)
582
elif re.match('^LogCollecteNB$', mode, re.IGNORECASE):
583
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '':
584
		HELP.GenericHelp(CONST.Version)
585
		sys.exit('Insufficient Parameter')
586
	if RAN.eNBIPAddress == 'none':
587 588 589
		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)
590
		sys.exit(0)
591
	RAN.LogCollecteNB()
592
elif re.match('^LogCollectHSS$', mode, re.IGNORECASE):
593
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
594
		HELP.GenericHelp(CONST.Version)
595
		sys.exit('Insufficient Parameter')
596
	EPC.LogCollectHSS()
597
elif re.match('^LogCollectMME$', mode, re.IGNORECASE):
598
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
599
		HELP.GenericHelp(CONST.Version)
600
		sys.exit('Insufficient Parameter')
601
	EPC.LogCollectMME()
602
elif re.match('^LogCollectSPGW$', mode, re.IGNORECASE):
603
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
604
		HELP.GenericHelp(CONST.Version)
605
		sys.exit('Insufficient Parameter')
606
	EPC.LogCollectSPGW()
607
elif re.match('^LogCollectPing$', mode, re.IGNORECASE):
608
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
609
		HELP.GenericHelp(CONST.Version)
610
		sys.exit('Insufficient Parameter')
611
	CiTestObj.LogCollectPing(EPC)
612
elif re.match('^LogCollectIperf$', mode, re.IGNORECASE):
613
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
614
		HELP.GenericHelp(CONST.Version)
615
		sys.exit('Insufficient Parameter')
616
	CiTestObj.LogCollectIperf(EPC)
Boris Djalal's avatar
Boris Djalal committed
617
elif re.match('^LogCollectOAIUE$', mode, re.IGNORECASE):
618
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
619
		HELP.GenericHelp(CONST.Version)
620
		sys.exit('Insufficient Parameter')
621
	CiTestObj.LogCollectOAIUE()
622
elif re.match('^InitiateHtml$', mode, re.IGNORECASE):
623
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
624
		HELP.GenericHelp(CONST.Version)
625 626
		sys.exit('Insufficient Parameter')
	count = 0
627
	foundCount = 0
628
	while (count < HTML.nbTestXMLfiles):
629
		#xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[count]
630
		xml_test_file = sys.path[0] + "/" + CiTestObj.testXMLfiles[count]
631
		if (os.path.isfile(xml_test_file)):
632 633 634 635
			try:
				xmlTree = ET.parse(xml_test_file)
			except:
				print("Error while parsing file: " + xml_test_file)
636
			xmlRoot = xmlTree.getroot()
637 638 639
			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'))
640
			foundCount += 1
641
		count += 1
642 643
	if foundCount != HTML.nbTestXMLfiles:
		HTML.nbTestXMLfiles=foundCount
644
	
645
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
646 647 648 649
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
		HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
650 651
		HTML.htmlNb_Smartphones=len(CiTestObj.UEDevices)
		HTML.htmlNb_CATM_Modules=len(CiTestObj.CatMDevices)
652
	HTML.CreateHtmlHeader(CiTestObj.ADBIPAddress)
653
elif re.match('^FinalizeHtml$', mode, re.IGNORECASE):
654 655 656 657
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
	logging.debug('\u001B[1m  Creating HTML footer \u001B[0m')
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')

658 659
	CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
	CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
660
	HTML.CreateHtmlFooter(CiTestObj.finalStatus)
661
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
662
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
663
	logging.debug('\u001B[1m  Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
664
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
665
	if re.match('^TesteNB$', mode, re.IGNORECASE):
666
		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 == '':
667
			HELP.GenericHelp(CONST.Version)
668 669
			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)
670 671 672 673
			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)
674 675
			sys.exit('Insufficient Parameter')

676 677 678
		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")
679
	else:
680 681
		if CiTestObj.UEIPAddress == '' or CiTestObj.ranRepository == '' or CiTestObj.ranBranch == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
			HELP.GenericHelp(CONST.Version)
682
			sys.exit('UE: Insufficient Parameter')
683

684
	#read test_case_list.xml file
685
	# if no parameters for XML file, use default value
686
	if (HTML.nbTestXMLfiles != 1):
687
		xml_test_file = cwd + "/test_case_list.xml"
688
	else:
689
		xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[0]
690 691 692 693 694 695

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

	exclusion_tests=xmlRoot.findtext('TestCaseExclusionList',default='')
	requested_tests=xmlRoot.findtext('TestCaseRequestedList',default='')
696 697 698
	if (HTML.nbTestXMLfiles == 1):
		HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-0'))
		HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-0'))
699
		repeatCount = xmlRoot.findtext('repeatCount',default='1')
700
		testStability = xmlRoot.findtext('TestUnstable',default='False')
701
		CiTestObj.repeatCounts.append(int(repeatCount))
702 703 704 705 706 707
		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))
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
	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)
733
	if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
734
		CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
735
		EPC.SetMmeIPAddress()
736
		EPC.SetAmfIPAddress()
737 738 739 740 741 742 743

	#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:
744
			#logging.debug('INFO: test will be run: ' + test)
745
			todo_tests.append(test)
746

747
	signal.signal(signal.SIGUSR1, receive_signal)
748

749
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
750 751 752
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
753 754
	elif (CiTestObj.ADBIPAddress == 'modules'):
		CiTestObj.UEDevices.append('COTS-Module')
755 756 757 758
	else:
		CiTestObj.UEDevices.append('OAI-UE')
	HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
	HTML.CreateHtmlTabHeader()
759

760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
	# On CI bench w/ containers, we need to validate if IP routes are set
	if EPC.IPAddress == '192.168.18.210':
		CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
	if CONTAINERS.eNBIPAddress == '192.168.18.194':
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
	if CONTAINERS.eNB1IPAddress == '192.168.18.194':
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
	if CONTAINERS.eNBIPAddress == '192.168.18.193':
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
	if CONTAINERS.eNB1IPAddress == '192.168.18.193':
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
	if CONTAINERS.eNBIPAddress == '192.168.18.209':
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
	if CONTAINERS.eNB1IPAddress == '192.168.18.209':
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)

776
	CiTestObj.FailReportCnt = 0
777
	RAN.prematureExit=True
778
	HTML.startTime=int(round(time.time() * 1000))
779 780
	while CiTestObj.FailReportCnt < CiTestObj.repeatCounts[0] and RAN.prematureExit:
		RAN.prematureExit=False
781
		# At every iteratin of the retry loop, a separator will be added
782 783
		# pass CiTestObj.FailReportCnt as parameter of HTML.CreateHtmlRetrySeparator
		HTML.CreateHtmlRetrySeparator(CiTestObj.FailReportCnt)
784
		for test_case_id in todo_tests:
785
			if RAN.prematureExit:
786
				break
787
			for test in all_tests:
788
				if RAN.prematureExit:
789
					break
790 791 792
				id = test.get('id')
				if test_case_id != id:
					continue
793
				CiTestObj.testCase_id = id
794 795
				HTML.testCase_id=CiTestObj.testCase_id
				EPC.testCase_id=CiTestObj.testCase_id
796
				CiTestObj.desc = test.findtext('desc')
797
				HTML.desc=CiTestObj.desc
798
				action = test.findtext('class')
799
				if (CheckClassValidity(xml_class_list, action, id) == False):
800
					continue
801
				CiTestObj.ShowTestID()
802 803
				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':
804
					if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
805 806
						#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 
807 808 809 810 811
						# Now we stop properly the test-suite --> clean reporting
						status = CiTestObj.GetAllUEDevices(terminate_ue_flag)
						if not status:
							RAN.prematureExit = True
							break
812
				if action == 'Build_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
813
					RAN.BuildeNB(HTML)
814
				elif action == 'WaitEndBuild_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
815
					RAN.WaitBuildeNBisFinished(HTML)
816
				elif action == 'Initialize_eNB':
817 818
					check_eNB = False
					check_OAI_UE = False
819
					RAN.pStatus=CiTestObj.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
Raphael Defosseux's avatar
Raphael Defosseux committed
820
					RAN.InitializeeNB(HTML, EPC)
821
					if RAN.prematureExit:
hardy's avatar
hardy committed
822
						CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
823
				elif action == 'Terminate_eNB':
Raphael Defosseux's avatar
Raphael Defosseux committed
824
					RAN.TerminateeNB(HTML, EPC)
825
				elif action == 'Initialize_UE':
826
					CiTestObj.InitializeUE(HTML,RAN, EPC, COTS_UE, InfraUE, CiTestObj.ue_trace, CONTAINERS)
827
				elif action == 'Terminate_UE':
Remi Hardy's avatar
Remi Hardy committed
828
					CiTestObj.TerminateUE(HTML,COTS_UE, InfraUE, CiTestObj.ue_trace)
829
				elif action == 'Attach_UE':
830
					CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
831
				elif action == 'Detach_UE':
832
					CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
833
				elif action == 'DataDisable_UE':
834
					CiTestObj.DataDisableUE(HTML)
835
				elif action == 'DataEnable_UE':
836
					CiTestObj.DataEnableUE(HTML)
837
				elif action == 'CheckStatusUE':
838
					CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
839
				elif action == 'Build_OAI_UE':
840
					CiTestObj.BuildOAIUE(HTML)
841
				elif action == 'Initialize_OAI_UE':
842
					CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS)
843
				elif action == 'Terminate_OAI_UE':
844
					CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
845
				elif action == 'Initialize_CatM_module':
846
					CiTestObj.InitializeCatM(HTML)
847
				elif action == 'Terminate_CatM_module':
848
					CiTestObj.TerminateCatM(HTML)
849
				elif action == 'Attach_CatM_module':
850
					CiTestObj.AttachCatM(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
851
				elif action == 'Detach_CatM_module':
852
					CiTestObj.TerminateCatM(HTML)
853
				elif action == 'Ping_CatM_module':
854
					CiTestObj.PingCatM(HTML,RAN,EPC,COTS_UE,EPC,InfraUE,CONTAINERS)
855
				elif action == 'Ping':
856
					CiTestObj.Ping(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS)
857
				elif action == 'Iperf':
858
					CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS)
859
				elif action == 'Reboot_UE':
860
					CiTestObj.RebootUE(HTML,RAN,EPC)
861
				elif action == 'Initialize_HSS':
Raphael Defosseux's avatar
Raphael Defosseux committed
862
					EPC.InitializeHSS(HTML)
863
				elif action == 'Terminate_HSS':
Raphael Defosseux's avatar
Raphael Defosseux committed
864
					EPC.TerminateHSS(HTML)
865
				elif action == 'Initialize_MME':
Raphael Defosseux's avatar
Raphael Defosseux committed
866
					EPC.InitializeMME(HTML)
867
				elif action == 'Terminate_MME':
Raphael Defosseux's avatar
Raphael Defosseux committed
868
					EPC.TerminateMME(HTML)
869
				elif action == 'Initialize_SPGW':
Raphael Defosseux's avatar
Raphael Defosseux committed
870
					EPC.InitializeSPGW(HTML)
871
				elif action == 'Terminate_SPGW':
Raphael Defosseux's avatar
Raphael Defosseux committed
872
					EPC.TerminateSPGW(HTML)
873 874 875 876
				elif action == 'Initialize_5GCN':
					EPC.Initialize5GCN(HTML)
				elif action == 'Terminate_5GCN':
					EPC.Terminate5GCN(HTML)
877
				elif action == 'Deploy_EPC':
Raphael Defosseux's avatar
Raphael Defosseux committed
878
					EPC.DeployEpc(HTML)
879
				elif action == 'Undeploy_EPC':
Raphael Defosseux's avatar
Raphael Defosseux committed
880
					EPC.UndeployEpc(HTML)
881
				elif action == 'Initialize_FlexranCtrl':
882
					CiTestObj.InitializeFlexranCtrl(HTML,RAN,EPC)
883
				elif action == 'Terminate_FlexranCtrl':
884
					CiTestObj.TerminateFlexranCtrl(HTML,RAN,EPC)
885
				elif action == 'IdleSleep':
886
					CiTestObj.IdleSleep(HTML)
887
				elif action == 'Perform_X2_Handover':
888
					CiTestObj.Perform_X2_Handover(HTML,RAN,EPC)
889 890
				elif action == 'Build_PhySim':
					HTML=ldpc.Build_PhySim(HTML,CONST)
891
					if ldpc.exitStatus==1:
892
						RAN.prematureExit = True
893
				elif action == 'Run_PhySim':
Remi Hardy's avatar
Remi Hardy committed
894
					HTML=ldpc.Run_PhySim(HTML,CONST,id)
895
				elif action == 'Build_Image':
Raphael Defosseux's avatar
Raphael Defosseux committed
896
					CONTAINERS.BuildImage(HTML)
897 898
				elif action == 'Copy_Image_to_Test':
					CONTAINERS.Copy_Image_to_Test_Server(HTML)
899
				elif action == 'Deploy_Object':
Raphael Defosseux's avatar
Raphael Defosseux committed
900
					CONTAINERS.DeployObject(HTML, EPC)
901
				elif action == 'Undeploy_Object':
Raphael Defosseux's avatar
Raphael Defosseux committed
902
					CONTAINERS.UndeployObject(HTML, RAN)
903 904
				elif action == 'Cppcheck_Analysis':
					SCA.CppCheckAnalysis(HTML)
905
				elif action == 'Deploy_Run_PhySim':
906
					PHYSIM.Deploy_PhySim(HTML, RAN)
907 908 909 910 911
				elif action == 'DeployGenObject':
					CONTAINERS.DeployGenObject(HTML)
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'UndeployGenObject':
912
					CONTAINERS.UndeployGenObject(HTML, RAN)
913 914 915 916 917 918 919 920 921 922
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'PingFromContainer':
					CONTAINERS.PingFromContainer(HTML)
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
				elif action == 'IperfFromContainer':
					CONTAINERS.IperfFromContainer(HTML)
					if CONTAINERS.exitStatus==1:
						RAN.prematureExit = True
923
				else:
924
					sys.exit('Invalid class (action) from xml')
925
				if RAN.prematureExit:
926 927 928 929
					if CiTestObj.testCase_id == CiTestObj.testMinStableId:
						logging.debug('Scenario has reached minimal stability point')
						CiTestObj.testStabilityPointReached = True
						HTML.testStabilityPointReached = True
930
		CiTestObj.FailReportCnt += 1
931
	if CiTestObj.FailReportCnt == CiTestObj.repeatCounts[0] and RAN.prematureExit:
932
		logging.debug('Scenario failed ' + str(CiTestObj.FailReportCnt) + ' time(s)')
933
		HTML.CreateHtmlTabFooter(False)
934 935 936 937
		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')
938
	else:
939
		logging.info('Scenario passed after ' + str(CiTestObj.FailReportCnt) + ' time(s)')
940
		HTML.CreateHtmlTabFooter(True)
941 942
elif re.match('^LoadParams$', mode, re.IGNORECASE):
	pass
943
else:
944
	HELP.GenericHelp(CONST.Version)
945
	sys.exit('Invalid mode')
946
sys.exit(0)