Skip to content

Commit

Permalink
Changes to use congif file to get needed data
Browse files Browse the repository at this point in the history
Get all needed data from config file about target test device.
No hard coded data to Jenkinsfiles.

Signed-off-by: Ville-Pekka Juntunen <[email protected]>
  • Loading branch information
vjuntunen committed Aug 31, 2023
1 parent f7baca5 commit f24a2bc
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 138 deletions.
65 changes: 49 additions & 16 deletions Jenkinsfiles/orin_arm_test_set → Jenkinsfiles/hw_test_set
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,67 @@ buildResults = [:]

bootJob = ''
batJob = ''
orinDirectory = 'orin_test_results'
resultsDirectory = ''
configPath = ''
bootSuite = 'boot_test.robot'
batSuite = './'
deviceName = ''
usbHubSerial = ''
usbDrive = 'PSSD'

pipeline {
agent { label "${params.label}" }
stages {
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}")
Expand All @@ -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"
Expand All @@ -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"
Expand Down
121 changes: 0 additions & 121 deletions Jenkinsfiles/nuc_x86_test_set

This file was deleted.

Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion requirements
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f24a2bc

Please sign in to comment.