From e462d321c90ea4311f448bc3255dc8fa59010f44 Mon Sep 17 00:00:00 2001 From: hardy Date: Tue, 7 Dec 2021 21:50:28 +0100 Subject: [PATCH 01/13] test result per MR + post to git --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 9 ++ ci-scripts/ran_dashboard/Hdashboard.py | 159 +++++++++++++++++++++-- 2 files changed, 160 insertions(+), 8 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index f594511b0a..bd8d9f4163 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -378,6 +378,15 @@ pipeline { } } } + stage ("Result Update"){ + steps { + script { + dir ('ci-scripts/ran_dashboard') { + sh "python3 Hdashboard.py testevent ${params.eNB_MR}" + } + } + } + } } } } diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 5e34ae50bf..ae62ff1a2f 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -43,7 +43,7 @@ import gitlab import yaml import os import time - +import sys from sqlconnect import SQLConnect @@ -86,6 +86,29 @@ class Dashboard: mydb.close_connection() return mydb.data + def singleMR_initHTML(self, date): + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('Test Dashboard\n') + self.f_html.write('\n') + self.f_html.write('
\n') + self.f_html.write('
\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('
OAI RAN TEST Status Dashboard
Update : '+date+'
\n') + self.f_html.write('
\n') + self.f_html.write('
\n') + + def Test_initHTML(self, date): self.f_html.write('\n') self.f_html.write('\n') @@ -197,11 +220,13 @@ class Dashboard: self.f_html.write('\n') - def Build(self, type, htmlfilename): + def Build(self, type, mr, htmlfilename): if type=='MR': self.Build_MR_Table(htmlfilename) elif type=='Tests': self.Build_Test_Table(htmlfilename) + elif type=='singleMR': + self.Build_singleMR_Table(mr,htmlfilename) else : print("Undefined Dashboard Type, options : MR or Tests") @@ -291,6 +316,93 @@ class Dashboard: self.Test_terminateHTML() + def Build_singleMR_Table(self,singlemr,htmlfilename): + print("Building single MR Tests Results...") + + self.f_html=open(htmlfilename,'w') + + ###update date/time, format dd/mm/YY H:M:S + now = datetime.now() + dt_string = now.strftime("%d/%m/%Y %H:%M") + #HTML table header + self.singleMR_initHTML(dt_string) + + + #1 table per MR if test results exist => 1 table for matching mr + for x in range(len(self.git)): + mr=str(self.git[x]['iid']) + if mr==singlemr: + #if 'PASS' not in self.db[mr]: + self.f_html.write('

'+mr+''+' '+self.git[x]['title'] + '

\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write(' \n') + self.f_html.write(' \n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + + #parsing the tests + for t in self.tests: + + row=[] + short_name= t + hyperlink= self.tests[t]['link'] + job=self.tests[t]['job'] + + + if job in self.db[mr]: + if 'PASS' in self.db[mr][job]: + row.append(self.db[mr][job]['PASS']) + else: + row.append('') + if 'FAIL' in self.db[mr][job]: + row.append(self.db[mr][job]['FAIL']) + else: + row.append('') + #2 columns for last_pass and last_fail links + if 'last_pass' in self.db[mr][job]: + lastpasshyperlink= self.db[mr][job]['last_pass'][1] + lastpasstext= self.db[mr][job]['last_pass'][0] + else: + lastpasshyperlink='' + lastpasstext='' + + if 'last_fail' in self.db[mr][job]: + lastfailhyperlink= self.db[mr][job]['last_fail'][1] + lastfailtext= self.db[mr][job]['last_fail'][0] + else: + lastfailhyperlink='' + lastfailtext='' + + + + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + if row[0]!='': + self.f_html.write('\n') + else: + self.f_html.write('\n') + if row[1]!='': + self.f_html.write('\n') + else: + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + self.f_html.write('\n') + + self.f_html.write('
Test NameBenchTest# Pass# FailLast PassLast Fail
'+short_name+''+self.tests[t]['bench']+''+self.tests[t]['test']+''+str(row[0])+''+str(row[1])+''+lastpasstext+''+lastfailtext+'
\n') + + #terminate HTML table and close file + self.Test_terminateHTML() + + + def Build_MR_Table(self,htmlfilename): print("Building Merge Requests Dashboard...") @@ -379,6 +491,7 @@ class Dashboard: #terminate HTML table and close file self.MR_terminateHTML() + def CopyToS3(self,htmlfilename,bucket,key): print("Uploading to S3 bucket") #Creating Session With Boto3. @@ -387,15 +500,45 @@ class Dashboard: #Creating S3 Resource From the Session. result = s3.upload_file(htmlfilename, bucket,key, ExtraArgs={'ACL':'public-read','ContentType': 'text/html'}) + #unused + def CopyCSS(self,path): + s3 = boto3.resource('s3') + copy_source = {'Bucket': 'oaitestdashboard','Key':'test_styles.css'} + s3.meta.client.copy(copy_source, 'oaitestdashboard', path+'/'+ 'test_styles.css') + + + def PostGitNote(self,singlemr) + gl = gitlab.Gitlab.from_config('OAI') + project_id = 223 + project = gl.projects.get(project_id) + editable_mr = project.mergerequests.get(int(singlemr)) + mr_notes = editable_mr.notes.list() + mr_note = editable_mr.notes.create({'body': 'Test Results for you MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) + editable_mr.save() + + def main(): - htmlDash=Dashboard() - htmlDash.Build('MR','/tmp/MR_index.html') - htmlDash.CopyToS3('/tmp/MR_index.html','oairandashboard','index.html') - htmlDash.Build('Tests','/tmp/Tests_index.html') - htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + #individual MR test results + test dashboard, event based (end of jenkins pipeline) + if len(sys.argv)>1: + if sys.argv[1]=="testevent" : + mr=sys.argv[2] + htmlDash=Dashboard() + htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') + htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') + htmlDash.Build('Tests','0000','/tmp/Tests_index.html') + htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + htmlDash.PostGitNote(mr) + #test and MR status dash boards, cron based + else: + htmlDash=Dashboard() + htmlDash.Build('MR','0000','/tmp/MR_index.html') + htmlDash.CopyToS3('/tmp/MR_index.html','oairandashboard','index.html') + htmlDash.Build('Tests','0000','/tmp/Tests_index.html') + htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + + - if __name__ == "__main__": # execute only if run as a script main() From bc6a4b92dc60badb86899a761da88d56daa3f6c0 Mon Sep 17 00:00:00 2001 From: hardy Date: Tue, 7 Dec 2021 22:36:52 +0100 Subject: [PATCH 02/13] change agent for boto3 --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 1 + ci-scripts/ran_dashboard/Hdashboard.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index bd8d9f4163..bb51871e37 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -379,6 +379,7 @@ pipeline { } } stage ("Result Update"){ + agent {label DataBaseHost} steps { script { dir ('ci-scripts/ran_dashboard') { diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index ae62ff1a2f..25618afd2f 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -507,7 +507,7 @@ class Dashboard: s3.meta.client.copy(copy_source, 'oaitestdashboard', path+'/'+ 'test_styles.css') - def PostGitNote(self,singlemr) + def PostGitNote(self,singlemr): gl = gitlab.Gitlab.from_config('OAI') project_id = 223 project = gl.projects.get(project_id) From 08affe9712a7e1938737161a4ed33c1c6a9ff47e Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 09:04:03 +0100 Subject: [PATCH 03/13] update jenkinsfile for lockable resource3 --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 6 +++++- ci-scripts/ran_dashboard/Hdashboard.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index bb51871e37..7ec6452159 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -37,6 +37,7 @@ def testStageName = params.pipelineTestStageName // Name of the phone/server resource def ciSmartPhonesResource1 = params.SmartPhonesResource1 def ciSmartPhonesResource2 = params.SmartPhonesResource2 +def ciSmartPhonesResource3 = params.SmartPhonesResource3 // Global Parameters. Normally they should be populated when the master job // triggers the slave job with parameters @@ -55,7 +56,7 @@ pipeline { options { disableConcurrentBuilds() ansiColor('xterm') - lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1) + lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1,resource: ciSmartPhonesResource3) } stages { stage("Build Init") { @@ -87,6 +88,9 @@ pipeline { if (params.SmartPhonesResource2 == null) { allParametersPresent = false } + if (params.SmartPhonesResource3 == null) { + allParametersPresent = false + } // 1st eNB parameters if (params.eNB_IPAddress == null) { allParametersPresent = false diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 25618afd2f..ac0aa5aa62 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -513,7 +513,7 @@ class Dashboard: project = gl.projects.get(project_id) editable_mr = project.mergerequests.get(int(singlemr)) mr_notes = editable_mr.notes.list() - mr_note = editable_mr.notes.create({'body': 'Test Results for you MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) + mr_note = editable_mr.notes.create({'body': 'Test Results for your MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) editable_mr.save() From 8325c36c50544bbc7b6f9fe5d9696745a4c8fcbe Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 09:11:46 +0100 Subject: [PATCH 04/13] fix bug in aws link to test results --- ci-scripts/ran_dashboard/Hdashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index ac0aa5aa62..54a789b2e7 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -513,7 +513,7 @@ class Dashboard: project = gl.projects.get(project_id) editable_mr = project.mergerequests.get(int(singlemr)) mr_notes = editable_mr.notes.list() - mr_note = editable_mr.notes.create({'body': 'Test Results for your MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) + mr_note = editable_mr.notes.create({'body': 'Test Results for your MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) editable_mr.save() From c3d63606a641644dd8b61713cb41354846de7382 Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 09:19:39 +0100 Subject: [PATCH 05/13] fix resource lock syntax --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index 7ec6452159..1213c48a16 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -56,7 +56,7 @@ pipeline { options { disableConcurrentBuilds() ansiColor('xterm') - lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1,resource: ciSmartPhonesResource3) + lock(extra: [[resource: ciSmartPhonesResource2],[resource: ciSmartPhonesResource1]],resource: ciSmartPhonesResource3) } stages { stage("Build Init") { From 5109fc66d65f77b517b750725083de68aab499bd Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 15:14:52 +0100 Subject: [PATCH 06/13] disable OAIUE B200 for the moment --- ci-scripts/Jenkinsfile-trig-nsa | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index de0b5c96ff..4a56270e90 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -80,13 +80,13 @@ pipeline { booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) ] //calling OAIUE B200 - build job: "RAN-SA-OAIUE-B200-CN5G", wait : true, propagate : false, parameters: [ - string(name: 'eNB_MR', value: String.valueOf(MR)), - string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), - string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), - string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), - booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) - ] + //build job: "RAN-SA-OAIUE-B200-CN5G", wait : true, propagate : false, parameters: [ + // string(name: 'eNB_MR', value: String.valueOf(MR)), + // string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + // string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + // string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + // booleanParam(name: 'eNB_mergeRequest', value: Boolean.valueOf(ALLOW_MERGE)) + //] //calling OAIUE N310 build job: "RAN-SA-OAIUE-N310-CN5G", wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), From 953029ac5c1cec47e9f2a168e4d083b379153785 Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 17:16:56 +0100 Subject: [PATCH 07/13] improve test results post to git --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 2 +- ci-scripts/ran_dashboard/Hdashboard.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index 1213c48a16..40bdfce726 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -387,7 +387,7 @@ pipeline { steps { script { dir ('ci-scripts/ran_dashboard') { - sh "python3 Hdashboard.py testevent ${params.eNB_MR}" + sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${StatusForDb} " } } } diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 54a789b2e7..7ddda8b83c 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -507,28 +507,37 @@ class Dashboard: s3.meta.client.copy(copy_source, 'oaitestdashboard', path+'/'+ 'test_styles.css') - def PostGitNote(self,singlemr): + def PostGitNote(self,mr,jobname,buildurl,status): gl = gitlab.Gitlab.from_config('OAI') project_id = 223 project = gl.projects.get(project_id) editable_mr = project.mergerequests.get(int(singlemr)) mr_notes = editable_mr.notes.list() - mr_note = editable_mr.notes.create({'body': 'Test Results for your MR are updated (End to End LTE/NSA/SA/2x2/OAIUE)'}) + mr_note = editable_mr.notes.create({ + 'body': 'Completed Test : '+jobname+' , status : '+status+'\n'+\ + buildurl+'\n'+\ + 'Consolidated Test Results (End to End LTE/NSA/SA/2x2/OAIUE)' + }) editable_mr.save() def main(): + #call from Jenkinsfile : sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${StatusForDb} " + #individual MR test results + test dashboard, event based (end of jenkins pipeline) if len(sys.argv)>1: if sys.argv[1]=="testevent" : mr=sys.argv[2] + jobname=sys.argv[3] + buildurl=sys.argv[4] + status=sys.argv[5] htmlDash=Dashboard() htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') htmlDash.Build('Tests','0000','/tmp/Tests_index.html') htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') - htmlDash.PostGitNote(mr) + htmlDash.PostGitNote(mr,jobname,buildurl,status) #test and MR status dash boards, cron based else: htmlDash=Dashboard() From 4cebb0e229db7ca9362caef754fc59baf1c3fc7f Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 18:23:22 +0100 Subject: [PATCH 08/13] fix incorrect variable name --- ci-scripts/ran_dashboard/Hdashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 7ddda8b83c..633184d8c5 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -511,7 +511,7 @@ class Dashboard: gl = gitlab.Gitlab.from_config('OAI') project_id = 223 project = gl.projects.get(project_id) - editable_mr = project.mergerequests.get(int(singlemr)) + editable_mr = project.mergerequests.get(int(mr)) mr_notes = editable_mr.notes.list() mr_note = editable_mr.notes.create({ 'body': 'Completed Test : '+jobname+' , status : '+status+'\n'+\ From f2f2f6e13fc61de908426eaa0655d681165f8b44 Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 19:35:06 +0100 Subject: [PATCH 09/13] improve post to git --- ci-scripts/ran_dashboard/Hdashboard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 633184d8c5..a5e39e812e 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -514,9 +514,9 @@ class Dashboard: editable_mr = project.mergerequests.get(int(mr)) mr_notes = editable_mr.notes.list() mr_note = editable_mr.notes.create({ - 'body': 'Completed Test : '+jobname+' , status : '+status+'\n'+\ - buildurl+'\n'+\ - 'Consolidated Test Results (End to End LTE/NSA/SA/2x2/OAIUE)' + 'body': 'Completed Test : '+jobname+' , status : '+status+'
'+\ + 'Link to this test : '+buildurl+'
'+\ + 'Consolidated Test Results (All End-to-End LTE/NSA/SA/2x2/OAIUE)' }) editable_mr.save() From 3166289ef5c29f85f05fd62962fa675ca02321ba Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 8 Dec 2021 20:27:47 +0100 Subject: [PATCH 10/13] add dbhost conditional statement for test results --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index 40bdfce726..c0f59e63a6 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -383,6 +383,9 @@ pipeline { } } stage ("Result Update"){ + when { + expression { params.DataBaseHost != "none" } + } agent {label DataBaseHost} steps { script { From 465c1f4747cf6fe645aedb406eb81dcb67d761c1 Mon Sep 17 00:00:00 2001 From: hardy Date: Thu, 9 Dec 2021 14:26:43 +0100 Subject: [PATCH 11/13] change git post appearance --- ci-scripts/Jenkinsfile-tmp-multi-enb-nsa | 2 +- ci-scripts/ran_dashboard/Hdashboard.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index c0f59e63a6..a3939d832d 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -390,7 +390,7 @@ pipeline { steps { script { dir ('ci-scripts/ran_dashboard') { - sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${StatusForDb} " + sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${env.BUILD_ID} ${StatusForDb} " } } } diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index a5e39e812e..e68bc94970 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -507,23 +507,23 @@ class Dashboard: s3.meta.client.copy(copy_source, 'oaitestdashboard', path+'/'+ 'test_styles.css') - def PostGitNote(self,mr,jobname,buildurl,status): + def PostGitNote(self,mr,jobname,buildurl,buildid,status): gl = gitlab.Gitlab.from_config('OAI') project_id = 223 project = gl.projects.get(project_id) editable_mr = project.mergerequests.get(int(mr)) mr_notes = editable_mr.notes.list() mr_note = editable_mr.notes.create({ - 'body': 'Completed Test : '+jobname+' , status : '+status+'
'+\ - 'Link to this test : '+buildurl+'
'+\ - 'Consolidated Test Results (All End-to-End LTE/NSA/SA/2x2/OAIUE)' + 'body': 'Completed Test : '+jobname+', status: '+status+', '+\ + '('+buildid+')
'+\ + 'Consolidated Test Results' }) editable_mr.save() def main(): - #call from Jenkinsfile : sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${StatusForDb} " + #call from Jenkinsfile : sh "python3 Hdashboard.py testevent ${params.eNB_MR} ${JOB_NAME} ${env.BUILD_URL} ${env.BUILD_ID} ${StatusForDb} " #individual MR test results + test dashboard, event based (end of jenkins pipeline) if len(sys.argv)>1: @@ -531,13 +531,14 @@ def main(): mr=sys.argv[2] jobname=sys.argv[3] buildurl=sys.argv[4] - status=sys.argv[5] + buildid=sys.argv[5] + status=sys.argv[6] htmlDash=Dashboard() htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') htmlDash.Build('Tests','0000','/tmp/Tests_index.html') htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') - htmlDash.PostGitNote(mr,jobname,buildurl,status) + htmlDash.PostGitNote(mr,jobname,buildurl,buildid,status) #test and MR status dash boards, cron based else: htmlDash=Dashboard() From a315ffed2cb979b4d34d2e0ee57ff956bc7f8d97 Mon Sep 17 00:00:00 2001 From: hardy Date: Tue, 14 Dec 2021 14:46:40 +0100 Subject: [PATCH 12/13] fix when build is not a listed mr --- ci-scripts/ran_dashboard/Hdashboard.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index e68bc94970..97020d1041 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -61,7 +61,9 @@ class Dashboard: self.git = self.__getGitData(cmd) #git data from Gitlab self.tests = self.__loadCfg('ran_dashboard_cfg.yaml') #tests table setup from yaml self.db = self.__loadFromDB() #test results from database - + self.mr_list=[] #mr list in string format + for x in range(len(self.git)): + self.mr_list.append(str(self.git[x]['iid'])) def __loadCfg(self,yaml_file): with open(yaml_file,'r') as f: @@ -534,11 +536,14 @@ def main(): buildid=sys.argv[5] status=sys.argv[6] htmlDash=Dashboard() - htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') - htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') - htmlDash.Build('Tests','0000','/tmp/Tests_index.html') - htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') - htmlDash.PostGitNote(mr,jobname,buildurl,buildid,status) + if mr in self.mr_list: + htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') + htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') + htmlDash.Build('Tests','0000','/tmp/Tests_index.html') + htmlDash.CopyToS3('/tmp/Tests_index.html','oaitestdashboard','index.html') + htmlDash.PostGitNote(mr,jobname,buildurl,buildid,status) + else: + print("Not a Merge Request => this build is for testing/debug purpose, no report to git") #test and MR status dash boards, cron based else: htmlDash=Dashboard() From 64216210d7e8cf7dc4fec5f37b2004f530a9cd6d Mon Sep 17 00:00:00 2001 From: hardy Date: Wed, 15 Dec 2021 08:02:01 +0100 Subject: [PATCH 13/13] bugfix : use the instance attribute correctly --- ci-scripts/ran_dashboard/Hdashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/ran_dashboard/Hdashboard.py b/ci-scripts/ran_dashboard/Hdashboard.py index 97020d1041..0cfae97c76 100644 --- a/ci-scripts/ran_dashboard/Hdashboard.py +++ b/ci-scripts/ran_dashboard/Hdashboard.py @@ -536,7 +536,7 @@ def main(): buildid=sys.argv[5] status=sys.argv[6] htmlDash=Dashboard() - if mr in self.mr_list: + if mr in htmlDash.mr_list: htmlDash.Build('singleMR',mr,'/tmp/MR'+mr+'_index.html') htmlDash.CopyToS3('/tmp/MR'+mr+'_index.html','oaitestdashboard','MR'+mr+'/index.html') htmlDash.Build('Tests','0000','/tmp/Tests_index.html')