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

76

77

78 79 80 81 82 83 84

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



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

93 94 95

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

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



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

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

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

190 191 192
		cmd_prefix = test.findtext('cmd_prefix')
		if cmd_prefix is not None: RAN.cmd_prefix = cmd_prefix

193
	elif action == 'Terminate_eNB':
194
		eNB_instance=test.findtext('eNB_instance')
195
		if (eNB_instance is None):
196 197 198
			RAN.eNB_instance=0
		else:
			RAN.eNB_instance=int(eNB_instance)
199 200 201 202 203 204
		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

205 206 207 208 209 210 211 212
		#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
213 214 215
		#local variable air_interface
		air_interface = test.findtext('air_interface')		
		if (air_interface is None) or (air_interface.lower() not in ['nr','lte','ocp']):
216
			RAN.air_interface[RAN.eNB_instance] = 'lte-softmodem'
hardy's avatar
hardy committed
217
		elif (air_interface.lower() in ['nr','lte']):
218
			RAN.air_interface[RAN.eNB_instance] = air_interface.lower() +'-softmodem'
hardy's avatar
hardy committed
219
		else :
220
			RAN.air_interface[RAN.eNB_instance] = 'ocp-enb'
221

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

230 231 232 233 234 235
	elif action == 'Detach_UE':
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
236

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

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


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

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

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

290
	elif action == 'Terminate_OAI_UE':
291 292
		UE_instance=test.findtext('UE_instance')
		if (UE_instance is None):
293
			CiTestObj.UE_instance = '0'
294 295
		else:
			CiTestObj.UE_instance = int(UE_instance)
296 297 298 299 300 301 302 303 304 305
		
		#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
306

307
	elif (action == 'Ping') or (action == 'Ping_CatM_module'):
308 309
		CiTestObj.ping_args = test.findtext('ping_args')
		CiTestObj.ping_packetloss_threshold = test.findtext('ping_packetloss_threshold')
310 311 312 313 314
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
315 316 317 318 319
		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
320

321
	elif action == 'Iperf':
322
		CiTestObj.iperf_args = test.findtext('iperf_args')
323 324 325 326 327
		ue_id = test.findtext('id')
		if (ue_id is None):
			CiTestObj.ue_id = ""
		else:
			CiTestObj.ue_id = ue_id
328
		CiTestObj.iperf_direction = test.findtext('direction')#used for modules only
329
		CiTestObj.iperf_packetloss_threshold = test.findtext('iperf_packetloss_threshold')
hardy's avatar
hardy committed
330 331 332 333 334 335 336
		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


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

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

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

370
	elif action == 'Build_PhySim':
371
		ldpc.buildargs  = test.findtext('physim_build_args')
Remi Hardy's avatar
Remi Hardy committed
372 373 374 375 376 377 378 379
		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
380

381 382 383 384 385
	elif action == 'Initialize_MME':
		string_field = test.findtext('option')
		if (string_field is not None):
			EPC.mmeConfFile = string_field

386 387 388 389 390
	elif action == 'Initialize_HSS' or action == 'Initialize_SPGW':
		pass
	elif action == 'Terminate_HSS' or action == 'Terminate_MME' or action == 'Terminate_SPGW':
		pass

391 392 393 394 395
	elif action == 'Deploy_EPC':
		string_field = test.findtext('parameters')
		if (string_field is not None):
			EPC.yamlPath = string_field

hardy's avatar
hardy committed
396 397 398 399 400 401 402 403 404 405
	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	

406 407 408 409 410 411 412 413 414 415 416 417 418 419
	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
420 421 422 423 424 425
		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(',')]
426 427 428
		string_field = test.findtext('services')
		if string_field is not None:
			CONTAINERS.services[CONTAINERS.eNB_instance] = string_field
429

430
	elif action == 'DeployGenObject' or action == 'UndeployGenObject' or action == 'StatsFromGenObject':
431 432 433 434 435 436 437 438 439
		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)
440 441
		string_field=test.findtext('d_retx_th')
		if (string_field is not None):
442
			CONTAINERS.ran_checkers['d_retx_th'] = [float(x) for x in string_field.split(',')]
443 444
		string_field=test.findtext('u_retx_th')
		if (string_field is not None):
445
			CONTAINERS.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470

	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
471

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 482 483 484 485 486 487 488 489
	elif action == 'Push_Local_Registry':
		string_field = test.findtext('registry_svr_id')
		if (string_field is not None):
			CONTAINERS.registrySvrId = string_field

	elif action == 'Pull_Local_Registry':
		string_field = test.findtext('test_svr_id')
		if (string_field is not None):
			CONTAINERS.testSvrId = string_field
490
		CONTAINERS.imageToPull.clear()
491 492 493
		string_field = test.findtext('images_to_pull')
		if (string_field is not None):
			CONTAINERS.imageToPull = string_field.split()
494 495 496 497 498 499

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

500
	else:
501
		logging.warning(f"unknown action {action} from option-parsing point-of-view")
502

503

504 505 506 507 508 509 510 511 512 513 514 515
#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)

516 517 518 519 520





521
#-----------------------------------------------------------
522
# MAIN PART
523
#-----------------------------------------------------------
524 525 526

#loading xml action list from yaml
import yaml
527
xml_class_list_file='xml_class_list.yml'
hardy's avatar
hardy committed
528
if (os.path.isfile(xml_class_list_file)):
529 530 531
	yaml_file=xml_class_list_file
elif (os.path.isfile('ci-scripts/'+xml_class_list_file)):
	yaml_file='ci-scripts/'+xml_class_list_file
532 533 534
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
535

536 537 538 539 540
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
541

hardy's avatar
hardy committed
542 543 544 545 546 547 548 549 550 551

#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")
552
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
hardy's avatar
hardy committed
553
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
554 555


556

557
mode = ''
558

559
CiTestObj = cls_oaicitest.OaiCiTest()
560 561 562 563
 
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement()
RAN = ran.RANManagement()
564
HTML = cls_oai_html.HTMLManagement()
565
CONTAINERS = cls_containerize.Containerize()
566
SCA = cls_static_code_analysis.StaticCodeAnalysis()
567
PHYSIM = cls_physim1.PhySim()
568
CLUSTER = cls_cluster.Cluster()
569

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

572

573
#-----------------------------------------------------------
574
# Parsing Command Line Arguments
575 576
#-----------------------------------------------------------

577
import args_parse
578
py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER)
579

580

581

582
#-----------------------------------------------------------
583
# TEMPORARY params management (UNUSED)
584 585 586
#-----------------------------------------------------------
#temporary solution for testing:
if py_param_file_present == True:
587 588
	AssignParams(py_params)

589

590 591 592
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
593 594 595
#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)
596 597


598
#-----------------------------------------------------------
599
# mode amd XML class (action) analysis
600
#-----------------------------------------------------------
601
cwd = os.getcwd()
602

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

723 724
	CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
	CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
725
	HTML.CreateHtmlFooter(CiTestObj.finalStatus)
726
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
727 728 729
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
	logging.info('\u001B[1m  Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
	logging.info('\u001B[1m----------------------------------------\u001B[0m')
730
	if re.match('^TesteNB$', mode, re.IGNORECASE):
731
		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 == '':
732
			HELP.GenericHelp(CONST.Version)
733 734
			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)
735 736 737 738
			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)
739 740
			sys.exit('Insufficient Parameter')

741 742 743
		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")
744
	else:
745 746
		if CiTestObj.UEIPAddress == '' or CiTestObj.ranRepository == '' or CiTestObj.ranBranch == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '' or CiTestObj.UESourceCodePath == '':
			HELP.GenericHelp(CONST.Version)
747
			sys.exit('UE: Insufficient Parameter')
748

749
	#read test_case_list.xml file
750
	# if no parameters for XML file, use default value
751
	if (HTML.nbTestXMLfiles != 1):
752
		xml_test_file = cwd + "/test_case_list.xml"
753
	else:
754
		xml_test_file = cwd + "/" + CiTestObj.testXMLfiles[0]
755 756 757 758 759 760

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

	exclusion_tests=xmlRoot.findtext('TestCaseExclusionList',default='')
	requested_tests=xmlRoot.findtext('TestCaseRequestedList',default='')
761 762 763
	if (HTML.nbTestXMLfiles == 1):
		HTML.htmlTabRefs.append(xmlRoot.findtext('htmlTabRef',default='test-tab-0'))
		HTML.htmlTabNames.append(xmlRoot.findtext('htmlTabName',default='Test-0'))
764
		repeatCount = xmlRoot.findtext('repeatCount',default='1')
765
		testStability = xmlRoot.findtext('TestUnstable',default='False')
766
		CiTestObj.repeatCounts.append(int(repeatCount))
767 768 769 770 771
		if testStability == 'True':
			CiTestObj.testUnstable = True
			HTML.testUnstable = True
			CiTestObj.testMinStableId = xmlRoot.findtext('TestMinId',default='999999')
			HTML.testMinStableId = CiTestObj.testMinStableId
772
			logging.warning('Test is tagged as Unstable -- starting from TestID ' + str(CiTestObj.testMinStableId))
773 774 775 776 777 778 779 780 781 782
	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)):
783
			logging.error('exclusion test is invalidly formatted: ' + test)
784 785
			sys.exit(1)
		else:
786
			logging.info(test)
787 788 789 790 791 792 793

	#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)):
794
			logging.info('test group/case requested: ' + test)
795
		else:
796
			logging.error('requested test is invalidly formatted: ' + test)
797
			sys.exit(1)
798
	if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
799
		CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
800
		EPC.SetMmeIPAddress()
801
		EPC.SetAmfIPAddress()
802 803 804 805 806

	#get the list of tests to be done
	todo_tests=[]
	for test in requested_tests:
		if    (test_in_list(test, exclusion_tests)):
807
			logging.info('test will be skipped: ' + test)
808
		else:
809
			#logging.info('test will be run: ' + test)
810
			todo_tests.append(test)
811

812
	signal.signal(signal.SIGUSR1, receive_signal)
813

814
	if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
815 816 817
		terminate_ue_flag = False
		CiTestObj.GetAllUEDevices(terminate_ue_flag)
		CiTestObj.GetAllCatMDevices(terminate_ue_flag)
818 819
	elif (CiTestObj.ADBIPAddress == 'modules'):
		CiTestObj.UEDevices.append('COTS-Module')
820 821 822 823
	else:
		CiTestObj.UEDevices.append('OAI-UE')
	HTML.SethtmlUEConnected(len(CiTestObj.UEDevices) + len(CiTestObj.CatMDevices))
	HTML.CreateHtmlTabHeader()
824

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

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