From e35cb99bc34cc64959d383d682b0e43a5e40aef2 Mon Sep 17 00:00:00 2001 From: mnokka-unikie Date: Tue, 3 Dec 2024 12:25:16 +0200 Subject: [PATCH] Introduce back slacking of failed hw tests Signed-off-by: mnokka-unikie --- ghaf-main-pipeline.groovy | 14 +++++++++++--- utils.groovy | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ghaf-main-pipeline.groovy b/ghaf-main-pipeline.groovy index 36fd672..13b6234 100644 --- a/ghaf-main-pipeline.groovy +++ b/ghaf-main-pipeline.groovy @@ -17,7 +17,7 @@ properties([ // Record failed target(s) def failedTargets = [] - +def failedHWTests = [] def target_jobs = [:] //////////////////////////////////////////////////////////////////////////////// @@ -114,7 +114,7 @@ pipeline { dir(WORKDIR) { script { utils.nix_eval_jobs(targets) - target_jobs = utils.create_parallel_stages(targets,false,failedTargets) + target_jobs = utils.create_parallel_stages(targets,false,failedTargets,failedHWTests) } } } @@ -136,10 +136,16 @@ pipeline { servername = sh(script: 'uname -n', returnStdout: true).trim() echo "Server name:$servername" def formattedFailedMessage = "" + def formattedHWFailedTests = "" + def line5="" + def line6="" if (failedTargets) { formattedFailedMessage = failedTargets.collect { "- ${it.trim()}" }.join("\n") } else { formattedFailedMessage = "No failed build targets" + formattedHWFailedMessage = failedHWTests.collect { "- ${it.trim()}" }.join("\n") + line5="\n*Failed HW test targets:*".stripIndent() + line6="\n${formattedHWFailedMessage}".stripIndent() } if (servername=="ghaf-jenkins-controller-prod") { serverchannel="ghaf-build" // prod main build failures channel @@ -152,7 +158,9 @@ pipeline { ${line1} ${line2} ${line3} - ${line4}""".stripIndent() + ${line4} + ${line5} + ${line6}""".stripIndent() slackSend ( channel: "$serverchannel", color: "danger", diff --git a/utils.groovy b/utils.groovy index 5b580dd..b9a2346 100644 --- a/utils.groovy +++ b/utils.groovy @@ -233,7 +233,8 @@ def ghaf_hw_test(String flakeref, String device_config, String testset='_boot_') // Add a link to failed test job(s) on the calling pipeline def test_href = "⛔ ${flakeref_trimmed}" currentBuild.description = "${currentBuild.description}
${test_href}" - return + return flakeref + } // Copy test results from agent to controller to 'test-results' directory copyArtifacts( @@ -243,6 +244,7 @@ def ghaf_hw_test(String flakeref, String device_config, String testset='_boot_') ) // Archive the test results archive_artifacts("ghaf-hw-test", flakeref_trimmed) + return null } def nix_eval_jobs(List targets) { @@ -301,9 +303,7 @@ def nix_eval_hydrajobs(List targets) { } } - -// , List failedTargets = [] -def create_parallel_stages(List targets, Boolean skip_hw_test=false, List failedTargets = null) { +def create_parallel_stages(List targets, Boolean skip_hw_test=false, List failedTargets = null, List failedHWTests =null) { def target_jobs = [:] targets.each { def timestampBegin = "" @@ -311,7 +311,6 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false, List f def displayName = "${it.target} (${it.system})" def targetAttr = "${it.system}.${it.target}" def scsdir = "scs/${targetAttr}/scs" - def target = "${it.target}" target_jobs[displayName] = { stage("Build ${displayName}") { def opts = "" @@ -323,7 +322,7 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false, List f try { if (it.error) { error("Error in evaluation! ${it.error}") - } + } timestampBegin = sh(script: "date +%s", returnStdout: true).trim() sh "nix build -L ${it.drvPath}\\^* ${opts}" timestampEnd = sh(script: "date +%s", returnStdout: true).trim() @@ -340,7 +339,7 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false, List f unstable("FAILED: ${displayName}") currentBuild.result = "FAILURE" if (failedTargets != null) { - failedTargets.add(target) + failedTargets.add(targetAttr) } println "Error: ${e.toString()}" } @@ -422,7 +421,15 @@ def create_parallel_stages(List targets, Boolean skip_hw_test=false, List f if (!skip_hw_test && it.hwtest_device != null) { stage("Test ${displayName}") { script { - ghaf_hw_test(targetAttr, it.hwtest_device, '_boot_bat_perf_') + errorstatus=ghaf_hw_test(targetAttr, it.hwtest_device, '_boot_bat_perf_') + println ("Test creation and execution done") + if (errorstatus==null) { + println("Test was OK") + } + else { + failedHWTests.add(errorstatus) + println ("ERROR FOUND, target: ${errorstatus}") + } } } }