diff --git a/vars/functionalTest.groovy b/vars/functionalTest.groovy index aa7b949d3..e50f9508a 100755 --- a/vars/functionalTest.groovy +++ b/vars/functionalTest.groovy @@ -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 = [:]) { @@ -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 diff --git a/vars/getFunctionalTestStage.groovy b/vars/getFunctionalTestStage.groovy index 47055feef..839b28a31 100644 --- a/vars/getFunctionalTestStage.groovy +++ b/vars/getFunctionalTestStage.groovy @@ -23,6 +23,7 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.Utils * run_if_pr whether or not the stage should run for PR builds * run_if_landing whether or not the stage should run for landing builds * job_status Map of status for each stage in the job/build + * details_stash Stash name for functional test details. * @return a scripted stage to run in a pipeline */ Map call(Map kwargs = [:]) { @@ -42,6 +43,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}") { @@ -89,7 +91,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() diff --git a/vars/getSummaryStage.groovy b/vars/getSummaryStage.groovy new file mode 100644 index 000000000..fba3ce58c --- /dev/null +++ b/vars/getSummaryStage.groovy @@ -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) + } + } + } + } + } +} diff --git a/vars/runTest.groovy b/vars/runTest.groovy index 91b590b65..24b9668e5 100644 --- a/vars/runTest.groovy +++ b/vars/runTest.groovy @@ -38,6 +38,8 @@ Map call(Map config = [:]) { * * config['description'] Description to report for SCM status. * Default env.STAGE_NAME. + * + * config['details_stash'] Stash name for functional test details. */ // Todo @@ -140,6 +142,12 @@ Map call(Map config = [:]) { Date endDate = new Date() int runTime = durationSeconds(startDate, endDate) + if (config['details_stash']) { + // Stash the launch.py generated details.json for the functional test stage + stash name: config['details_stash'], + includes: '**/details.json' + } + // We need to pass the rc to the post step. Map results = ['result_code': rc, 'result': status, diff --git a/vars/runTestFunctionalV2.groovy b/vars/runTestFunctionalV2.groovy index 3acfb43bf..3818952e4 100644 --- a/vars/runTestFunctionalV2.groovy +++ b/vars/runTestFunctionalV2.groovy @@ -39,6 +39,8 @@ Map call(Map config = [:]) { * * config['description'] Description to report for SCM status. * Default env.STAGE_NAME. + * + * config['details_stash'] Stash name for functional test details. */ Map stage_info = parseStageInfo(config) @@ -97,5 +99,6 @@ Map call(Map config = [:]) { String name = 'func' + stage_info['pragma_suffix'] + '-cov' stash name: config.get('coverage_stash', name), includes: covfile + return runData }