blob: 22ad46f389eaad358a1e7218599b9d4071e5a706 [file] [log] [blame]
Devin Lim90803a82017-08-29 13:41:44 -07001#!groovy
2// This is a Jenkinsfile for a scripted pipeline for the SCPF tests
3// properties([pipelineTriggers([cron('30 19 * * *')])])
4
5// TODO: Exception handling around steps
6
7none = [ "" ]
8batches = [1,100,1000]
9neighbors = ['y', 'n']
10SCPF = [
11 SCPFcbench: [ test:'SCPFcbench', table:'cbench_bm_tests', results:'cbench_bm_results', file:'CbenchDB', rFile:'SCPFcbench.R', extra:none, finalResult:1, graphTitle:['Cbench Test'], dbCols:'avg', dbWhere:'', y_axis:'Throughput (Responses/sec)'],
12 SCPFhostLat: [ test:'SCPFhostLat', table:'host_latency_tests', results:'host_latency_results', file:'HostAddLatency', rFile:'SCPFhostLat.R', extra:none,finalResult:1, graphTitle:['Host Latency Test'], dbCols:'avg', dbWhere:'AND scale=5', y_axis:'Latency (ms)'],
13 SCPFportLat: [ test:'SCPFportLat', table:'port_latency_details', results:'port_latency_results', file:'/tmp/portEventResultDb', rFile:'SCPFportLat.R', extra:none, finalResult:1, graphTitle:['Port Latency Test - Port Up','Port Latency Test - Port Down'], dbCols:[ 'up_ofp_to_dev_avg,up_dev_to_link_avg,up_link_to_graph_avg', 'down_ofp_to_dev_avg,down_dev_to_link_avg,down_link_to_graph_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ],
14 SCPFflowTp1g: [ test:'SCPFflowTp1g --params TEST/flows:12250', table:'flow_tp_tests', results:'flow_tp_results', file:'flowTP1gDB', rFile:'SCPFflowTp1g.R n', extra:neighbors,finalResult:1, graphTitle:['Flow Througphput Test - neighbors=0','Flow Througphput Test - neighbors=4'], dbCols:'avg', dbWhere:[ 'AND scale=5 AND neighbors=0 ','AND scale=5 AND NOT neighbors=0' ], y_axis:'Throughput (,000 Flows/sec)' ],
15 SCPFflowTp1gWithFlowObj: [ test:'SCPFflowTp1g --params TEST/flowObj:True', table:'flow_tp_fobj_tests', results:'flow_tp_fobj_results', file:'flowTP1gDBFlowObj', rFile:'SCPFflowTp1g.R y', extra:neighbors, finalResult:0],
16 SCPFscaleTopo: [ test:'SCPFscaleTopo', table:'scale_topo_latency_details', results:'scale_topo_latency_results', file:'/tmp/scaleTopoResultDb', rFile:'SCPFscaleTopo.R', extra:none, finalResult:1, graphTitle:['Scale Topology Test'], dbCols:[ 'first_connection_to_last_connection, last_connection_to_last_role_request, last_role_request_to_last_topology' ], dbWhere:'AND scale=20' , y_axis:'Latency (s)'],
17 SCPFswitchLat: [ test:'SCPFswitchLat', table:'switch_latency_details', results:'switch_latency_results', file:'/tmp/switchEventResultDb', rFile:'SCPFswitchLat.R', extra:none, finalResult:1, graphTitle:['Switch Latency Test - Switch Up','Switch Latency Test - Switch Down'], dbCols:[ 'tcp_to_feature_reply_avg,feature_reply_to_role_request_avg,role_request_to_role_reply_avg,role_reply_to_device_avg,up_device_to_graph_avg', 'fin_ack_to_ack_avg,ack_to_device_avg,down_device_to_graph_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ],
18 SCPFbatchFlowResp: [ test:'SCPFbatchFlowResp', table:'batch_flow_tests', results:'batch_flow_results', file:'SCPFbatchFlowRespData', rFile:'SCPFbatchFlowResp.R', extra:none, finalResult:1, graphTitle:['Batch Flow Test - Elapsepost', 'Batch Flow Test - Elapsedel'], dbCols:[ 'elapsepost, posttoconfrm', 'elapsedel, deltoconfrm' ], dbWhere:'', y_axis:'Latency (ms)'],
19 SCPFintentEventTp: [ test:'SCPFintentEventTp', table:'intent_tp_tests', results:'intent_tp_results', file:'IntentEventTPDB', rFile:'SCPFintentEventTp.R n', extra:neighbors, finalResult:1, graphTitle:['Intent Throughput Test - neighbors=0','Intent Throughput Test - neighbors=4'], dbCols:'avg', dbWhere:[ 'AND scale=5 AND neighbors=0 ','AND scale=5 AND NOT neighbors=0' ], y_axis:'Throughput (Ops/sec)'],
20 SCPFintentRerouteLat: [ test:'SCPFintentRerouteLat', table:'intent_reroute_latency_tests', results:'intent_reroute_latency_results', file:'IntentRerouteLatDB', rFile:'SCPFIntentInstallWithdrawRerouteLat.R n', extra:batches, finalResult:1, graphTitle:['Intent Reroute Test'], dbCols:'avg', dbWhere:'AND scale=5 AND batch_size=100', y_axis:'Latency (ms)'],
21 SCPFscalingMaxIntents: [ test:'SCPFscalingMaxIntents', table:'max_intents_tests', results:'max_intents_results', file:'ScalingMaxIntentDB', rFile:'SCPFscalingMaxIntents.R n', extra:none, finalResult:0],
22 SCPFintentEventTpWithFlowObj: [ test:'SCPFintentEventTp --params TEST/flowObj:True', table:'intent_tp_fobj_tests', results:'intent_tp_fobj_results', file:'IntentEventTPflowObjDB', rFile:'SCPFintentEventTp.R y', extra:neighbors,finalResult:0],
23 SCPFintentInstallWithdrawLat: [ test:'SCPFintentInstallWithdrawLat', table:'intent_latency_tests', results:'intent_latency_results', file:'IntentInstallWithdrawLatDB', rFile:'SCPFIntentInstallWithdrawRerouteLat.R n', extra:batches,finalResult:1, graphTitle:['Intent Installation Test','Intent Withdrawal Test'], dbCols:[ 'install_avg','withdraw_avg' ], dbWhere:'AND scale=5 AND batch_size=100', y_axis:'Latency (ms)'],
24 SCPFintentRerouteLatWithFlowObj: [ test:'SCPFintentRerouteLat --params TEST/flowObj:True', table:'intent_reroute_latency_fobj_tests', results:'intent_reroute_latency_fobj_results', file:'IntentRerouteLatDBWithFlowObj', rFile:'SCPFIntentInstallWithdrawRerouteLat.R y', extra:batches, finalResult:0],
25 SCPFscalingMaxIntentsWithFlowObj: [ test:'SCPFscalingMaxIntents --params TEST/flowObj:True', table:'max_intents_fobj_tests', results:'max_intents_fobj_results', file:'ScalingMaxIntentDBWFO', rFile:'SCPFscalingMaxIntents.R y', extra:none, finalResult:0],
26 SCPFintentInstallWithdrawLatWithFlowObj: [ test:'SCPFintentInstallWithdrawLat --params TEST/flowObj:True', table:'intent_latency_fobj_tests', results:'intent_latency_fobj_results', file:'IntentInstallWithdrawLatDBWFO', rFile:'SCPFIntentInstallWithdrawRerouteLat.R y', extra:batches, finalResult:0],
27 SCPFmastershipFailoverLat: [test:'SCPFmastershipFailoverLat', table:'mastership_failover_tests', results:'mastership_failover_results', file:'mastershipFailoverLatDB', rFile:'SCPFmastershipFailoverLat.R', extra:none, finalResult:1, graphTitle:['Mastership Failover Test'], dbCols:[ 'kill_deact_avg,deact_role_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ]
28]
29
30echo("Testcases:")
31graph_generator_directory = "~/OnosSystemTest/TestON/JenkinsFile/SCPF/"
32graph_saved_directory = "/var/jenkins/workspace/Pipeline_postjob_BM/"
33def testsToRun = null
34def prop = null
35node("TestStation-BMs"){
36 prop = readProperties(file:'/var/jenkins/TestONOS.property') // TODO set defaults
37 testsToRun = prop["Tests"].tokenize("\n;, ")
38 for ( String test : testsToRun ) {
39 println test
40 }
41}
42
43def tests = [:]
44for( String test : SCPF.keySet() ){
45 toBeRun = testsToRun.contains( test )
46 def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
47 tests[stepName] = SCPFTest(test, toBeRun, prop)
48}
49
50// run the tests
51for ( test in tests.keySet() ){
52 tests[test].call()
53}
54
55// The testName should be the key from the SCPF map
56def SCPFTest( testName, toBeRun, prop ) {
57 return {
58 catchError{
59 stage(testName) {
60 if ( toBeRun ){
61 workSpace = "/var/jenkins/workspace/"+testName
62 node("TestStation-BMs"){
63 withEnv(['ONOSBranch='+prop["ONOSBranch"],
64 'ONOSJVMHeap='+prop["ONOSJVMHeap"],
65 'TestONBranch='+prop["TestONBranch"],
66 'ONOSTag='+prop["ONOSTag"],
67 'WikiPrefix='+prop["WikiPrefix"],
68 'WORKSPACE='+workSpace]){
69 sh '''#!/bin/bash -l
70 set -i # interactive
71 shopt -s expand_aliases # expand alias in non-interactive mode
72 export PYTHONUNBUFFERED=1
73
74 ifconfig
75
76 echo "ONOS Branch is: $ONOSBranch"
77 echo "TestON Branch is: $TestONBranch"
78 echo "Test date: "
79 date
80
81 cd ~
82 export PATH=$PATH:onos/tools/test/bin
83
84 timeout 240 stc shutdown | head -100
85 timeout 240 stc teardown | head -100
86 timeout 240 stc shutdown | head -100
87
88 cd ~/OnosSystemTest/TestON/bin
89 git log |head
90 ./cleanup.sh
91 ''' + "./cli.py run " + SCPF[testName]['test']
92
93 // For moving results
94 sh '''#!/bin/bash -i
95 # remove any leftover files from previous tests
96 sudo rm ${WORKSPACE}/*Result.txt
97
98 #copy files to workspace
99 cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
100 sudo cp *Result.txt ${WORKSPACE}/
101 cd ${WORKSPACE}/
102 ls -al
103 cd '''
104 // Post Results
105 withCredentials([
106 string(credentialsId: 'db_pass', variable: 'pass'),
107 string(credentialsId: 'db_user', variable: 'user'),
108 string(credentialsId: 'db_host', variable: 'host'),
109 string(credentialsId: 'db_port', variable: 'port')]) {
110 def database_command = pass + "|psql --host=" + host + " --port=" + port + " --username=" + user + " --password --dbname onostest -c \"INSERT INTO " + SCPF[testName]['table'] + " VALUES('\$DATE','" + SCPF[testName]['results'] + "','\$BUILD_NUMBER', '\$ONOSBranch', \$line);\""
111 if (testName == "SCPFscaleTopo" || testName == "SCPFswitchLat" || testName == "SCPFportLat") {
112 database_command = pass + "|psql --host=" + host + " --port=" + port + " --username=" + user + " --password --dbname onostest -c \"INSERT INTO " + SCPF[testName]['table'] + " VALUES('\$DATE','" + SCPF[testName]['results'] + "','\$BUILD_NUMBER', \$line, '\$ONOSBranch');\""
113 }
114 sh '''#!/bin/bash
115
116 export DATE=\$(date +%F_%T)
117 cd ~
118 pwd
119 cd /tmp
120 while read line
121 do
122
123 echo \$line
124 echo ''' + database_command + '''
125
126 done< ''' + SCPF[testName]['file'] + '''
127 ''' + getGraphCommand( SCPF[testName]['rFile'], SCPF[testName]['extra'], host, port, user, pass, testName, prop["ONOSBranch"] ) + '''
128 ''' + ( SCPF[testName]['finalResult'] ? generateCombinedResultGraph( host,port, user, pass, testName, prop["ONOSBranch"] ) : "" )
129 }
130 // Fetch Logs
131 sh '''#!/bin/bash
132
133 cd ~/OnosSystemTest/TestON/logs
134 echo "Job Name is: ${JOB_NAME}"
135 TestONlogDir=$(ls -t | grep ${TEST_NAME}_ |head -1)
136 echo "########################################################################################"
137 echo "##### copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}"
138 echo "########################################################################################"
139 cd $TestONlogDir
140 if [ $? -eq 1 ]
141 then
142 echo "Job name does not match any test suite name to move log!"
143 else
144 pwd
145 for i in $OC{1..7}; do onos-fetch-logs $i || echo log does not exist; done
146 fi'''
147 }
148 }
149 if( prop["postResult"] == "true" ){
150 def post = build job: "Pipeline_postjob_BM", propagate: false
151 }
152 node("TestStation-BMs"){
153 sh '''#!/bin/bash
154
155 if [ -e ''' + workSpace + "/" + testName + "Result.txt ] && grep -q \"1\" " + workSpace + "/" + testName + "Result.txt" + '''
156 then
157 echo ''' + testName + " : All passed." + '''
158 else
159 echo ''' + testName + " : not all passed." + '''
160 DoingThisToSetTheResultFalse
161 fi'''
162 }
163 }
164 }
165 }
166 }
167}
168def getGraphCommand( rFileName, extras, host, port, user, pass, testName, branchName ){
169 result = ""
170 for( extra in extras ){
171 result += generateGraph( rFileName, " " + extra, host, port, user, pass, testName, branchName ) + ";"
172 }
173 return result
174}
175def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName){
176 return "Rscript " + graph_generator_directory + rFileName + " " + host + " " + port + " " + user + " " + pass + " " + testName + " " + branchName + " " + batch + " " + graph_saved_directory
177}
178def generateCombinedResultGraph( host, port, user, pass, testName, branchName ){
179 result = ""
180 for ( int i=0; i< SCPF[testName]['graphTitle'].size(); i++){
181 result += "Rscript " + graph_generator_directory + "SCPFLineGraph.R " + host + " " + port + " " + user + " " + pass + " \"" + SCPF[testName]['graphTitle'][i] + "\" " + branchName + " " + 100 + " \"SELECT " +
182 checkIfList( testName, 'dbCols', i ) + " FROM " + SCPF[testName]['table'] + " WHERE branch=\'" + branchName + "\' " + checkIfList( testName, 'dbWhere', i ) +
183 " ORDER BY date ASC LIMIT 100\" \"" + SCPF[testName]['y_axis'] + "\" " + graph_saved_directory + ";"
184 }
185 return result
186}
187def checkIfList( testName, forWhich, pos ){
188 return SCPF[testName][forWhich] instanceof List ? SCPF[testName][forWhich][pos] : SCPF[testName][forWhich]
189}