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

hardy's avatar
hardy committed
202 203 204
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
205
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
206
		elif (air_interface.lower() in ['nr','lte']):
207
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
208
		else :
209
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
210

211 212
	elif action == 'Initialize_UE':
		ue_id = test.findtext('id')
Remi Hardy's avatar
Remi Hardy committed
213
		CiTestObj.ue_trace=test.findtext('UE_Trace')#temporary variable, to be passed to Module_UE in Initialize_UE call
214 215 216 217 218
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id

219 220 221 222 223 224
	elif action == 'Detach_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
225

226
	elif action == 'Attach_UE':
227 228 229 230 231
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
232 233
		nbMaxUEtoAttach = test.findtext('nbMaxUEtoAttach')
		if (nbMaxUEtoAttach is None):
234
			CiTestObj.nbMaxUEtoAttach = -1
235
		else:
236
			CiTestObj.nbMaxUEtoAttach = int(nbMaxUEtoAttach)
237

238 239 240 241 242 243 244 245
	elif action == 'Terminate_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id


246
	elif action == 'CheckStatusUE':
247 248
		expectedNBUE = test.findtext('expectedNbOfConnectedUEs')
		if (expectedNBUE is None):
249
			CiTestObj.expectedNbOfConnectedUEs = -1
250
		else:
251
			CiTestObj.expectedNbOfConnectedUEs = int(expectedNBUE)
252

253
	elif action == 'Build_OAI_UE':
254
		CiTestObj.Build_OAI_UE_args = test.findtext('Build_OAI_UE_args')
255 256 257
		CiTestObj.clean_repository = test.findtext('clean_repository')
		if (CiTestObj.clean_repository == 'false'):
			CiTestObj.clean_repository = False
258
		else:
259
			CiTestObj.clean_repository = True
Boris Djalal's avatar
Boris Djalal committed
260

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

279
	elif action == 'Terminate_OAI_UE':
280 281
		UE_instance=test.findtext('UE_instance')
		if (UE_instance is None):
282
			CiTestObj.UE_instance = '0'
283 284
		else:
			CiTestObj.UE_instance = int(UE_instance)
285 286 287 288 289 290 291 292 293 294
		
		#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
295

296
	elif (action == 'Ping') or (action == 'Ping_CatM_module'):
297 298
		CiTestObj.ping_args = test.findtext('ping_args')
		CiTestObj.ping_packetloss_threshold = test.findtext('ping_packetloss_threshold')
299 300 301 302 303
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
304 305 306 307 308
		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
309

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


326 327 328
		CiTestObj.iperf_profile = test.findtext('iperf_profile')
		if (CiTestObj.iperf_profile is None):
			CiTestObj.iperf_profile = 'balanced'
329
		else:
330 331 332
			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'
333 334 335
		CiTestObj.iperf_options = test.findtext('iperf_options')
		if (CiTestObj.iperf_options is None):
			CiTestObj.iperf_options = 'check'
336
		else:
337 338 339
			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'
340

341
	elif action == 'IdleSleep':
342 343
		string_field = test.findtext('idle_sleep_time_in_sec')
		if (string_field is None):
344
			CiTestObj.idle_sleep_time = 5
345
		else:
346
			CiTestObj.idle_sleep_time = int(string_field)
347

348
	elif action == 'Perform_X2_Handover':
349 350
		string_field = test.findtext('x2_ho_options')
		if (string_field is None):
351
			CiTestObj.x2_ho_options = 'network'
352 353 354
		else:
			if string_field != 'network':
				logging.error('ERROR: test-case has wrong option ' + string_field)
355
				CiTestObj.x2_ho_options = 'network'
356
			else:
357
				CiTestObj.x2_ho_options = string_field
358

359
	elif action == 'Build_PhySim':
360
		ldpc.buildargs  = test.findtext('physim_build_args')
Remi Hardy's avatar
Remi Hardy committed
361 362 363 364 365 366 367 368
		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
369

370 371 372 373 374
	elif action == 'Initialize_MME':
		string_field = test.findtext('option')
		if (string_field is not None):
			EPC.mmeConfFile = string_field

375 376 377 378 379
	elif action == 'Deploy_EPC':
		string_field = test.findtext('parameters')
		if (string_field is not None):
			EPC.yamlPath = string_field

hardy's avatar
hardy committed
380 381 382 383 384 385 386 387 388 389
	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	

390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
	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

405
	elif action == 'DeployGenObject' or action == 'UndeployGenObject' or action == 'StatsFromGenObject':
406 407 408 409 410 411 412 413 414
		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)
415 416 417 418 419 420
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
			CONTAINERS.ran_checkers['d_retx_th']= string_field
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
			CONTAINERS.ran_checkers['u_retx_th']= string_field
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445

	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
446

447 448 449 450 451 452 453 454 455 456 457
	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
458
	elif action == 'Run_LDPCTest' or action == 'Run_NRulsimTest':
459
		ldpc.runargs = test.findtext('physim_run_args')
460

461 462 463
	elif action == 'LicenceAndFormattingCheck':
		pass

464 465 466
	elif action == 'Cppcheck_Analysis':
		pass

467
	else:
468
		logging.error(f"unknown action {action}")
469

470

471 472 473 474 475 476 477 478 479 480 481 482
#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)

483 484 485 486 487





488
#-----------------------------------------------------------
489
# MAIN PART
490
#-----------------------------------------------------------
491 492 493

#loading xml action list from yaml
import yaml
494
xml_class_list_file='xml_class_list.yml'
hardy's avatar
hardy committed
495
if (os.path.isfile(xml_class_list_file)):
496 497 498
	yaml_file=xml_class_list_file
elif (os.path.isfile('ci-scripts/'+xml_class_list_file)):
	yaml_file='ci-scripts/'+xml_class_list_file
499 500 501
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
502

503 504 505 506 507
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
508

hardy's avatar
hardy committed
509 510 511 512 513 514 515 516 517 518

#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")
519
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
hardy's avatar
hardy committed
520
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
521 522


523

524
mode = ''
525

526
CiTestObj = cls_oaicitest.OaiCiTest()
527 528 529 530
 
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement()
RAN = ran.RANManagement()
531
HTML = cls_oai_html.HTMLManagement()
532
CONTAINERS = cls_containerize.Containerize()
533
SCA = cls_static_code_analysis.StaticCodeAnalysis()
534
PHYSIM = cls_physim1.PhySim()
535
CLUSTER = cls_cluster.Cluster()
536

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

539

540
#-----------------------------------------------------------
541
# Parsing Command Line Arguments
542 543
#-----------------------------------------------------------

544
import args_parse
545
py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER)
546

547

548

549
#-----------------------------------------------------------
550
# TEMPORARY params management (UNUSED)
551 552 553
#-----------------------------------------------------------
#temporary solution for testing:
if py_param_file_present == True:
554 555
	AssignParams(py_params)

556

557 558 559
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
560 561 562
#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)
563 564


565
#-----------------------------------------------------------
566
# mode amd XML class (action) analysis
567
#-----------------------------------------------------------
568
cwd = os.getcwd()
569

570
if re.match('^TerminateeNB$', mode, re.IGNORECASE):
571
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '':
572
		HELP.GenericHelp(CONST.Version)
573
		sys.exit('Insufficient Parameter')
574 575
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
Raphael Defosseux's avatar
Raphael Defosseux committed
576
	RAN.eNB_instance=0
577
	RAN.eNB_serverId[0]='0'
578
	RAN.eNBSourceCodePath='/tmp/'
579
	RAN.TerminateeNB(HTML, EPC)
580
elif re.match('^TerminateUE$', mode, re.IGNORECASE):
581
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
582
		HELP.GenericHelp(CONST.Version)
583 584
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
585
	CiTestObj.TerminateUE(HTML,COTS_UE,InfraUE,CiTestObj.ue_trace)
Boris Djalal's avatar
Boris Djalal committed
586
elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE):
587
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '':
588
		HELP.GenericHelp(CONST.Version)
Boris Djalal's avatar
Boris Djalal committed
589 590
		sys.exit('Insufficient Parameter')
	signal.signal(signal.SIGUSR1, receive_signal)
591
	CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
592
elif re.match('^TerminateHSS$', 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.TerminateHSS(HTML)
597
elif re.match('^TerminateMME$', 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.TerminateMME(HTML)
602
elif re.match('^TerminateSPGW$', 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.TerminateSPGW(HTML)
607
elif re.match('^LogCollectBuild$', mode, re.IGNORECASE):
608
	if (RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '') and (CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == ''):
609
		HELP.GenericHelp(CONST.Version)
610
		sys.exit('Insufficient Parameter')
611 612
	if RAN.eNBIPAddress == 'none':
		sys.exit(0)
613
	CiTestObj.LogCollectBuild(RAN)
614
elif re.match('^LogCollecteNB$', mode, re.IGNORECASE):
615
	if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '':
616
		HELP.GenericHelp(CONST.Version)
617
		sys.exit('Insufficient Parameter')
618
	if RAN.eNBIPAddress == 'none':
619 620 621
		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)
622
		sys.exit(0)
623
	RAN.LogCollecteNB()
624
elif re.match('^LogCollectHSS$', 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.LogCollectHSS()
629
elif re.match('^LogCollectMME$', 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.LogCollectMME()
634
elif re.match('^LogCollectSPGW$', mode, re.IGNORECASE):
635
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
636
		HELP.GenericHelp(CONST.Version)
637
		sys.exit('Insufficient Parameter')
638
	EPC.LogCollectSPGW()
639
elif re.match('^LogCollectPing$', mode, re.IGNORECASE):
640
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
641
		HELP.GenericHelp(CONST.Version)
642
		sys.exit('Insufficient Parameter')
643
	CiTestObj.LogCollectPing(EPC)
644
elif re.match('^LogCollectIperf$', mode, re.IGNORECASE):
645
	if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
646
		HELP.GenericHelp(CONST.Version)
647
		sys.exit('Insufficient Parameter')
648
	CiTestObj.LogCollectIperf(EPC)
Boris Djalal's avatar
Boris Djalal committed
649
elif re.match('^LogCollectOAIUE$', mode, re.IGNORECASE):
650
	if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
651
		HELP.GenericHelp(CONST.Version)
652
		sys.exit('Insufficient Parameter')
653
	CiTestObj.LogCollectOAIUE()
654
elif re.match('^InitiateHtml$', mode, re.IGNORECASE):
655
	if (CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == ''):
656
		HELP.GenericHelp(CONST.Version)
657 658
		sys.exit('Insufficient Parameter')
	count = 0
659
	foundCount = 0
660
	while (count < HTML.nbTestXMLfiles):
661
		#xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[count]
662
		xml_test_file = sys.path[0] + "/" + CiTestObj.testXMLfiles[count]
663
		if (os.path.isfile(xml_test_file)):
664 665 666 667
			try:
				xmlTree = ET.parse(xml_test_file)
			except:
				print("Error while parsing file: " + xml_test_file)
668
			xmlRoot = xmlTree.getroot()
669 670 671
			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'))
672
			foundCount += 1
673
		count += 1
674 675
	if foundCount != HTML.nbTestXMLfiles:
		HTML.nbTestXMLfiles=foundCount
676
	
677
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
678 679 680 681
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
		HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
682 683
		HTML.htmlNb_Smartphones=len(CiTestObj.UEDevices)
		HTML.htmlNb_CATM_Modules=len(CiTestObj.CatMDevices)
684
	HTML.CreateHtmlHeader(CiTestObj.ADBIPAddress)
685
elif re.match('^FinalizeHtml$', mode, re.IGNORECASE):
686 687 688 689
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
	logging.debug('\u001B[1m  Creating HTML footer \u001B[0m')
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')

690 691
	CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
	CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
692
	HTML.CreateHtmlFooter(CiTestObj.finalStatus)
693
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
694
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
695
	logging.debug('\u001B[1m  Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
696
	logging.debug('\u001B[1m----------------------------------------\u001B[0m')
697
	if re.match('^TesteNB$', mode, re.IGNORECASE):
698
		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 == '':
699
			HELP.GenericHelp(CONST.Version)
700 701
			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)
702 703 704 705
			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)
706 707
			sys.exit('Insufficient Parameter')

708 709 710
		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")
711
	else:
712 713
		if CiTestObj.UEIPAddress == '' or CiTestObj.ranRepository == '' or CiTestObj.ranBranch == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
			HELP.GenericHelp(CONST.Version)
714
			sys.exit('UE: Insufficient Parameter')
715

716
	#read test_case_list.xml file
717
	# if no parameters for XML file, use default value
718
	if (HTML.nbTestXMLfiles != 1):
719
		xml_test_file = cwd + "/test_case_list.xml"
720
	else:
721
		xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[0]
722 723 724 725 726 727

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

	exclusion_tests=xmlRoot.findtext('TestCaseExclusionList',default='')
	requested_tests=xmlRoot.findtext('TestCaseRequestedList',default='')
728 729 730
	if (HTML.nbTestXMLfiles == 1):
		HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-0'))
		HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-0'))
731
		repeatCount = xmlRoot.findtext('repeatCount',default='1')
732
		testStability = xmlRoot.findtext('TestUnstable',default='False')
733
		CiTestObj.repeatCounts.append(int(repeatCount))
734 735 736 737 738 739
		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))
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
	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)
765
	if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
766
		CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
767
		EPC.SetMmeIPAddress()
768
		EPC.SetAmfIPAddress()
769 770 771 772 773 774 775

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

779
	signal.signal(signal.SIGUSR1, receive_signal)
780

781
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
782 783 784
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
785 786
	elif (CiTestObj.ADBIPAddress == 'modules'):
		CiTestObj.UEDevices.append('COTS-Module')
787 788 789 790
	else:
		CiTestObj.UEDevices.append('OAI-UE')
	HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
	HTML.CreateHtmlTabHeader()
791

792
	# On CI bench w/ containers, we need to validate if IP routes are set
793
	if EPC.IPAddress == '172.21.16.136':
794
		CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
795
	if CONTAINERS.eNBIPAddress == '172.21.16.127':
796
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
797
	if CONTAINERS.eNB1IPAddress == '172.21.16.127':
798
		CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
799
	if CONTAINERS.eNBIPAddress == '172.21.16.128':
800
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
801
	if CONTAINERS.eNB1IPAddress == '172.21.16.128':
802
		CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
803
	if CONTAINERS.eNBIPAddress == '172.21.16.137':
804
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
805
	if CONTAINERS.eNB1IPAddress == '172.21.16.137':
806 807
		CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)

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