Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vars/functionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
*
* config['ftest_arg'] Functional test launch.py arguments.
* Default determined by parseStageInfo().
*
* config['details_stash'] Stash name for functional test details.
*/

Map call(Map config = [:]) {
Expand Down Expand Up @@ -113,6 +115,8 @@ Map call(Map config = [:]) {
run_test_config['ftest_arg'] = config.get('ftest_arg', stage_info['ftest_arg'])
run_test_config['context'] = context
run_test_config['description'] = description
run_test_config['details_stash'] = config.get(
'details_stash', 'func' + stage_info['pragma_suffix'] + '-details')

String script = 'if ! pip3 install'
script += ''' --upgrade --upgrade-strategy only-if-needed launchable; then
Expand Down
4 changes: 3 additions & 1 deletion vars/getFunctionalTestStage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Map call(Map kwargs = [:]) {
Boolean run_if_pr = kwargs.get('run_if_pr', false)
Boolean run_if_landing = kwargs.get('run_if_landing', false)
Map job_status = kwargs.get('job_status', [:])
String details_stash = kwargs.get('details_stash', '')

return {
stage("${name}") {
Expand Down Expand Up @@ -89,7 +90,8 @@ Map call(Map kwargs = [:]) {
nvme: nvme,
default_nvme: default_nvme,
provider: provider)['ftest_arg'],
test_function: 'runTestFunctionalV2'))
test_function: 'runTestFunctionalV2',
details_stash: details_stash))
} finally {
println("[${name}] Running functionalTestPostV2()")
functionalTestPostV2()
Expand Down
56 changes: 56 additions & 0 deletions vars/getSummaryStage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// vars/getSummaryStage.groovy

/**
* getSummaryStage.groovy
*
* Get a functional test stage in scripted syntax.
*
* @param kwargs Map containing the following optional arguments (empty strings yield defaults):
* name name of the stage
* docker_filename docker filename
* script_stashes list of stash names to access with runScriptWithStashes
* script_name shell script to run with runScriptWithStashes
* script_label label to use when running the script in runScriptWithStashes
* artifacts artifacts to archive
* job_status Map of status for each stage in the job/build
* @return a scripted stage to run in a pipeline
*/

List call(Map kwargs = [:]) {
String name = kwargs.get('name', 'Unknown Summary Stage')
String docker_filename = kwargs.get('docker_filename', 'utils/docker/Dockerfile.el.8')
List script_stashes = kwargs.get('script_stashes', [])
String script_name = kwargs.get('script_name', 'ci/functional_test_summary.sh')
String script_label = kwargs.get('script_label', 'Generate Functional Test Summary')
String artifacts = kwargs.get('artifacts', 'unknown_test_summary/*')
Map job_status = kwargs.get('job_status', [:])

return {
stage("${name}") {
agent {
dockerfile {
filename docker_filename
label 'docker_runner'
additionalBuildArgs dockerBuildArgs(add_repos: false)
}
try {
job_step_update(
job_status,
name,
runScriptWithStashes(
stashes: script_stashes,
script: script_name,
label: script_label
)
)
}
finally {
always {
archiveArtifacts(artifacts: artifacts, allowEmptyArchive: false)
job_status_update(job_status, name)
}
}
}
}
}
}
76 changes: 76 additions & 0 deletions vars/runScriptWithStashes.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// vars/runScriptWithStashes.groovy

/**
* // vars/runScriptWithStashes.groovy
*
* Run a shell script with access to specified stashes.
*
* @param kwargs Map containing the following optional arguments (empty strings yield defaults):
* stashes list of stash names to access during script execution
* script shell script to run
* label label to use when running the script
*/
Map call(Map kwargs = [:]) {
Date startDate = new Date()
List stashes = kwargs.get('stashes', [])
String script = kwargs.get('script', '')
String label = kwargs.get('label', "Run ${script} with stashes")

Integer stash_count = 0
stashes.each { stash ->
try {
unstash stash
println("Successfully unstashed ${stash}.")
stash_count++
/* groovylint-disable-next-line CatchException */
} catch (Exception ex) {
println("Ignoring failure to unstash ${stash}. Perhaps the stage was skipped?")
}
}

Integer return_code = 255
if (!script) {
// Nothing to do if no stash exist
println('No script provided, skipping execution')
return_code = 0
} else if (stash_count < 1) {
// Nothing to do if no stash exist
println('No code coverage stashes found, skipping merged code coverage report')
return_code = 0
} else {
// Run the script
try {
sh(script: script, label: label)
return_code = 0
} catch (hudson.AbortException e) {
// groovylint-disable UnnecessaryGetter
// groovylint-disable-next-line NoDef, VariableTypeRequired
def rc_val = (e.getMessage() =~ /\d+$/)
if (rc_val) {
return_code = rc_val[0] as Integer
}
}
}

// Generate a result for the stage
Date endDate = new Date()
Integer runTime = durationSeconds(startDate, endDate)
String status = 'SUCCESS'
if (return_code != 0) {
status = 'FAILURE'
}
Map results = ['result_code': return_code,
'result': status,
'start_date': startDate,
'end_date': endDate,
'runtest_time': runTime]

String results_map = 'results_map_' + sanitizedStageName()
writeYaml file: results_map,
data: results,
overwrite: true
stash name: results_map,
includes: results_map

return results
}
7 changes: 7 additions & 0 deletions vars/runTestFunctionalV2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,12 @@ Map call(Map config = [:]) {
String name = 'func' + stage_info['pragma_suffix'] + '-cov'
stash name: config.get('coverage_stash', name),
includes: covfile

if (config['details_stash']) {
// Stash the launch.py generated details.json for the functional test stage
stash name: config['details_stash'],
includes: '**/details.json'
}

return runData
}