blob: bbf12a4a30668d2388169d800ed85d352647cf7f [file] [log] [blame]
Devin Lime1346f42018-05-15 15:41:36 -07001#!groovy
Devin Limf5175192018-05-14 19:13:22 -07002// Copyright 2017 Open Networking Foundation (ONF)
3//
4// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7//
8// TestON is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation, either version 2 of the License, or
11// (at your option) any later version.
12//
13// TestON is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with TestON. If not, see <http://www.gnu.org/licenses/>.
20
21// This is the dependency Jenkins script.
22// it has some common functions that runs test and generate graph.
23
Devin Lim61643762017-12-07 15:55:38 -080024import groovy.time.*
Devin Limb734ea52018-05-14 14:13:05 -070025generalFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/GeneralFuncs.groovy' )
26fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Devin Limfe9a4cb2018-05-11 17:06:21 -070027
28fileRelated.init()
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080029
Devin Lim61643762017-12-07 15:55:38 -080030def initializeTrend( machine ){
Devin Limf5175192018-05-14 19:13:22 -070031 // For initializing any trend graph jobs
32 // machine : Either VM,BM, or Fabric#
33
Devin Lim61643762017-12-07 15:55:38 -080034 table_name = "executed_test_tests"
35 result_name = "executed_test_results"
36 testMachine = "TestStation-" + machine + "s";
37 this.machine = machine
38 isSCPF = false
Devin Lim981f80b2018-04-09 11:25:59 -070039 isTrend = true
Devin Lim61643762017-12-07 15:55:38 -080040}
41def initialize( type, SCPFfuncs ){
Devin Limf5175192018-05-14 19:13:22 -070042 // Initializing for SCPF tests
43 // type : type of the test ( SR,FUNC,SCPF... )
44 // Passing the SCPFfunction which will be PerformanceFuncs.groovy
45
Devin Lim61643762017-12-07 15:55:38 -080046 init( type )
47 SCPFfunc = SCPFfuncs
48 isSCPF = true
49 machine = machineType[ type ]
50}
51def initialize( type ){
Devin Limf5175192018-05-14 19:13:22 -070052 // initializing for FUNC,HA,SR, and USECASE
53 // type : type of the test ( SR,FUNC,SCPF... )
54
Devin Lim61643762017-12-07 15:55:38 -080055 init( type )
56 SCPFfunc = null
57 table_name = "executed_test_tests"
58 result_name = "executed_test_results"
Devin Limfe9a4cb2018-05-11 17:06:21 -070059 trend_generator_file = fileRelated.trendMultiple
60 build_stats_generator_file = fileRelated.histogramMultiple
Devin Lim61643762017-12-07 15:55:38 -080061 isSCPF = false
62}
63def init( type ){
Devin Limf5175192018-05-14 19:13:22 -070064 // type : type of the test ( SR,FUNC,SCPF... )
65
Devin Lim61643762017-12-07 15:55:38 -080066 machineType = [ "FUNC" : "VM",
67 "HA" : "VM",
Devin Lim431408d2018-03-23 17:51:31 -070068 "SR" : "Fabric",
Devin Lim61643762017-12-07 15:55:38 -080069 "SCPF" : "BM",
70 "USECASE" : "BM" ]
71 testType = type;
72 testMachine = "TestStation-" + machineType[ type ] + "s";
Devin Lim981f80b2018-04-09 11:25:59 -070073 isTrend = false
Devin Lim61643762017-12-07 15:55:38 -080074}
Devin Lim86e40532018-04-06 12:44:06 -070075def additionalInitForSR( branch ){
Devin Limf5175192018-05-14 19:13:22 -070076 // additional setup for SegmentRouting tests to determine the machine depends on the branch it is running.
77 // branch : branch of the onos. ( master, 1.12, 1.13... )
78
Devin Limc38e6932018-04-06 18:04:33 -070079 testMachine = ( ( new StringBuilder( testMachine ) ).insert( testMachine.size()-1, fabricOn( branch ) ) ).toString()
Devin Lim6cccad52018-04-09 11:32:19 -070080 if( isTrend )
81 machine += fabricOn( branch )
82 else
83 machineType[ testType ] += fabricOn( branch )
Devin Lim86e40532018-04-06 12:44:06 -070084 print testMachine
85}
86def fabricOn( branch ){
Devin Limf5175192018-05-14 19:13:22 -070087 // gets the fabric machines with the branch of onos.
88 // branch : master, 1.12, 1.13...
89
You Wang96b98ad2018-05-25 12:14:45 -070090 switch( branch.reverse().take(4).reverse() ) {
91 case "master": return "4"
92 case "1.13": return "2"
93 case "1.12": return "3"
94 }
Devin Lim86e40532018-04-06 12:44:06 -070095}
Devin Lim61643762017-12-07 15:55:38 -080096def printType(){
Devin Limf5175192018-05-14 19:13:22 -070097 // print the test type and test machine that was initialized.
98
Devin Lim61643762017-12-07 15:55:38 -080099 echo testType;
100 echo testMachine;
101}
102def getProperties(){
Devin Limf5175192018-05-14 19:13:22 -0700103 // get the properties of the test by reading the TestONOS.property
104
Devin Lim61643762017-12-07 15:55:38 -0800105 node( testMachine ){
106 return readProperties( file:'/var/jenkins/TestONOS.property' );
107 }
108}
109def getTestsToRun( testList ){
Devin Limf5175192018-05-14 19:13:22 -0700110 // get test to run by tokenizing the list.
111
Devin Lim61643762017-12-07 15:55:38 -0800112 testList.tokenize("\n;, ")
113}
114def getCurrentTime(){
Devin Limf5175192018-05-14 19:13:22 -0700115 // get time of the PST zone.
116
Devin Limd1fb8e92018-02-28 16:29:33 -0800117 TimeZone.setDefault( TimeZone.getTimeZone('PST') )
Devin Lim61643762017-12-07 15:55:38 -0800118 return new Date();
119}
120def getTotalTime( start, end ){
Devin Limf5175192018-05-14 19:13:22 -0700121 // get total time of the test using start and end time.
122
Devin Lim61643762017-12-07 15:55:38 -0800123 return TimeCategory.minus( end, start );
124}
125def printTestToRun( testList ){
Devin Limf5175192018-05-14 19:13:22 -0700126 // printout the list of the test in the list.
127
Devin Lim61643762017-12-07 15:55:38 -0800128 for ( String test : testList ) {
129 println test;
130 }
131}
132def sendResultToSlack( start, isManualRun, branch ){
Devin Limf5175192018-05-14 19:13:22 -0700133 // send the result of the test to the slack when it is not manually running.
134 // start : start time of the test
135 // isManualRun : string that is whether "false" or "true"
136 // branch : branch of the onos.
137
Devin Lim61643762017-12-07 15:55:38 -0800138 try{
139 if( isManualRun == "false" ){
140 end = getCurrentTime();
141 TimeDuration duration = TimeCategory.minus( end , start );
142 slackSend( color:"#5816EE",
143 message: testType + "-" + branch + " tests ended at: " + end.toString() + "\nTime took : " + duration )
144 }
145 }
146 catch( all ){}
147}
148def initAndRunTest( testName, testCategory ){
Devin Limf5175192018-05-14 19:13:22 -0700149 // Bash script that will
150 // Initialize the environment to the machine and run the test.
151 // testName : name of the test
152 // testCategory : (SR,FUNC ... )
153
Devin Lim61643762017-12-07 15:55:38 -0800154 return '''#!/bin/bash -l
155 set -i # interactive
156 set +e
157 shopt -s expand_aliases # expand alias in non-interactive mode
158 export PYTHONUNBUFFERED=1
159 ifconfig
Devin Lim61643762017-12-07 15:55:38 -0800160 echo "ONOS Branch is: $ONOSBranch"
161 echo "TestON Branch is: $TestONBranch"
162 echo "Test date: "
163 date
164 cd ~
165 export PATH=$PATH:onos/tools/test/bin
166 timeout 240 stc shutdown | head -100
167 timeout 240 stc teardown | head -100
168 timeout 240 stc shutdown | head -100
169 cd ~/OnosSystemTest/TestON/bin
170 git log |head
171 ./cleanup.sh -f
Devin Lima7b97a42018-04-09 14:26:38 -0700172 ''' + "./cli.py run " + ( !isSCPF ? testName : testCategory[ testName ][ 'test' ] ) + " --params GRAPH/nodeCluster=" + machineType[ testType ] + '''
Devin Lim61643762017-12-07 15:55:38 -0800173 ./cleanup.sh -f
174 # cleanup config changes
175 cd ~/onos/tools/package/config
176 git clean -df'''
177}
178def copyLogs( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700179 // bash script part for copy the logs and other neccessary element for SR tests.
180 // testName : name of the test.
181
Devin Lim61643762017-12-07 15:55:38 -0800182 result = ""
183 if( testType == "SR" ){
184 result = '''
185 sudo rm /var/jenkins/workspace/SR-log-${WikiPrefix}/*
186 sudo cp *karaf.log.* /var/jenkins/workspace/SR-log-${WikiPrefix}/
187 sudo cp *Flows* /var/jenkins/workspace/SR-log-${WikiPrefix}/
188 sudo cp *Groups* /var/jenkins/workspace/SR-log-${WikiPrefix}/
Devin Lima7b97a42018-04-09 14:26:38 -0700189 sudo cp *.tar.gz /var/jenkins/workspace/SR-log-${WikiPrefix}/
Devin Lim6faa3f92018-05-01 13:16:25 -0700190 sudo cp t3-* /var/jenkins/workspace/SR-log-${WikiPrefix}/
Devin Lim61643762017-12-07 15:55:38 -0800191 '''
192 }
193 return result
194}
195def cleanAndCopyFiles( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700196 // clean up some files that were in the folder and copy the new files from the log
197 // testName : name of the test
198
Devin Lim61643762017-12-07 15:55:38 -0800199 return '''#!/bin/bash -i
200 set +e
201 echo "ONOS Branch is: ${ONOSBranch}"
202 echo "TestON Branch is: ${TestONBranch}"
203 echo "Job name is: "''' + testName + '''
204 echo "Workspace is: ${WORKSPACE}/"
205 echo "Wiki page to post is: ${WikiPrefix}-"
206 # remove any leftover files from previous tests
207 sudo rm ${WORKSPACE}/*Wiki.txt
208 sudo rm ${WORKSPACE}/*Summary.txt
209 sudo rm ${WORKSPACE}/*Result.txt
210 sudo rm ${WORKSPACE}/*.csv
211 #copy files to workspace
212 cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
213 ''' + copyLogs( testName ) + '''
214 sudo cp *.txt ${WORKSPACE}/
215 sudo cp *.csv ${WORKSPACE}/
216 cd ${WORKSPACE}/
217 for i in *.csv
218 do mv "$i" "$WikiPrefix"-"$i"
219 done
220 ls -al
221 cd '''
222}
223def fetchLogs( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700224 // fetch the logs of onos from onos nodes to onos System Test logs
225 // testName: name of the test
226
Devin Lim61643762017-12-07 15:55:38 -0800227 return '''#!/bin/bash
228 set +e
229 cd ~/OnosSystemTest/TestON/logs
230 echo "Job Name is: " + ''' + testName + '''
231 TestONlogDir=$(ls -t | grep ${TEST_NAME}_ |head -1)
232 echo "########################################################################################"
233 echo "##### copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}"
234 echo "########################################################################################"
235 cd $TestONlogDir
236 if [ $? -eq 1 ]
237 then
238 echo "Job name does not match any test suite name to move log!"
239 else
240 pwd
241 for i in $OC{1..7}; do onos-fetch-logs $i || echo log does not exist; done
242 fi
243 cd'''
244}
245def isPostingResult( manual, postresult ){
Devin Limf5175192018-05-14 19:13:22 -0700246 // check if it is posting the result.
247 // posting when it is automatically running or has postResult condition from the manual run
248
Devin Lim61643762017-12-07 15:55:38 -0800249 return manual == "false" || postresult == "true"
250}
251def postResult( prop, graphOnly ){
Devin Limf5175192018-05-14 19:13:22 -0700252 // post the result by triggering postjob.
253 // prop : property dictionary that was read from the machine.
254 // graphOnly : if it is graph generating job
255
Devin Lim61643762017-12-07 15:55:38 -0800256 if( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
257 def post = build job: "postjob-" + ( graphOnly ? machine : machineType[ testType ] ), propagate: false
258 }
259}
260def postLogs( testName, prefix ){
Devin Limf5175192018-05-14 19:13:22 -0700261 // posting logs of the onos jobs specifically SR tests
262 // testName : name of the test
263 // prefix : branch prefix ( master, 1.12, 1.13 ... )
264
Devin Lim61643762017-12-07 15:55:38 -0800265 resultURL = ""
266 if( testType == "SR" ){
267 def post = build job: "SR-log-" + prefix, propagate: false
268 resultURL = post.getAbsoluteUrl()
269 }
270 return resultURL
271}
272def getSlackChannel(){
Devin Limf5175192018-05-14 19:13:22 -0700273 // get name of the slack channel.
274 // if the test is SR, it will return sr-failures
275
Devin Lim61643762017-12-07 15:55:38 -0800276 return "#" + ( testType == "SR" ? "sr-failures" : "jenkins-related" )
277}
278def analyzeResult( prop, workSpace, testName, otherTestName, resultURL, wikiLink, isSCPF ){
Devin Limf5175192018-05-14 19:13:22 -0700279 // analyzing the result of the test and send to slack if the test was failed.
280 // prop : property dictionary
281 // workSpace : workSpace where the result file is saved
282 // testName : real name of the test
283 // otherTestName : other name of the test for SCPF tests ( SCPFflowTPFobj )
284 // resultURL : url for the logs for SR tests. Will not be posted if it is empty
285 // wikiLink : link of the wiki page where the result was posted
286 // isSCPF : Check if it is SCPF. If so, it won't post the wiki link.
287
Devin Lim61643762017-12-07 15:55:38 -0800288 node( testMachine ){
289 resultContents = readFile workSpace + "/" + testName + "Result.txt"
290 resultContents = resultContents.split("\n")
291 if( resultContents[ 0 ] == "1" ){
292 print "All passed"
293 }else{
294 print "Failed"
295 if( prop[ "manualRun" ] == "false" ){
296 slackSend( channel:getSlackChannel(), color:"FF0000", message: "[" + prop[ "ONOSBranch" ] + "]"
297 + otherTestName + " : Failed!\n" + resultContents[ 1 ] + "\n"
298 + "[TestON log] : \n"
Devin Limd1fb8e92018-02-28 16:29:33 -0800299 + "https://jenkins.onosproject.org/blue/organizations/jenkins/${env.JOB_NAME}/detail/${env.JOB_NAME}/${env.BUILD_NUMBER}/pipeline"
Devin Lim61643762017-12-07 15:55:38 -0800300 + ( isSCPF ? "" : ( "\n[Result on Wiki] : \n" + "https://wiki.onosproject.org/display/ONOS/" + wikiLink.replaceAll( "\\s","+" ) ) )
301 + ( resultURL != "" ? ( "\n[Karaf log] : \n" + resultURL + "artifact/" ) : "" ),
302 teamDomain: 'onosproject' )
303 }
304 Failed
305 }
306 }
307}
Devin Lime89761a2018-03-16 17:52:57 -0700308def publishToConfluence( isManualRun, isPostResult, wikiLink, file ){
Devin Limf5175192018-05-14 19:13:22 -0700309 // publish HTML script to wiki confluence
310 // isManualRun : string "true" "false"
311 // isPostResult : string "true" "false"
312 // wikiLink : link of the wiki page to publish
313 // file : name of the file to be published
314
Devin Lime89761a2018-03-16 17:52:57 -0700315 if( isPostingResult( isManualRun, isPostResult ) ){
Devin Lim61643762017-12-07 15:55:38 -0800316 publishConfluence siteName: 'wiki.onosproject.org', pageName: wikiLink, spaceName: 'ONOS',
Devin Lim1253ae82018-02-26 11:13:36 -0800317 attachArchivedArtifacts: true, buildIfUnstable: true,
Devin Lim61643762017-12-07 15:55:38 -0800318 editorList: [
319 confluenceWritePage( confluenceFile( file ) )
320 ]
321 }
322
323}
324def runTest( testName, toBeRun, prop, pureTestName, graphOnly, testCategory, graph_generator_file, graph_saved_directory ) {
Devin Limf5175192018-05-14 19:13:22 -0700325 // run the test on the machine that contains all the steps : init and run test, copy files, publish result ...
326 // testName : name of the test
327 // toBeRun : boolean value whether the test will be run or not. If not, it won't be run but shows up with empty result on pipeline view
328 // prop : dictionary property on the machine
329 // pureTestName : Pure name of the test. ( ex. pureTestName of SCPFflowTpFobj will be SCPFflowTp )
330 // graphOnly : check if it is generating graph job. If so, it will only generate the generating graph part
331 // testCategory : category of the test ( SCPF, SR, FUNC ... )
332 // graph_generator_file : Rscript file with the full path.
333 // graph_saved_directory : where the generated graph will be saved to.
334
Devin Lim61643762017-12-07 15:55:38 -0800335 return {
336 catchError{
337 stage( testName ) {
338 if ( toBeRun ){
339 workSpace = "/var/jenkins/workspace/" + testName
340 def fileContents = ""
341 node( testMachine ){
342 withEnv( [ 'ONOSBranch=' + prop[ "ONOSBranch" ],
343 'ONOSJVMHeap=' + prop[ "ONOSJVMHeap" ],
344 'TestONBranch=' + prop[ "TestONBranch" ],
345 'ONOSTag=' + prop[ "ONOSTag" ],
346 'WikiPrefix=' + prop[ "WikiPrefix" ],
347 'WORKSPACE=' + workSpace ] ){
348 if( ! graphOnly ){
349 sh initAndRunTest( testName, testCategory )
350 // For the Wiki page
351 sh cleanAndCopyFiles( pureTestName )
352 }
353 databaseAndGraph( prop, testName, graphOnly, graph_generator_file, graph_saved_directory )
354 if( ! graphOnly ){
355 sh fetchLogs( pureTestName )
356 if( !isSCPF )
Devin Lime89761a2018-03-16 17:52:57 -0700357 publishToConfluence( prop[ "manualRun" ], prop[ "postResult" ],
358 testCategory[ testName ][ 'wiki_link' ],
359 workSpace + "/" + testCategory[ testName ][ 'wiki_file' ] )
Devin Lim61643762017-12-07 15:55:38 -0800360 }
361 }
362
363
364 }
365 postResult( prop, graphOnly )
366 if( ! graphOnly ){
367 resultURL = postLogs( testName, prop[ "WikiPrefix" ] )
368 analyzeResult( prop, workSpace, pureTestName, testName, resultURL, isSCPF ? "" : testCategory[ testName ][ 'wiki_link' ], isSCPF )
369 }
370 }
371 }
372 }
373 }
374}
Devin Lim61643762017-12-07 15:55:38 -0800375def databaseAndGraph( prop, testName, graphOnly, graph_generator_file, graph_saved_directory ){
Devin Limf5175192018-05-14 19:13:22 -0700376 // part where it insert the data into the database.
377 // It will use the predefined encrypted variables from the Jenkins.
378 // prop : property dictionary that was read from the machine
379 // testName : name of the test
380 // graphOnly : boolean whether it is graph only or not
381 // graph_generator_file : Rscript file with the full path.
382 // graph_saved_directory : where the generated graph will be saved to.
383
Devin Lim61643762017-12-07 15:55:38 -0800384 if( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
385 // Post Results
386 withCredentials( [
387 string( credentialsId: 'db_pass', variable: 'pass' ),
388 string( credentialsId: 'db_user', variable: 'user' ),
389 string( credentialsId: 'db_host', variable: 'host' ),
390 string( credentialsId: 'db_port', variable: 'port' ) ] ) {
391 def database_command = generalFuncs.database_command_create( pass, host, port, user ) + ( !isSCPF ? sqlCommand( testName ) : SCPFfunc.sqlCommand( testName ) )
392 sh '''#!/bin/bash
393 export DATE=\$(date +%F_%T)
394 cd ~
395 pwd ''' + ( graphOnly ? "" : ( !isSCPF ? databasePart( prop[ "WikiPrefix" ], testName, database_command ) :
396 SCPFfunc.databasePart( testName, database_command ) ) ) + '''
397 ''' + ( !isSCPF ? graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory, graph_generator_file ) : SCPFfunc.getGraphGeneratingCommand( host, port, user, pass, testName, prop ) )
398 }
399 }
400}
Devin Lim86e40532018-04-06 12:44:06 -0700401def generateCategoryStatsGraph( testMachineOn, manualRun, postresult, stat_file, pie_file, type, branch, testListPart, save_path, pieTestListPart ){
Devin Limf5175192018-05-14 19:13:22 -0700402 // function that will generate the category stat graphs for the overall test.
403 // testMachineOn : the machine the graph will be generated. It will be TestStation-VMs for the most cases
404 // manualRun : string of "true" or "false"
405 // postresult : string of "true" or "false"
406 // stat_file : file name with full path for Rscript for the stat graph
407 // pie_file : file name with full path for Rscript for the pie graph
408 // type : type of the test ( USECASE, FUNC, HA )
409 // branch : branch of the test ( master, onos-1.12, onos-1.13 )
410 // testListPart : list of the test to be included
411 // save_path : path that will save the graphs to
412 // pieTestListPart : list of the test for pie graph
Devin Lim61643762017-12-07 15:55:38 -0800413
414 if( isPostingResult( manualRun, postresult ) ){
Devin Lim86e40532018-04-06 12:44:06 -0700415 node( testMachineOn ){
Devin Lim61643762017-12-07 15:55:38 -0800416
417 withCredentials( [
418 string( credentialsId: 'db_pass', variable: 'pass' ),
419 string( credentialsId: 'db_user', variable: 'user' ),
420 string( credentialsId: 'db_host', variable: 'host' ),
421 string( credentialsId: 'db_port', variable: 'port' ) ] ) {
422 sh '''#!/bin/bash
Devin Limfe9a4cb2018-05-11 17:06:21 -0700423 ''' + generalFuncs.basicGraphPart( stat_file, host, port, user, pass, type, branch ) + " \"" + testListPart + "\" latest " + save_path + '''
424 ''' + getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'y', save_path ) + '''
425 ''' + getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'n', save_path )
Devin Lim61643762017-12-07 15:55:38 -0800426 }
427 }
428 postResult( [], true )
429 }
430}
431def makeTestList( list, commaNeeded ){
Devin Limf5175192018-05-14 19:13:22 -0700432 // make the list of the test in to a string.
433 // list : list of the test
434 // commaNeeded : if comma is needed for the string
435
Devin Lim61643762017-12-07 15:55:38 -0800436 return generalFuncs.getTestList( list ) + ( commaNeeded ? "," : "" )
437}
438def createStatsList( testCategory, list, semiNeeded ){
Devin Limf5175192018-05-14 19:13:22 -0700439 // make the list for stats
440 // testCategory : category of the test
441 // list : list of the test
442 // semiNeeded: if semi colon is needed
443
Devin Lim61643762017-12-07 15:55:38 -0800444 return testCategory + "-" + generalFuncs.getTestList( list ) + ( semiNeeded ? ";" : "" )
445}
446def generateOverallGraph( prop, testCategory, graph_saved_directory ){
Devin Limf5175192018-05-14 19:13:22 -0700447 // generate the overall graph for the test
Devin Lim61643762017-12-07 15:55:38 -0800448
449 if( isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
450 node( testMachine ){
451
452 withCredentials( [
453 string( credentialsId: 'db_pass', variable: 'pass' ),
454 string( credentialsId: 'db_user', variable: 'user' ),
455 string( credentialsId: 'db_host', variable: 'host' ),
456 string( credentialsId: 'db_port', variable: 'port' ) ] ) {
457 testList = generalFuncs.getTestList( testCategory )
458 sh '''#!/bin/bash
459 ''' + generalFuncs.basicGraphPart( trend_generator_file, host, port, user, pass, testType, prop[ "ONOSBranch" ] ) + " " + testList + " 20 " + graph_saved_directory
460 }
461 }
462 postResult( prop, false )
463 }
464}
465def getOverallPieGraph( file, host, port, user, pass, branch, type, testList, yOrN, path ){
Devin Limf5175192018-05-14 19:13:22 -0700466 // Rcommand for the pie graph
467
Devin Lim61643762017-12-07 15:55:38 -0800468 return generalFuncs.basicGraphPart( file, host, port, user, pass, type, branch ) + " \"" + testList + "\" latest " + yOrN + " " + path
469}
470def sqlCommand( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700471 // get the inserting sqlCommand for non-SCPF tests.
472
Devin Lim61643762017-12-07 15:55:38 -0800473 return "\"INSERT INTO " + table_name + " VALUES('\$DATE','" + result_name + "','" + testName + "',\$BUILD_NUMBER, '\$ONOSBranch', \$line);\" "
474}
475def graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory, graph_generator_file ){
Devin Limf5175192018-05-14 19:13:22 -0700476 // get the graphGenerating R command for non-SCPF tests
477
Devin Lim61643762017-12-07 15:55:38 -0800478 return generalFuncs.basicGraphPart( graph_generator_file, host, port, user, pass, testName, prop[ "ONOSBranch" ] ) + " 20 " + graph_saved_directory
479}
480def databasePart( wikiPrefix, testName, database_command ){
Devin Limf5175192018-05-14 19:13:22 -0700481 // to read and insert the data from .csv to the database
482
Devin Lim61643762017-12-07 15:55:38 -0800483 return '''
484 sed 1d ''' + workSpace + "/" + wikiPrefix + "-" + testName + '''.csv | while read line
485 do
486 echo \$line
487 echo ''' + database_command + '''
488 done '''
489}
Devin Lim86e40532018-04-06 12:44:06 -0700490def generateStatGraph( testMachineOn, onos_branch, AllTheTests, stat_graph_generator_file, pie_graph_generator_file, graph_saved_directory ){
Devin Limf5175192018-05-14 19:13:22 -0700491 // Will generate the stats graph.
492
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800493 testListPart = createStatsList( "FUNC", AllTheTests[ "FUNC" ], true ) +
494 createStatsList( "HA", AllTheTests[ "HA" ], true ) +
495 createStatsList( "USECASE", AllTheTests[ "USECASE" ], false )
496 pieTestList = makeTestList( AllTheTests[ "FUNC" ], true ) +
497 makeTestList( AllTheTests[ "HA" ], true ) +
498 makeTestList( AllTheTests[ "USECASE" ], false )
Devin Lim86e40532018-04-06 12:44:06 -0700499 generateCategoryStatsGraph( testMachineOn, "false", "true", stat_graph_generator_file, pie_graph_generator_file, "ALL", onos_branch, testListPart, graph_saved_directory, pieTestList )
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800500}
Jeremy Ronquillof78a6ca2018-03-12 09:20:57 -0700501def branchWithPrefix( branch ){
Devin Limf5175192018-05-14 19:13:22 -0700502 // get the branch with the prefix ( "onos-" )
Jeremy Ronquillof78a6ca2018-03-12 09:20:57 -0700503 return ( ( branch != "master" ) ? "onos-" : "" ) + branch
504}
Devin Lim1253ae82018-02-26 11:13:36 -0800505return this;