Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZhouShuya
OpenXG-RAN
Commits
2ac9b4ff
Commit
2ac9b4ff
authored
Aug 02, 2018
by
Raphael Defosseux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI: adding on-the-fly HTML summary within python
Signed-off-by:
Raphael Defosseux
<
raphael.defosseux@eurecom.fr
>
parent
ceaac8df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
0 deletions
+138
-0
ci-scripts/Jenkinsfile-tmp-ran
ci-scripts/Jenkinsfile-tmp-ran
+5
-0
ci-scripts/main.py
ci-scripts/main.py
+133
-0
No files found.
ci-scripts/Jenkinsfile-tmp-ran
View file @
2ac9b4ff
...
...
@@ -186,6 +186,11 @@ pipeline {
[
$class
:
'UsernamePasswordMultiBinding'
,
credentialsId:
"${params.ADB_Credentials}"
,
usernameVariable:
'ADB_Username'
,
passwordVariable:
'ADB_Password'
]
])
{
sh
"python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBRepository=${eNB_Repository} --eNBBranch=${eNB_Branch} --eNBCommitID=${eNB_CommitID} --eNB_AllowMerge=${eNB_AllowMergeRequestProcess} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${testXMLFile}"
if
(
fileExists
(
"test_results.html"
))
{
sh
"mv test_results.html test_results-${JOB_NAME}.html"
sh
"sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's#TEMPLATE_BUILD_ID#${BUILD_ID}#' test_results-${JOB_NAME}.html"
archiveArtifacts
"test_results-${JOB_NAME}.html"
}
}
}
catch
(
Exception
e
)
{
currentBuild
.
result
=
'FAILURE'
...
...
ci-scripts/main.py
View file @
2ac9b4ff
...
...
@@ -83,6 +83,10 @@ class SSHConnection():
self
.
iperf_packetloss_threshold
=
''
self
.
UEDevices
=
[]
self
.
UEIPAddresses
=
[]
self
.
htmlFile
=
''
self
.
htmlHeaderCreated
=
False
self
.
htmlFooterCreated
=
False
self
.
htmlUEConnected
=
0
def
open
(
self
,
ipaddress
,
username
,
password
):
self
.
ssh
=
pexpect
.
spawn
(
'ssh'
,
[
username
+
'@'
+
ipaddress
],
timeout
=
5
)
...
...
@@ -178,6 +182,7 @@ class SSHConnection():
self
.
command
(
'echo '
+
self
.
eNBPassword
+
' | sudo -S mv log/* '
+
'build_log_'
+
SSH
.
testCase_id
,
'\$'
,
5
)
self
.
command
(
'echo '
+
self
.
eNBPassword
+
' | sudo -S mv compile_oai_enb.log '
+
'build_log_'
+
SSH
.
testCase_id
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
self
.
Build_eNB_args
,
'OK'
,
0
)
def
InitializeHSS
(
self
):
if
self
.
EPCIPAddress
==
''
or
self
.
EPCUserName
==
''
or
self
.
EPCPassword
==
''
or
self
.
EPCSourceCodePath
==
''
or
self
.
EPCType
==
''
:
...
...
@@ -198,6 +203,7 @@ class SSHConnection():
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S rm -f hss.log daemon.log'
,
'\$'
,
5
)
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S echo "Starting sudo session" && sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real '
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
self
.
EPCType
,
'OK'
,
0
)
def
InitializeMME
(
self
):
if
self
.
EPCIPAddress
==
''
or
self
.
EPCUserName
==
''
or
self
.
EPCPassword
==
''
or
self
.
EPCSourceCodePath
==
''
or
self
.
EPCType
==
''
:
...
...
@@ -219,6 +225,7 @@ class SSHConnection():
self
.
command
(
'cd /opt/ltebox/tools'
,
'\$'
,
5
)
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S ./start_mme'
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
self
.
EPCType
,
'OK'
,
0
)
def
InitializeSPGW
(
self
):
if
self
.
EPCIPAddress
==
''
or
self
.
EPCUserName
==
''
or
self
.
EPCPassword
==
''
or
self
.
EPCSourceCodePath
==
''
or
self
.
EPCType
==
''
:
...
...
@@ -234,6 +241,7 @@ class SSHConnection():
self
.
command
(
'cd /opt/ltebox/tools'
,
'\$'
,
5
)
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S ./start_xGw'
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
self
.
EPCType
,
'OK'
,
0
)
def
InitializeeNB
(
self
):
if
self
.
eNBIPAddress
==
''
or
self
.
eNBUserName
==
''
or
self
.
eNBPassword
==
''
or
self
.
eNBSourceCodePath
==
''
:
...
...
@@ -266,6 +274,7 @@ class SSHConnection():
if
(
loopCounter
==
0
):
doLoop
=
False
logging
.
debug
(
'
\u001B
[1;37;43m eNB logging system did not show got sync! See with attach later
\u001B
[0m'
)
self
.
CreateHtmlTestRow
(
config_file
,
'eNB not showing got sync!'
,
0
)
# Not getting got sync is bypassed for the moment
#sys.exit(1)
self
.
command
(
'stdbuf -o0 cat enb_'
+
SSH
.
testCase_id
+
'.log'
,
'\$'
,
10
)
...
...
@@ -274,6 +283,7 @@ class SSHConnection():
time
.
sleep
(
6
)
else
:
doLoop
=
False
self
.
CreateHtmlTestRow
(
config_file
,
'OK'
,
0
)
logging
.
debug
(
'
\u001B
[1m Initialize eNB Completed
\u001B
[0m'
)
self
.
close
()
...
...
@@ -306,6 +316,7 @@ class SSHConnection():
multi_jobs
.
append
(
p
)
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
AttachUE_common
(
self
,
device_id
):
try
:
...
...
@@ -353,6 +364,7 @@ class SSHConnection():
multi_jobs
.
append
(
p
)
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
len
(
self
.
UEDevices
))
def
DetachUE_common
(
self
,
device_id
):
try
:
...
...
@@ -377,6 +389,7 @@ class SSHConnection():
multi_jobs
.
append
(
p
)
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
RebootUE_common
(
self
,
device_id
):
try
:
...
...
@@ -431,6 +444,7 @@ class SSHConnection():
multi_jobs
.
append
(
p
)
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
GetAllUEDevices
(
self
,
terminate_ue_flag
):
if
self
.
ADBIPAddress
==
''
or
self
.
ADBUserName
==
''
or
self
.
ADBPassword
==
''
:
...
...
@@ -524,6 +538,7 @@ class SSHConnection():
i
=
i
+
1
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
self
.
ping_args
,
'OK'
,
0
)
def
Iperf_common
(
self
,
lock
,
UE_IPAddress
,
device_id
,
ue_num
):
try
:
...
...
@@ -660,6 +675,7 @@ class SSHConnection():
i
=
i
+
1
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
self
.
iperf_args
,
'OK'
,
0
)
def
CheckProcessExist
(
self
,
initialize_eNB_flag
):
multi_jobs
=
[]
...
...
@@ -753,6 +769,7 @@ class SSHConnection():
if
result
is
not
None
:
self
.
command
(
'echo '
+
self
.
eNBPassword
+
' | sudo -S killall --signal SIGKILL lte-softmodem || true'
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
TerminateHSS
(
self
):
self
.
open
(
self
.
EPCIPAddress
,
self
.
EPCUserName
,
self
.
EPCPassword
)
...
...
@@ -774,6 +791,7 @@ class SSHConnection():
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S ./kill_hss.sh'
,
'\$'
,
5
)
self
.
command
(
'rm ./kill_hss.sh'
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
TerminateMME
(
self
):
self
.
open
(
self
.
EPCIPAddress
,
self
.
EPCUserName
,
self
.
EPCPassword
)
...
...
@@ -802,6 +820,7 @@ class SSHConnection():
self
.
command
(
'cd /opt/ltebox/tools'
,
'\$'
,
5
)
self
.
command
(
'echo '
+
self
.
EPCPassword
+
' | sudo -S ./stop_xGw'
,
'\$'
,
5
)
self
.
close
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
TerminateUE_common
(
self
,
device_id
):
try
:
...
...
@@ -829,6 +848,7 @@ class SSHConnection():
multi_jobs
.
append
(
p
)
for
job
in
multi_jobs
:
job
.
join
()
self
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
0
)
def
LogCollectBuild
(
self
):
self
.
open
(
self
.
eNBIPAddress
,
self
.
eNBUserName
,
self
.
eNBPassword
)
...
...
@@ -905,6 +925,115 @@ class SSHConnection():
self
.
command
(
'zip spgw.log.zip xGwLog.0'
,
'\$'
,
60
)
self
.
close
()
#-----------------------------------------------------------
# HTML Reporting....
#-----------------------------------------------------------
def
CreateHtmlHeader
(
self
):
if
(
not
self
.
htmlHeaderCreated
):
self
.
htmlFile
=
open
(
'test_results.html'
,
'w'
)
self
.
htmlFile
.
write
(
'<!DOCTYPE html>
\n
'
)
self
.
htmlFile
.
write
(
'<html class="no-js" lang="en-US">
\n
'
)
self
.
htmlFile
.
write
(
'<head>
\n
'
)
self
.
htmlFile
.
write
(
' <title>Test Results for TEMPLATE_JOB_NAME job build #TEMPLATE_BUILD_ID</title>
\n
'
)
self
.
htmlFile
.
write
(
' <base href = "http://www.openairinterface.org/" />
\n
'
)
self
.
htmlFile
.
write
(
'</head>
\n
'
)
self
.
htmlFile
.
write
(
'<body>
\n
'
)
self
.
htmlFile
.
write
(
' <table style="border-collapse: collapse; border: none;">
\n
'
)
self
.
htmlFile
.
write
(
' <tr style="border-collapse: collapse; border: none;">
\n
'
)
self
.
htmlFile
.
write
(
' <td style="border-collapse: collapse; border: none;">
\n
'
)
self
.
htmlFile
.
write
(
' <a href="http://www.openairinterface.org/">
\n
'
)
self
.
htmlFile
.
write
(
' <img src="/wp-content/uploads/2016/03/cropped-oai_final_logo2.png" alt="" border="none" height=50 width=150>
\n
'
)
self
.
htmlFile
.
write
(
' </img>
\n
'
)
self
.
htmlFile
.
write
(
' </a>
\n
'
)
self
.
htmlFile
.
write
(
' </td>
\n
'
)
self
.
htmlFile
.
write
(
' <td style="border-collapse: collapse; border: none; vertical-align: center;">
\n
'
)
self
.
htmlFile
.
write
(
' <b><font size = "6">Job Summary -- Job: TEMPLATE_JOB_NAME -- Build-ID: TEMPLATE_BUILD_ID</font></b>
\n
'
)
self
.
htmlFile
.
write
(
' </td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlFile
.
write
(
' </table>
\n
'
)
self
.
htmlFile
.
write
(
' <br>
\n
'
)
self
.
htmlFile
.
write
(
' <table border = "1">
\n
'
)
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >GIT Repository</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>'
+
SSH
.
eNBRepository
+
'</td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Job Trigger</td>
\n
'
)
if
(
SSH
.
eNB_AllowMerge
):
self
.
htmlFile
.
write
(
' <td>Merge-Request</td>
\n
'
)
else
:
self
.
htmlFile
.
write
(
' <td>Push to Branch</td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
if
(
SSH
.
eNB_AllowMerge
):
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Source Branch</td>
\n
'
)
else
:
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Branch</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>'
+
SSH
.
eNBBranch
+
'</td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
if
(
SSH
.
eNB_AllowMerge
):
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Source Commit ID</td>
\n
'
)
else
:
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Commit ID</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>'
+
SSH
.
eNBCommitID
+
'</td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
if
(
SSH
.
eNB_AllowMerge
):
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >Target Branch</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>develop</td>
\n
'
)
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlFile
.
write
(
' </table>
\n
'
)
terminate_ue_flag
=
True
SSH
.
GetAllUEDevices
(
terminate_ue_flag
)
self
.
htmlUEConnected
=
len
(
self
.
UEDevices
)
self
.
htmlFile
.
write
(
'<h2>'
+
str
(
self
.
htmlUEConnected
)
+
' UE(s) is(are) connected to ADB bench server</h2>
\n
'
)
self
.
htmlFile
.
write
(
' <br>
\n
'
)
self
.
htmlFile
.
write
(
' <h2>Test Summary for '
+
SSH
.
testXMLfile
+
'</h2>
\n
'
)
self
.
htmlFile
.
write
(
' <table border = "1">
\n
'
)
self
.
htmlFile
.
write
(
' <tr bgcolor = "#33CCFF" >
\n
'
)
self
.
htmlFile
.
write
(
' <th>Test Id</th>
\n
'
)
self
.
htmlFile
.
write
(
' <th>Test Desc</th>
\n
'
)
self
.
htmlFile
.
write
(
' <th>Test Options</th>
\n
'
)
self
.
htmlFile
.
write
(
' <th>Test Status</th>
\n
'
)
i
=
0
while
(
i
<
self
.
htmlUEConnected
):
self
.
htmlFile
.
write
(
' <th>UE'
+
str
(
i
)
+
' Status</th>
\n
'
)
i
+=
1
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
self
.
htmlHeaderCreated
=
True
def
CreateHtmlFooter
(
self
):
if
((
not
self
.
htmlFooterCreated
)
and
(
self
.
htmlHeaderCreated
)):
self
.
htmlFile
.
write
(
' </table>
\n
'
)
self
.
htmlFile
.
write
(
'</body>
\n
'
)
self
.
htmlFile
.
write
(
'</html>
\n
'
)
self
.
htmlFile
.
close
()
self
.
htmlFooterCreated
=
False
def
CreateHtmlTestRow
(
self
,
options
,
status
,
ue_status
):
if
((
not
self
.
htmlFooterCreated
)
and
(
self
.
htmlHeaderCreated
)):
self
.
htmlFile
.
write
(
' <tr>
\n
'
)
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcyan" >'
+
SSH
.
testCase_id
+
'</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>'
+
SSH
.
desc
+
'</td>
\n
'
)
self
.
htmlFile
.
write
(
' <td>'
+
str
(
options
)
+
'</td>
\n
'
)
if
(
str
(
status
)
==
'OK'
):
self
.
htmlFile
.
write
(
' <td bgcolor = "lightgreen" >'
+
str
(
status
)
+
'</td>
\n
'
)
elif
(
str
(
status
)
==
'KO'
):
self
.
htmlFile
.
write
(
' <td bgcolor = "lightcoral" >'
+
str
(
status
)
+
'</td>
\n
'
)
else
:
self
.
htmlFile
.
write
(
' <td bgcolor = "orange" >'
+
str
(
status
)
+
'</td>
\n
'
)
i
=
0
while
(
i
<
self
.
htmlUEConnected
):
if
(
i
<
ue_status
):
self
.
htmlFile
.
write
(
' <td>-</td>
\n
'
)
else
:
self
.
htmlFile
.
write
(
' <td>-</td>
\n
'
)
i
+=
1
self
.
htmlFile
.
write
(
' </tr>
\n
'
)
#-----------------------------------------------------------
# Usage()
#-----------------------------------------------------------
def
Usage
():
...
...
@@ -1123,6 +1252,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE):
Usage
()
sys
.
exit
(
'Insufficient Parameter'
)
SSH
.
CreateHtmlHeader
()
#read test_case_list.xml file
# if no parameters for XML file, use default value
if
SSH
.
testXMLfile
==
''
:
...
...
@@ -1221,6 +1352,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE):
SSH
.
TerminateSPGW
()
else
:
sys
.
exit
(
'Invalid action'
)
SSH
.
CreateHtmlFooter
()
else
:
Usage
()
sys
.
exit
(
'Invalid mode'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment