Commit 190ff5df authored by hardy's avatar hardy

python_v2/Jenkinsfile-testinfra-as-code

parent 2d4e8cc3
class CN:
def __init__(self,infra,config,deployment):
self.Deployment=deployment
self.Infra=infra
for k,v in config.items():
setattr(self,k,v)
\ No newline at end of file
class NodeB:
def __init__(self,infra,config,deployment):
self.Deployment=deployment
self.Infra=infra
for k,v in config.items():
setattr(self,k,v)
\ No newline at end of file
class UE:
def __init__(self,infra,config,deployment):
self.Deployment=deployment
self.Infra=infra
for k,v in config.items():
setattr(self,k,v)
\ No newline at end of file
#loading xml action list from yaml
import yaml
import cls_ue
import cls_ran
import cls_cn
#from yaml description of test infrastructure, return infrastructure data model
def GetTestInfrastructure(filename):
with open(filename,'r') as f:
infra = yaml.load(f)
return infra
#from yaml description of testcase, return configuration data model
def GetTestConfig(filename):
with open(filename,'r') as f:
test_config = yaml.load(f)
return test_config
def GetTestObjects(key,infrastructure,test_cfg):
part=test_cfg['config'][key]['key'] #identify the relevant infra part from test config naming ex : RAN_0
elements=test_cfg['config'][key][key].keys() #retrieve the effective elements under test
#create dict of Objects under test
OBJ={}
for n in elements:
deployment = test_cfg['config'][key][key][n]['Deploy']
obj_part=infrastructure[part][n] #retrieve the infra part of the element under test only
if key=='RAN':
OBJ[n]=cls_ran.NodeB(infrastructure,obj_part,deployment)
elif key=='CN':
OBJ[n]=cls_cn.CN(infrastructure,obj_part,deployment)
elif key=='UE':
OBJ[n]=cls_ue.UE(infrastructure,obj_part,deployment)
else:
pass
return OBJ #dictionary of objects under test
if __name__ == "__main__":
testbench='testinfra-as-code.yaml'
test='test-example.yaml'
infrastructure=GetTestInfrastructure(testbench)
test_cfg=GetTestConfig(test)
RAN=GetTestObjects('RAN',infrastructure,test_cfg)
CN=GetTestObjects('CN',infrastructure,test_cfg)
UEs=GetTestObjects('UE',infrastructure,test_cfg)
config:
filename : testinfra-as-code.yaml
RAN :
key : RAN_1
RAN :
eNB_0 :
Deploy : Bare
gNB_0 :
Deploy : Container
UE :
key : myUEs
UE :
idefix_0:
Deploy : None
oppo:
Deploy : None
oaiue:
Deploy : Bare
CN :
key : CN_0
CN :
LTEBox_0:
Deploy : Bare
OAICN5G:
Deploy : Compose
#list needed for iteration
Tests :
- t1.xml
- t2.xml
- t3.xml
- t4.xml
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 29 09:38:02 2021
@author: hardy
"""
class NodeB:
def __init__(self,infra,config,deployment):
self.deployment=deployment
self.infra=infra
for k,v in config.items():
setattr(self,k,v)
class UE:
def __init__(self,infra,config):
self.infra=infra
for k,v in config.items():
setattr(self,k,v)
#loading xml action list from yaml
import yaml
yaml_file='testinfra-as-code.yaml'
with open(yaml_file,'r') as f:
infra = yaml.load(f)
yaml_file='test-example.yaml'
with open(yaml_file,'r') as f:
test = yaml.load(f)
#RAN spec from test
ran_key=test['config']['RAN']['key']
nodes_key=test['config']['RAN']['Nodes'].keys()
#create dict of RAN objects RAN under Test
RAN={}
for n in nodes_key:
deployment = test['config']['RAN']['Nodes'][n]['Deploy']
config=infra[ran_key][n]
RAN[n]=NodeB(infra,config,deployment)
#UE spec from test
ue_key=test['config']['UE']['key']
allues_key=test['config']['UE']['UEs'].keys()
#create dict of UE objects UE under Test
UEs={}
for u in allues_key:
config=infra[ue_key][u]
UEs[u]=UE(infra,config)
RAN_1:
eNB_0 :
ID : eNB_0
Name : toto
Type : eNB
Deploy :
Bare :
Kind : bare
IPAddress : 192.168.18.193 #on Obelix
Username : oaicicd
SourceCodePath : /tmp/my-CI-NSA-eNB
Container :
Kind : docker
Args :
Cluster :
Kind : openshift
Args :
gNB_0 :
ID : gNB_0
Name : titi
Type : eNB
Deploy :
Bare :
Kind : Bare
IPAddress : 192.168.18.194 #on Obelix
Username : oaicicd
SourceCodePath : /tmp/my-CI-NSA-gNB
Container :
Kind : docker
Args :
Cluster :
Kind : openshift
Args :
eNB_1 :
ID : eNB_0
Name : tata
Type : eNB
Deploy :
Bare :
Kind : Bare
IPAddress : 192.168.18.195 #on Obelix
Username : oaicicd
SourceCodePath : /tmp/my-CI-NSA-eNB
Container :
Kind : docker
Args :
Cluster :
Kind : openshift
Args :
CN_0:
LTEBox_0 :
ID : LTEBox_0
Name : LTE_box_on_nikaia
Type : LTEBOX
Deploy :
bare :
Kind : bare
IPAddress : 192.168.18.99 #on Nikaia
Username : oaicicd
SourceCodePath : /tmp/
SABox_0 :
ID : SABox_0
Name : SA_box_on_newserver
Type : SABOX
Deploy :
Bare :
Kind : Bare
IPAddress : 192.168.18.999 #on
Username : oaicicd
SourceCodePath : /tmp/
OAICN5G :
ID : OAICN5G
Name :
Type :
Deploy :
Compose :
Kind : Compose
IPAddress : 192.168.18.999 #on
Username : oaicicd
SourceCodePath : /tmp/
myUEs:
oaiue :
Deploy :
bare :
Kind : bare
IPAddress : 192.168.18.99 #on Nikaia
Username : oaicicd
SourceCodePath : /tmp/
idefix_0:
Name : idefix0
State : enabled
Kind : module
Type : quectel
Process :
Name : quectel-CM
Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4
WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup
DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach
PLMN : 22201
UENetwork : wwan0
HostIPAddress : 192.168.18.188
HostUsername : oaicicd
HostPassword : oaicicd
HostSourceCodePath : none
porcepix_0:
Name : porcepix0
State : enabled
Kind : module
Type : quectel
Process :
Name : quectel-CM
Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4
WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup
DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach
PLMN : 22201
UENetwork : wwan0
HostIPAddress : 192.168.18.188
HostUsername : oaicicd
HostPassword : oaicicd
HostSourceCodePath : none
porcepix_1:
Name : porcepix1
State : enabled
Kind : module
Type : quectel
Process :
Name : quectel-CM
Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4
WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup
DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach
PLMN : 22201
UENetwork : wwan0
HostIPAddress : 192.168.18.188
HostUsername : oaicicd
HostPassword : oaicicd
HostSourceCodePath : none
oppo:
Name : opporeno5g
State : enabled
Kind : mobile
ADBIPAddress : 192.168.18.196
ADBUsername : oaici
ADBPassword : KkexF6CErOi1fNuebCPsuIVK
ADBIdentifier : 9d690a12
Sequences :
Airplane :
- adb shell input keyevent KEYCODE_POWER
- adb shell input swipe 300 700 300 0
- adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
- adb shell input keyevent 20
- adb shell input tap 968 324
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment