How to use select_testcases method in lisa

Best Python code snippet using lisa_python

KtinkerVnf.py

Source:KtinkerVnf.py Github

copy

Full Screen

1#import enum2import tkinter as tk3import fileinput4import re5import sys6import restartModule as rsm7from tkinter import Listbox, StringVar, Checkbutton8window=tk.Tk()9window.title("VNF spinup Data")10window.geometry("1280x720")11sdc_data_file='C:\\robot_framework\\robotsolution\\robot\\resources\\SDC\\SDC_DATA.robot'12VID_data_file='C:\\robot_framework\\robotsolution\\robot\\resources\\vid\\vid_data.robot'13setcount=114#numVidNetworks=415def replace_vnf_data(file,old,new):16 print("old value is" + old)17 print("New Value is " + new)18 for line in fileinput.FileInput(file,inplace=1):19 line = re.sub(old,new, line)20 sys.stdout.write(line)21def get_entry(entryValue):22 print(entryValue.get())23 return entryValue.get()24def Search_String(file,StringValue):25 for line in fileinput.FileInput(file,inplace=0):26 #print(line)27 if(re.search(StringValue,line)):28 value = re.findall(StringValue, line)29 return value30 #sys.stdout.write(line) 31 #return value 32def extract_fields(file,StringValue):33 for line in fileinput.FileInput(file,inplace=1):34 vnfDataList=re.split(" ",line)35 36testCases=['TC#02_OVS_Network_Model_Creation','TC#03_SRIOV_Network_Model_Creation','TC#04_Network_Preload_upload','TC#05_OVS_Network_SpinUp','TC#06_SRIOV_Network_SpinUp','TC#08_VNF_Model_Creation','TC#09_VNF_Preload_Upload',37 'TC#12_Deletion','TC#13_Deletionof_VNFComponents ']38def create_TestCasesCheckBox(testCases):39 i=140 for test in testCases:41 var+i=tk.IntVar()42 Checkbutton(window,text='first',variable="var"+i).grid(column=0,row=23+i) 43# def Select_TestCases(parent=None, picks=[], side="LEFT", anchor="W"):44# vars = []45# for pick in picks:46# var = IntVar()47# chk = Checkbutton(self, text=pick, variable=var)48# chk.pack(side=side, anchor=anchor, expand=YES)49# vars.append(var) 50 51def create_Variables_Mobility(vnfName,numModules):52 vnfVariables=['vlm_name_','la_name_','fg_name_','vsp_name_','vf_name_','service_name_','service_name_Run_','model_UUID_','model_IUUID_','vsp_name_flexware_','service_name_Flexware_',53 'InvariantUUIDVnf_','UUIDVnf_']54 modelVariables=['serviceNameNetwork_','UUIDFinal_','InvariantUUID_']55 56 print("for mobility vnfs")57 #opening data file58 with open(sdc_data_file, "a+") as dataFile:59 #iterating over list variables60 for term in vnfVariables:61 #print(term)62 searchText="{"+term+vnfName 63 print(searchText)64 #iterating over lines in file65 dataFile.seek(0)66 #fileData=dataFile.readlines()67 68 for line in dataFile:69 if searchText in line:70 print(searchText)71 print(searchText+' is already present')72 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop73 else:74 dataFile.write('$'+searchText+'} '+'dummyVnfValueOfVariable\n')75 #76 for Modelterm in modelVariables:77 #print(term)78 modelSearchText="{"+Modelterm+vnfName 79 #iterating over lines in file80 dataFile.seek(0)81 #fileData=dataFile.readlines()82 83 for line2 in dataFile:84 if modelSearchText in line2:85 print(modelSearchText)86 print(modelSearchText+' is already present')87 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop88 else:89 for netItr in range (1,int(numModules)+1):90 dataFile.write('$'+modelSearchText+'_'+str(netItr)+'}'+' '+'dummyMOdelValueOfVariable\n')91 92def create_variavles_NC(vnfName,OVSModels,SRIOVModels): 93 94 vnfFabricVariables=['vlm_name_Fabric_','la_name_Fabric_','fg_name_Fabric_','vsp_name_Fabric_','vf_name_Fabric_','service_name_Fabric_','service_name_Run_','model_UUID_Fabric_','model_IUUID_Fabric_','InvariantUUIDVnf_Fabric_','UUIDVnf_Fabric_'] 95 modelOVSVariables=['UUIDFinal_OVS','InvariantUUID_OVS_','service_name_OVS_']96 modelSRIOVVariables=['UUIDFinal_SRIOV_','InvariantUUID_SRIOV_','service_name_SRIOV_']97 print("for NC vnfs") 98 #opening data file99 with open(sdc_data_file, "a+") as dataFile:100 #iterating over list variables101 for term in vnfFabricVariables:102 #print(term)103 searchText="{"+term+vnfName 104 print(searchText)105 #iterating over lines in file106 dataFile.seek(0)107 #fileData=dataFile.readlines()108 109 for line in dataFile:110 if searchText in line:111 print(searchText)112 print(searchText+' is already present')113 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop114 else:115 dataFile.write('$'+searchText+'} '+'dummyValueOfFabricVariable\n')116 #&{NetworkRole_OVS_MCCD} net1=oam_protected_net_1 net2=hsl_net_1 117 for ModelOVSterm in modelOVSVariables:118 #print(term)119 modelOvsSearchText="{"+ModelOVSterm+vnfName 120 121 #iterating over lines in file122 dataFile.seek(0)123 #fileData=dataFile.readlines()124 125 for line2 in dataFile:126 if modelOvsSearchText in line2:127 print(modelOvsSearchText)128 print(modelOvsSearchText +' is already present')129 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop130 else:131 for netItr in range (1,int(OVSModels)+1):132 dataFile.write('$'+modelOvsSearchText+'_'+str(netItr)+'}'+' '+'dummyMOdelValueOfOVSVariable\n') 133 134 135 136 #writing network roles for OVS and SRIOV 137 for line3 in dataFile:138 if ModelOvsNetworkSearchText in line3:139 print(ModelOvsNetworkSearchText)140 print(ModelOvsNetworkSearchText +' is already present')141 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop142 else:143 dataFile.write('&'+modelOvsSearchText+'}' + " "+"net1=abc net2=def net3=ghi net4=jkl net5=mno net6=pqr net7=stu net8=vwx net9=yza net10=bcd\n")144 numModelOVSSearchText="{NumModels_OVS_" +vnfName 145 for line4 in dataFile:146 if numModelOVSSearchText in line4:147 print(numModelOVSSearchText)148 print(numModelOVSSearchText +' is already present')149 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop150 else:151 dataFile.write('$'+numModelOVSSearchText+'}' + " "+OVSModels+"\n") 152 for ModelSRIOVterm in modelSRIOVVariables:153 #print(term)154 modelSRIOVSearchText="{"+ModelSRIOVterm+vnfName 155 #iterating over lines in file156 dataFile.seek(0)157 #fileData=dataFile.readlines()158 159 for line5 in dataFile:160 if modelOvsSearchText in line5:161 print(modelSRIOVSearchText)162 print(modelSRIOVSearchText+' is already present')163 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop164 else:165 for netItr in range (1,int(SRIOVModels)+1):166 dataFile.write('$'+modelSRIOVSearchText+'_'+str(netItr)+'}'+' '+'dummyMOdelValueOfOVSVariable\n') 167 #writing network roles for OVS and SRIOV 168 ModelSRIOVNetworkSearchText="{NetworkRole_SRIOV_"+vnfName 169 for line6 in dataFile:170 if ModelSRIOVNetworkSearchText in line6:171 print(ModelSRIOVNetworkSearchText)172 print(ModelSRIOVNetworkSearchText +' is already present')173 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop174 else:175 dataFile.write('&'+ModelSRIOVNetworkSearchText+'}' + " "+"net1=abc net2=def net3=ghi net4=jkl net5=mno net6=pqr net7=stu net8=vwx net9=yza net10=bcd\n")176 numModelSRIOVSearchText="{NumModels_SRIOV_"+vnfName 177 for line7 in dataFile:178 if numModelOVSSearchText in line7:179 print(numModelSRIOVSearchText)180 print(numModelSRIOVSearchText +' is already present')181 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop182 else:183 dataFile.write('$'+numModelSRIOVSearchText+'}' + " "+SRIOVModels+"\n") 184SDNCVariables=['_PRELOAD_TYPE','_VNF_NAME','_VOLUME_GROUPS_PRESENT','_NUMBER_OF_VOLUME_GROUPS','_SUBSCRIBER_NAME','_OWNING_ENTITY','_SUBSCRIBER_TYPE','_NW_PRODUCT_FAMILY','_NW_LCP_REGION','_NW_TENANT','_NW_PLATFORM'185 ,'_VNF_LINE_OF_BUSINESS','_VNF_PRODUCT_FAMILY','_VNF_LCP_REGION','_VNF_TENANT','_VNF_PLATFORM','_VF_MODULE_LCP_REGION','_VF_MODULE_LCP_REGION','_VF_MODULE_TENANT','_VOLUME_GROUP_LCP_REGION','_VOLUME_GROUP_TENANT']186VIDVariables=['created_service_Instance_ID_','NETWORK_ID_']187VidVolumeGroupVariables=['VOLUME_GROUP_ID_','VOLUME_GROUP_NAME_']188def create_variavles_SDNC(vnfName,numVidNetworks,numVidVolumes): 189 print("for NC vnfs") 190 with open(sdc_data_file, "a+") as dataFile:191 #iterating over list variables192 for term in SDNCVariables:193 #print(term)194 searchText="{"+vnfName+term 195 print(searchText)196 #iterating over lines in file197 dataFile.seek(0)198 #fileData=dataFile.readlines()199 200 for line in dataFile:201 if searchText in line:202 print(searchText)203 print(searchText+' is already present')204 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop205 else:206 dataFile.write('$'+searchText+'} '+'dummyVnfValueOfVariable\n')207 #208 for vidTerm in VIDVariables:209 #print(term)210 vidSearchText="{"+vidTerm+vnfName 211 #iterating over lines in file212 dataFile.seek(0)213 #fileData=dataFile.readlines()214 215 for line2 in dataFile:216 if vidSearchText in line2:217 print(vidSearchText)218 print(vidSearchText+' is already present')219 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop220 else:221 for netItr in range (1,int(numVidNetworks)+1):222 dataFile.write('$'+vidSearchText+'_Network_'+str(netItr)+'}'+' '+'dummyMOdelValueOfVariable\n') 223 for volumeTerm in VidVolumeGroupVariables:224 #print(term)225 volumeSearchText="{"+volumeTerm+vnfName 226 #iterating over lines in file227 dataFile.seek(0)228 #fileData=dataFile.readlines()229 230 for line3 in dataFile:231 if volumeSearchText in line3:232 print(volumeSearchText)233 print(volumeSearchText+' is already present')234 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop235 else:236 for netItr in range (1,int(numVidVolumes)+1):237 dataFile.write('$'+volumeSearchText+'_'+str(netItr)+'}'+' '+'dummyMOdelValueOfVariable\n') 238 for line3 in dataFile:239 if "${VNF_ID_"+vnfName in line3:240 print(volumeSearchText)241 print("${VNF_ID_"+vnfName+' is already present')242 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop243 else:244 245 dataFile.write("${VNF_ID_"+vnfName+'}'+' '+'dummyVnfId\n') 246 for line5 in dataFile:247 if "${created_service_Instance_ID_"+vnfName in line3:248 249 print("${created_service_Instance_ID_"+vnfName+' is already present')250 #applying for else loop here.It means if condition is not matched in for loop do the part in else loop251 else:252 253 dataFile.write("${created_service_Instance_ID_"+vnfName+'}'+' '+'dummyServiceInstanceId\n') 254 255 256##creating list 257v = tk.IntVar()258tk.Radiobutton(window, text="Fresh", variable=v, value=1).grid(column=1,row=18)259tk.Radiobutton(window, text="Re-Run", variable=v, value=2).grid(column=1,row=19)260VnfData=tk.Label(text="Please enter data about your VNF here",font=("Times New Roman", 30))261VnfData.grid(column=1, row=0)262#creating Vnf type263VnfType=tk.Label(text="select your VNF type")264VnfType.grid(column=1, row=15) 265VnfTypeList =tk.Listbox(window)266VnfTypeList.grid(column=1, row=16)267for item in ["mobility", "Network Cloud"]:268 VnfTypeList.insert(tk.END, item)269#creating Vnf name270VnfName=tk.Label(text="Enter VNF name")271VnfName.grid(column=0, row=3, sticky='w')272#VnfNameValue=StringVar273VnfNameValue = StringVar()274VnfNameEntry=tk.Entry(window, textvariable=VnfNameValue) #275VnfNameEntry.grid(column=1, row=3)276#creating heatfile name277HeatFileName=tk.Label(text="Enter heatfile name")278HeatFileName.grid(column=0, row=4, sticky='w')279HeatFileValue = StringVar()280HeatFileNameEntry=tk.Entry(window, textvariable=HeatFileValue)281HeatFileNameEntry.grid(column=1, row=4)282#creating Policy Name283PolicyName=tk.Label(text="Enter naming policy name")284PolicyName.grid(column=0, row=5, sticky='w')285PolicyNameValue = StringVar()286PolicyNameEntry=tk.Entry(window,textvariable=PolicyNameValue)287PolicyNameEntry.grid(column=1, row=5)288#creating NFC naming code289nfcNamingCode=tk.Label(text="Enter nfc naming code")290nfcNamingCode.grid(column=0, row=6, sticky='w')291nfcNamingCodeValue=StringVar()292nfcNamingCodeEntry=tk.Entry(window,textvariable=nfcNamingCodeValue)293nfcNamingCodeEntry.grid(column=1, row=6)294#crerating Nf role295nfRole=tk.Label(text="Enter nf role", )296nfRole.grid(column=0, row=7, sticky='w')297nfRoleValue=StringVar()298nfRoleEntry=tk.Entry(window,textvariable=nfRoleValue)299nfRoleEntry.grid(column=1, row=7)300#craeting Nf naming code301nfNamingCode=tk.Label(text="Enter nf namingcode")302nfNamingCode.grid(column=0, row=8, sticky='w')303nfNamingCodeValue=StringVar()304nfNamingCodeEntry=tk.Entry(window,textvariable=nfNamingCodeValue)305nfNamingCodeEntry.grid(column=1, row=8)306#creating nf type307nfType=tk.Label(text="Enter nf type")308nfType.grid(column=0, row=9, sticky='w')309nfTypeValue=StringVar()310nfTypeEntry=tk.Entry(window,textvariable=nfTypeValue)311nfTypeEntry.grid(column=1, row=9)312#craeting number of models313numModels=tk.Label(text="Enter number of models to be run")314numModels.grid(column=0, row=10, sticky='w')315numModelsValue=StringVar()316numModelsEntry=tk.Entry(window,textvariable=numModelsValue)317numModelsEntry.grid(column=1, row=10)318#creating Sriov model count319numModelsSriov=tk.Label(text="Enter number of SRIOV models to be run")320numModelsSriov.grid(column=0, row=11, sticky='w')321numModelsSriovValue=StringVar()322numModelsSriovEntry=tk.Entry(window,textvariable=numModelsSriovValue)323numModelsSriovEntry.grid(column=1, row=11) 324#creating OVS model counrt325numModelOVS=tk.Label(text="Enter number of OVS models to be run")326numModelOVS.grid(column=0, row=12, sticky='w')327numModelOVSValue=StringVar()328numModelOVSEntry=tk.Entry(window,textvariable=numModelOVSValue)329 330numModelOVSEntry.grid(column=1, row=12) 331#Select_TestCases(parent='Window', picks=['ram','shyam','sita','gita'], side="LEFT", anchor="W")332#creating first Submit button333submitButton = tk.Button(text="submit",bg='red',command=lambda: get_entry(content))334submitButton.grid(column=1,row=21)335#creating Second submit button336submitButton2 = tk.Button(text="submit",bg='red',command=window.destroy)337submitButton2.grid(column=1,row=23)338var1=tk.IntVar()339var2=tk.IntVar()340 341 342Checkbutton(window,text='first',variable=var1).grid(column=0,row=23)343Checkbutton(window,text='first',variable=var2).grid(column=1,row=23)344create_TestCasesCheckBox(testCases)345#starint mainloop346window.mainloop()347#print("new value is "+get_entry(VnfNameValue))348#349#newReplacedValue='SCN}' + " " +get_entry(VnfNameValue) +'\n'350#replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)351# print(sdc_data_file)352#finding heat value and replacing in file353# Search_StringValue=Search_String(sdc_data_file,'Dict_LMSP}'+'[\s+a-zA-Z://0-9.-_]*'+'heatfile_Update=') 354# print(Search_StringValue)355# heatvalue=get_entry(HeatFileValue)356# replace_value=Search_StringValue[0] +heatvalue+" "357# replace_vnf_data(sdc_data_file,Search_StringValue[0],replace_value)358# #newSearch_StringValue=Search_String(sdc_data_file,replace_value+'[\s+a-zA-Z://0-9.-_]*') 359# newSearch_StringValue=Search_String(sdc_data_file,'Dict_LMSP}'+'[\s+a-zA-Z://0-9.-_]*'+'heatfile_Update='+heatvalue+'\s+'+'[a-zA-Z://0-9.-_]*') 360# print(newSearch_StringValue[0]) 361# replace_vnf_data(sdc_data_file,newSearch_StringValue[0],replace_value)362#create_Variables_Mobility("MMM",'4')363Select_TestCases(parent='Window', picks=['ram','shyam','sita','gita'], side=LEFT, anchor="W")364# newReplacedValue='SCN}' + " " +get_entry(HeatFileValue) +'\n'365# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)366# 367# newReplacedValue='SCN}' + " " +get_entry(PolicyNameValue) +'\n'368# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)369# 370# newReplacedValue='SCN}' + " " +get_entry(nfcNamingCodeValue) +'\n'371# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)372# 373# newReplacedValue='SCN}' + " " +get_entry(nfRoleValue) +'\n'374# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)375# 376# newReplacedValue='SCN}' + " " +get_entry(nfNamingCodeValue) +'\n'377# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)378# 379# newReplacedValue='SCN}' + " " +get_entry(nfTypeValue) +'\n'380# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)381# 382# newReplacedValue='SCN}' + " " +get_entry(numModelsValue) +'\n'383# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)384# 385# newReplacedValue='SCN}' + " " +get_entry(numModelsSriovValue) +'\n'386# replace_vnf_data(sdc_data_file,'SCN}[\s+a-zA-Z://0-9.-_]*',newReplacedValue)387# 388# newReplacedValue='SCN}' + " " +get_entry(numModelOVSValue) +'\n'...

Full Screen

Full Screen

selector.py

Source:selector.py Github

copy

Full Screen

...27 j += blocksize28 blocksize /= 229 sys.stderr.write("\n")30 return data31 def select_testcases(self, seeddirs, count=10):32 #determine execution time for each file33 results = []34 try:35 for seeddir in seeddirs:36 for fname in glob.glob(seeddir+"/*"):37 with open(fname, "rb") as f:38 data = f.read()39 self.ext = fname.split(".")[-1]40 data = self.minimize(data)41 fname = os.path.basename(fname)42 with open("/tmp/minimized-%s" % fname, "wb") as f:43 f.write(data)44 start = time.time()45 try:...

Full Screen

Full Screen

commands.py

Source:commands.py Github

copy

Full Screen

...61 list_all = cast(Optional[bool], args.list_all)62 log = _get_init_logger("list")63 if args.type == constants.LIST_CASE:64 if list_all:65 cases: Iterable[TestCaseRuntimeData] = select_testcases()66 else:67 cases = select_testcases(builder.partial_resolve(constants.TESTCASE))68 for case_data in cases:69 log.info(70 f"case: {case_data.name}, suite: {case_data.metadata.suite.name}, "71 f"area: {case_data.suite.area}, "72 f"category: {case_data.suite.category}, "73 f"tags: {','.join(case_data.suite.tags)}, "74 f"priority: {case_data.priority}"75 )76 else:77 raise LisaException(f"unknown list type '{args.type}'")78 log.info("list information here")79 return 080class CommandHookSpec:81 @hookspec...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful