blob: 119b4276caea9be9816eca5f710524cda4fd96ae [file] [log] [blame]
#!groovy
funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
fileRelated.init()
current_version = "master"
previous_version = "1.13"
before_previous_version = "1.12"
funcs.initializeTrend( "VM" );
triggerFuncs.init( funcs )
wikiContents = ""
testcases = [
"FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
"HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
"SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
"SR" : [ tests : "", nodeName : "Fabric", wikiContent : "" ],
"USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
]
Prefix_organizer = [
"FU" : "FUNC",
"HA" : "HA",
"PL" : "USECASE",
"SA" : "USECASE",
"SC" : "SCPF",
"SR" : "SR",
"US" : "USECASE",
"VP" : "USECASE"
]
manually_run = params.manual_run
onos_b = current_version
test_branch = ""
onos_tag = params.ONOSTag
isOldFlow = true
// Set tests based on day of week
def now = funcs.getCurrentTime()
print now.toString()
today = now[ Calendar.DAY_OF_WEEK ]
if ( manually_run ){
onos_b = params.ONOSVersion
} else {
if ( today == Calendar.SATURDAY ){
onos_b = previous_version
} else if( today == Calendar.SUNDAY ){
onos_b = before_previous_version
}
}
AllTheTests = test_lists.getAllTheTests( onos_b )
day = ""
SCPF_choices = ""
USECASE_choices = ""
FUNC_choices = ""
HA_choices = ""
SR_choices = ""
stat_graph_generator_file = fileRelated.histogramMultiple
pie_graph_generator_file = fileRelated.pieMultiple
graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/"
post_result = params.PostResult
if( !manually_run ){
testDivider( today )
FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices )
HA_choices = triggerFuncs.lastCommaRemover( HA_choices )
SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices )
USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices )
SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
}
if ( manually_run ){
testcases = triggerFuncs.organize_tests( params.Tests, testcases )
isOldFlow = params.isOldFlow
println "Tests to be run manually : "
}else{
testcases[ "SCPF" ][ "tests" ] = SCPF_choices
testcases[ "USECASE" ][ "tests" ] = USECASE_choices
testcases[ "FUNC" ][ "tests" ] = FUNC_choices
testcases[ "HA" ][ "tests" ] = HA_choices
testcases[ "SR" ][ "tests" ] = SR_choices
println "Defaulting to " + day + " tests:"
}
triggerFuncs.print_tests( testcases )
def runTest = [
"VM" : [:],
"BM" : [:]
]
for( String test in testcases.keySet() ){
println test
if ( testcases[ test ][ "tests" ] != "" ){
runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs.trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test, manually_run, onos_tag )
}
}
def finalList = [:]
jobName = env.JOB_NAME
finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] )
finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] )
//parallel finalList
if( jobName.take( 2 ) == "vm" )
finalList[ "VM" ].call()
else
finalList[ "BM" ].call()
if ( !manually_run ){
funcs.generateStatGraph( "TestStation-VMs",
funcs.branchWithPrefix( onos_b ),
AllTheTests,
stat_graph_generator_file,
pie_graph_generator_file,
graph_saved_directory )
}
def testDivider( today ){
switch ( today ) {
case Calendar.MONDAY:
initHtmlForWiki()
monday( true )
tuesday( true, false )
wednesday( true, false )
thursday( true, false )
friday( true, false )
saturday( false, false )
sunday( false, false )
day = "Monday"
closeHtmlForWiki()
postToWiki( wikiContents )
slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + triggerFuncs.printDaysForTest( AllTheTests ) )
break
case Calendar.TUESDAY:
tuesday( false, true )
day = "Tuesday"
break
case Calendar.WEDNESDAY:
wednesday( false, true )
day = "Wednesday"
break
case Calendar.THURSDAY:
thursday( false, true )
day = "Thursday"
break
case Calendar.FRIDAY:
friday( false, true )
day = "Friday"
break
case Calendar.SATURDAY:
saturday( false, true )
day = "Saturday"
break
case Calendar.SUNDAY:
sunday( false , true )
day = "Sunday"
break
}
}
def monday( getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", true, "M", getResult )
HA_choices += adder( "HA", "extra_A", true, "M", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", true, "M", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
closingHeader( "USECASE" )
}
def tuesday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "T", getResult )
HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "T", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
closingHeader( "USECASE" )
}
def wednesday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "W", getResult )
HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "W", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
closingHeader( "USECASE" )
}
def thursday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "Th", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
closingHeader( "USECASE" )
}
def friday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "F", getResult )
HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "F", false )
SR_choices += adder( "SR", "extra_A", getDay, "F", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
closingHeader( "USECASE" )
}
def saturday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult )
FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult )
FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "Sa", getResult )
HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult )
HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult )
SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult )
SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult )
SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult )
SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "Sa", false )
SR_choices += adder( "SR", "extra_B", getDay, "Sa", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult )
closingHeader( "USECASE" )
}
def sunday( getDay, getResult ){
addingHeader( "FUNC" )
FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult )
FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult )
FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult )
closingHeader( "FUNC" )
addingHeader( "HA" )
HA_choices += adder( "HA", "basic", getDay, "S", getResult )
HA_choices += adder( "HA", "extra_A", getDay, "S", getResult )
HA_choices += adder( "HA", "extra_B", getDay, "S", getResult )
closingHeader( "HA" )
addingHeader( "SCPF" )
SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult )
SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult )
SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult )
SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult )
SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult )
closingHeader( "SCPF" )
addingHeader( "SR" )
SR_choices += adder( "SR", "basic", getDay, "S", false )
closingHeader( "SR" )
addingHeader( "USECASE" )
USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult )
closingHeader( "USECASE" )
}
def adder( testCat, set, dayAdding, day, getResult ){
result = ""
for( String test in AllTheTests[ testCat ].keySet() ){
if( AllTheTests[ testCat ][ test ][ set ] ){
if( getResult )
result += test + ","
if( dayAdding )
dayAdder( testCat, test, day )
makeHtmlColList( testCat, test )
}
}
return result
}
def initHtmlForWiki(){
wikiContents = '''
<table class="wrapped confluenceTable">
<colgroup>
<col />
<col />
<col />
<col />
<col />
<col />
</colgroup>
<tbody>
<tr>
<th colspan="1" class="confluenceTh">
<br />
</th>
<th class="confluenceTh"><p>Monday</p></th>
<th class="confluenceTh"><p>Tuesday</p></th>
<th class="confluenceTh"><p>Wednesday</p></th>
<th class="confluenceTh"><p>Thursday</p></th>
<th class="confluenceTh"><p>Friday</p></th>
<th class="confluenceTh"><p>Saturday</p></th>
<th class="confluenceTh"><p>Sunday</p></th>
</tr>'''
for( String test in testcases.keySet() ){
testcases[ test ][ 'wikiContent' ] = '''
<tr>
<th colspan="1" class="confluenceTh">''' + test + '''</th>'''
}
}
def addingHeader( testCategory ){
testcases[ testCategory ][ 'wikiContent' ] += '''
<td class="confluenceTd">
<ul>'''
}
def makeHtmlColList( testCategory, testName ){
testcases[ testCategory ][ 'wikiContent' ] += '''
<li>'''+ testName +'''</li>'''
}
def closingHeader( testCategory ){
testcases[ testCategory ][ 'wikiContent' ] += '''
</ul>
</td>'''
}
def closeHtmlForWiki(){
for( String test in testcases.keySet() ){
wikiContents += testcases[ test ][ 'wikiContent' ]
wikiContents += '''
</tr>'''
}
wikiContents += '''
</tbody>
</table>
<p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p>
<p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p>
<p>On <strong>Saturdays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( previous_version ) +''' branch.</p>
<p>On <strong>Sundays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( before_previous_version ) +''' branch.</p>'''
}
def postToWiki( contents ){
node( testMachine ){
workspace = fileRelated.jenkinsWorkspace + "all-pipeline-trigger/"
filename = "jenkinsSchedule.txt"
writeFile file: workspace + filename, text: contents
funcs.publishToConfluence( "false", "true",
"Automated Test Schedule",
workspace + filename )
}
}
def dayAdder( testCat, testName, dayOfWeek ){
AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
}