Commit f13a1245 authored by hardy's avatar hardy

get test results into dahsboard : part 1 formatting

parent 69748161
...@@ -57,7 +57,7 @@ class gDashboard: ...@@ -57,7 +57,7 @@ class gDashboard:
#worksheet #worksheet
self.sheet = self.ss.worksheet(worksheet) self.sheet = self.ss.worksheet(worksheet)
self.ss.del_worksheet(self.sheet) #start by deleting the old sheet self.ss.del_worksheet(self.sheet) #start by deleting the old sheet
self.sheet = self.ss.add_worksheet(title=worksheet, rows="100", cols="20") #create a new one self.sheet = self.ss.add_worksheet(title=worksheet, rows="100", cols="30") #create a new one
self.d = {} #data dictionary self.d = {} #data dictionary
...@@ -78,10 +78,21 @@ class gDashboard: ...@@ -78,10 +78,21 @@ class gDashboard:
row =[dt_string] row =[dt_string]
self.sheet.insert_row(row, index=1, value_input_option='RAW') self.sheet.insert_row(row, index=1, value_input_option='RAW')
#line 2 empty #line 2 is for the test names (links to jenkins pipeline), updated at the end
#line 3 is for the column names #line 3 is for the column names
i=3 i=3
row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","Review Form","OK MERGE","Merge conflicts"] row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","Review Form","OK MERGE","Merge conflicts"]
#test 1
row.append("# PASS")
row.append("# FAIL")
row.append("Last Fail")
#test 2
row.append("# PASS")
row.append("# FAIL")
row.append("Last Fail")
self.sheet.insert_row(row, index=i, value_input_option='RAW') self.sheet.insert_row(row, index=i, value_input_option='RAW')
#line 4 onward, MR data lines #line 4 onward, MR data lines
...@@ -143,16 +154,30 @@ class gDashboard: ...@@ -143,16 +154,30 @@ class gDashboard:
found=True found=True
n+=1 n+=1
#add test results, notice : NSA only for the moment (code to be refactored for multiple tests afterwards)
cmd="python3 /home/oaicicd/mysql/sql_connect_dev.py "+str(self.d[x]['iid'])
process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)
output = process.stdout.readline()
tmp=output.decode("utf-8")
tmp=tmp.replace('\'','"')
tmp=tmp.rstrip()
testres = json.loads(tmp)
#build final row to be inserted, the first column is left empty for now, will be filled afterward with hyperlinks to gitlab MR #build final row to be inserted, the first column is left empty for now, will be filled afterward with hyperlinks to gitlab MR
row =["", str(date_time_obj.date()),str(self.d[x]['author']['name']),str(self.d[x]['title']),\ row =["", str(date_time_obj.date()),str(self.d[x]['author']['name']),str(self.d[x]['title']),\
assignee, reviewer,\ assignee, reviewer,\
milestone1,milestone2,milestone3,review_form,milestone4,conflicts] milestone1,milestone2,milestone3,review_form,milestone4,conflicts,\
testres['PASS'],testres['FAIL']]
#insert the row to worksheet #insert the row to worksheet
self.sheet.insert_row(row, index=i, value_input_option='RAW') self.sheet.insert_row(row, index=i, value_input_option='RAW')
#add MR hyperlinks in a list of requests to be sent as one update batch; this to save API calls (quotas) #add MR hyperlinks in a list of requests to be sent as one update batch; this to save API calls (quotas)
i=3 i=3
requests=[] requests=[]
...@@ -162,10 +187,39 @@ class gDashboard: ...@@ -162,10 +187,39 @@ class gDashboard:
hyperlink= '\"'+"https://gitlab.eurecom.fr/oai/openairinterface5g/-/merge_requests/"+ str(self.d[x]['iid']) +'\"' hyperlink= '\"'+"https://gitlab.eurecom.fr/oai/openairinterface5g/-/merge_requests/"+ str(self.d[x]['iid']) +'\"'
text= '\"'+str(self.d[x]['iid'])+'"' text= '\"'+str(self.d[x]['iid'])+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex)) requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex))
cmd="python3 /home/oaicicd/mysql/sql_connect_dev.py "+str(self.d[x]['iid'])
process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)
output = process.stdout.readline()
tmp=output.decode("utf-8")
tmp=tmp.replace('\'','"')
tmp=tmp.rstrip()
testres = json.loads(tmp)
if len(testres['fails list'])>0:
colIndex=14
hyperlink= '\"'+ testres['fails link'][0] +'\"'
text= '\"'+testres['fails list'][0]+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex))
i=i+1 i=i+1
body = {"requests": requests} body = {"requests": requests}
self.ss.batch_update(body) self.ss.batch_update(body)
#line 2 is for the test names
#add MR hyperlinks in a list of requests to be sent as one update batch; this to save API calls (quotas)
requests=[]
rowIndex=1
colIndex=12
hyperlink= '\"'+"https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-NSA-Mini-Module/"+'\"'
text= '\"'+'NSA Mini'+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex))
rowIndex=1
colIndex=15
hyperlink= '\"'+"https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-Module/"+'\"'
text= '\"'+'NR SA'+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex))
body = {"requests": requests}
self.ss.batch_update(body)
def addHyperlink(self, hyperlink, text, destinationSheetName, rowIndex, colIndex): def addHyperlink(self, hyperlink, text, destinationSheetName, rowIndex, colIndex):
...@@ -207,17 +261,17 @@ class gDashboard: ...@@ -207,17 +261,17 @@ class gDashboard:
"copyPaste": { "copyPaste": {
"source": { "source": {
"sheetId": sourceSheetId, "sheetId": sourceSheetId,
"startRowIndex": 0, "startRowIndex": 1,
"endRowIndex": 40, "endRowIndex": 40,
"startColumnIndex": 0, "startColumnIndex": 0,
"endColumnIndex": 12 "endColumnIndex": 19
}, },
"destination": { "destination": {
"sheetId": destinationSheetId, "sheetId": destinationSheetId,
"startRowIndex": 0, "startRowIndex": 1,
"endRowIndex": 40, "endRowIndex": 40,
"startColumnIndex": 0, "startColumnIndex": 0,
"endColumnIndex": 12 "endColumnIndex": 19
}, },
"pasteType": "PASTE_FORMAT" "pasteType": "PASTE_FORMAT"
} }
...@@ -280,11 +334,28 @@ class gDashboard: ...@@ -280,11 +334,28 @@ class gDashboard:
} }
) )
#group MR related columns
# sheetId = self.ss.worksheet(destinationSheetName)._properties['sheetId']
# requests.append(
# {
# "addDimensionGroup": {
# "range": {
# "dimension": "COLUMNS",
# "sheetId": sheetId,
# "startIndex": 3,
# "endIndex": 12
# },
# }
# }
# )
#
body = {"requests": requests} body = {"requests": requests}
self.ss.batch_update(body) self.ss.batch_update(body)
def main(): def main():
my_gDashboard=gDashboard("/opt/dashboard/g_creds.json", 'OAI RAN Dashboard', 'MR Status') my_gDashboard=gDashboard("/opt/dashboard/g_creds.json", 'OAI RAN Dashboard', 'MR Status')
cmd="""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """ cmd="""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """
......
LTE-2x2 : #short name used in the dashboard
job : 'RAN-LTE-2x2-Module-OAIEPC' #job name from Jenkins, used in the database
link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-LTE-2x2-Module-OAIEPC'
NSA-B200 :
job : 'RAN-NSA-B200-Module-LTEBOX'
link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-NSA-B200-Module-LTEBOX'
NSA-2x2 :
job : 'RAN-NSA-2x2-Module-OAIEPC'
link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-NSA-2x2-Module-OAIEPC'
SA-N310 :
job : 'RAN-SA-Module-CN5G'
link : 'https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-Module-CN5G'
\ No newline at end of file
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