From 61bdb375f1caa279dd323692a46a784c49f65912 Mon Sep 17 00:00:00 2001 From: Ville-Pekka Juntunen Date: Fri, 25 Aug 2023 09:52:05 +0300 Subject: [PATCH] Changes to use congif file to get needed data Get all needed data from config file about target test device. No hard coded data to Jenkinsfiles. Signed-off-by: Ville-Pekka Juntunen --- .../{orin_arm_test_set => hw_test_set} | 65 +++++++--- Jenkinsfiles/nuc_x86_test_set | 121 ------------------ Robot-Framework/test-suites/log.html | 0 Robot-Framework/test-suites/output.xml | 0 Robot-Framework/test-suites/report.html | 0 requirements | 2 +- 6 files changed, 50 insertions(+), 138 deletions(-) rename Jenkinsfiles/{orin_arm_test_set => hw_test_set} (61%) delete mode 100644 Jenkinsfiles/nuc_x86_test_set create mode 100644 Robot-Framework/test-suites/log.html create mode 100644 Robot-Framework/test-suites/output.xml create mode 100644 Robot-Framework/test-suites/report.html diff --git a/Jenkinsfiles/orin_arm_test_set b/Jenkinsfiles/hw_test_set similarity index 61% rename from Jenkinsfiles/orin_arm_test_set rename to Jenkinsfiles/hw_test_set index 13ce644..460cddd 100644 --- a/Jenkinsfiles/orin_arm_test_set +++ b/Jenkinsfiles/hw_test_set @@ -8,9 +8,13 @@ buildResults = [:] bootJob = '' batJob = '' -orinDirectory = 'orin_test_results' +resultsDirectory = '' +configPath = '' bootSuite = 'boot_test.robot' batSuite = './' +deviceName = '' +usbHubSerial = '' +usbDrive = 'PSSD' pipeline { agent { label "${params.label}" } @@ -18,25 +22,53 @@ pipeline { stage('Set variables') { steps { script { + resultsDirectory = "${params.device}_test_results" def splitted = "${JOB_NAME}".split('/') - bootJob = "${splitted[0]}/Testing/Orin_arm/orin_arm_boot_test" + bootJob = "${splitted[0]}/Testing/boot_test" batJob = "${splitted[0]}/Testing/smoke_tests" + configPath = "/home/${params.label}/Jenkins-agent/workspace/${splitted[0]}/Testing/test_config.json" + + // Check for which agent and which target device + if ("${params.label}" == "tc-agent02"){ + if (params.device == "Orin"){ + deviceName = 'ORIN1' + } else if (params.device == "NUC"){ + deviceName = 'NUC1' + } + } else if ("${params.label}" == "tc-agent03"){ + if (params.device == "Orin"){ + deviceName = 'ORIN2' + } else if (params.device == "NUC"){ + deviceName = 'NUC2' + } + } + echo "DEVICE: ${deviceName}" + + // Set pipeline description + currentBuild.description = "${params.server} ${params.device} BuildID: ${params.buildID}" + + // Read test devices configfile and set usbHub serial to use right device + def deviceData = readJSON file: "${configPath}" + usbHubSerial = "${deviceData['addresses']["${deviceName}"]['usbhub_serial']}" + println("USB HUB serial: ${usbHubSerial}") + } } } stage('Change USB HUB host to PC') { steps { script{ - // Set pipeline description - currentBuild.description = "${params.server} BuildID: ${params.buildID}" - sh './BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s EBBBCDD4' + sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s ${usbHubSerial}" + // wait that USB drive is mounted sh 'sleep 10' def output = sh ( - script: 'lsblk -o model,name |grep PSSD', // Check for usb device that is connected to target test device + // Check for usb drive that is connected to target test device + script: "lsblk -o model,name |grep ${usbDrive}", returnStdout: true ).trim() def list = output.split(' ') + // Take last element which is the target USB device USBDEVICE = list[-1] println("USB device: ${USBDEVICE}") @@ -54,26 +86,27 @@ pipeline { stage('Change USB HUB host back to test device') { steps { script{ - sh './BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s EBBBCDD4' + sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s ${usbHubSerial}" } } } - stage('Boot Orin') { + stage('Boot Test') { steps { script{ // Make directory for test results - sh "mkdir -p ${params.resultsPath}/${params.buildID}/${orinDirectory}/boot" + sh "mkdir -p ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot" build = build( job: "${bootJob}", propagate: false, parameters: [ [$class: 'StringParameterValue', name: 'RF_SUITE', value: "${bootSuite}"], - [$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"] + [$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"], + [$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"] ] ) // copy report and log - sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${orinDirectory}/boot/report.html" - sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${orinDirectory}/boot/log.html" + sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/report.html" + sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/log.html" if(build.result == "SUCCESS") { buildResults."boot" = "SUCCESS" echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD" @@ -94,18 +127,18 @@ pipeline { steps { script{ // Make directory for test results - sh "mkdir ${params.resultsPath}/${params.buildID}/${orinDirectory}/bat" + sh "mkdir ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat" build = build( job: "${batJob}", propagate: false, parameters: [ [$class: 'StringParameterValue', name: 'RF_SUITE', value: "${batSuite}"], [$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"], - [$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "ORIN1"] + [$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"] ] ) // copy report and log - sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${orinDirectory}/bat/report.html" - sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${orinDirectory}/bat/log.html" + sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/report.html" + sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/log.html" if(build.result == "SUCCESS") { buildResults."bat" = "SUCCESS" echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD" diff --git a/Jenkinsfiles/nuc_x86_test_set b/Jenkinsfiles/nuc_x86_test_set deleted file mode 100644 index 6746ab4..0000000 --- a/Jenkinsfiles/nuc_x86_test_set +++ /dev/null @@ -1,121 +0,0 @@ -#!groovy -// SPDX-FileCopyrightText: 2022-2023 Technology Innovation Institute (TII) -// SPDX-License-Identifier: Apache-2.0 - -import groovy.json.* - -buildResults = [:] - -bootJob = '' -batJob = '' -nucDirectory = 'nuc_test_results' -bootSuite = 'boot_test.robot' -batSuite = './' - -pipeline { - agent { label "${params.label}" } - stages { - stage('Set variables') { - steps { - script { - def splitted = "${JOB_NAME}".split('/') - bootJob = "${splitted[0]}/Testing/NUC_x86/nuc_x86_boot_test" - batJob = "${splitted[0]}/Testing/smoke_tests" - } - } - } - stage('Change USB HUB host to PC') { - steps { - script{ - // Set pipeline description - currentBuild.description = "${params.server} BuildID: ${params.buildID}" - sh './BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s 6B780E17' - // wait that USB drive is mounted - sh 'sleep 10' - def output = sh ( - script: 'lsblk -o model,name |grep PSSD', // Check for usb device that is connected to target test device - returnStdout: true - ).trim() - def list = output.split(' ') - // Take last element which is the target USB device - USBDEVICE = list[-1] - println("USB device: ${USBDEVICE}") - } - } - } - stage('Write OS image to USB disk') { - steps { - script { - println("${params.image}") - sh "sudo dd if=${params.image} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync" - } - } - } - stage('Change USB HUB host back to test device') { - steps { - script{ - sh './BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s 6B780E17' - } - } - } - stage('Boot NUC') { - steps { - script{ - // Make directory for test results - sh "mkdir -p ${params.resultsPath}/${params.buildID}/${nucDirectory}/boot" - build = build( - job: "${bootJob}", propagate: false, - parameters: [ - [$class: 'StringParameterValue', name: 'RF_SUITE', value: "${bootSuite}"], - [$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"] - ] - ) - - // copy report and log - sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${nucDirectory}/boot/report.html" - sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${nucDirectory}/boot/log.html" - if(build.result == "SUCCESS") { - buildResults."boot" = "SUCCESS" - echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD" - } else { - catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){ - error("Boot build failed") - } - } - } - } - } - stage('BAT tests') { - when { - expression { - buildResults.boot == 'SUCCESS' - } - } - steps { - script{ - // Make directory for test results - sh "mkdir ${params.resultsPath}/${params.buildID}/${nucDirectory}/bat" - build = build( - job: "${batJob}", propagate: false, - parameters: [ - [$class: 'StringParameterValue', name: 'RF_SUITE', value: "${batSuite}"], - [$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"], - [$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "NUC1"] - ] - ) - // copy report and log - sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${nucDirectory}/bat/report.html" - sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${nucDirectory}/bat/log.html" - if(build.result == "SUCCESS") { - buildResults."bat" = "SUCCESS" - echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD" - } else { - catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){ - error("BAT build failed") - } - } - } - } - } - } -} diff --git a/Robot-Framework/test-suites/log.html b/Robot-Framework/test-suites/log.html new file mode 100644 index 0000000..e69de29 diff --git a/Robot-Framework/test-suites/output.xml b/Robot-Framework/test-suites/output.xml new file mode 100644 index 0000000..e69de29 diff --git a/Robot-Framework/test-suites/report.html b/Robot-Framework/test-suites/report.html new file mode 100644 index 0000000..e69de29 diff --git a/requirements b/requirements index 46b830c..c86387a 100644 --- a/requirements +++ b/requirements @@ -2,4 +2,4 @@ pyserial==3.5 robotframework-seriallibrary==0.4.2 robotframework-sshlibrary==3.8.0 robotframework==5.0.1 -PyP100==0.0.19 +PyP100==0.1.2