Skip to content
Open
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
27 changes: 23 additions & 4 deletions src/sdg/Gauntlet.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,16 @@ def old_stage_library(String stage_name) {
cmd += ' --branch=' + gauntEnv.branches.toString()
cmd += (gauntEnv.url_template == 'NA')? "" : ' --url-template=' + gauntEnv.url_template
cmd += ' ' + gauntEnv.filetype
nebula(cmd, true, true, true)
if (gauntEnv.bootfile_source == "cloudsmith") {
stepExecutor.withCredentials([
stepExecutor.string(credentialsId: gauntEnv.cloudsmith_auth_id, variable: 'CLOUDSMITH_AUTH')
]) {
cmd += ' --cloudsmith-auth=${CLOUDSMITH_AUTH}'
nebula(cmd, true, true, true)
}
} else {
nebula(cmd, true, true, true)
}
}
//get git sha properties of files
get_gitsha(board)
Expand Down Expand Up @@ -396,11 +405,21 @@ def old_stage_library(String stage_name) {
if (gauntEnv.bootfile_source == "NA")
throw new Exception("bootfile_source must be specified")
echo "Fetching reference boot files"
nebula('dl.bootfiles --board-name=' + board
+ ' --source-root="' + gauntEnv.nebula_local_fs_source_root
def dlCmd = 'dl.bootfiles --board-name=' + board
+ ' --source-root="' + gauntEnv.nebula_local_fs_source_root
+ '" --source=' + gauntEnv.bootfile_source
+ ' --branch="' + ref_branch.toString()
+ '" --filetype="boot_partition"', true, true, true)
+ '" --filetype="boot_partition"'
if (gauntEnv.bootfile_source == "cloudsmith") {
stepExecutor.withCredentials([
stepExecutor.string(credentialsId: gauntEnv.cloudsmith_auth_id, variable: 'CLOUDSMITH_AUTH')
]) {
dlCmd += ' --cloudsmith-auth=${CLOUDSMITH_AUTH}'
nebula(dlCmd, true, true, true)
}
} else {
nebula(dlCmd, true, true, true)
}
echo "Extracting reference fsbl and u-boot"
dir('outs'){
sh("cp bootgen_sysfiles.tgz ..")
Expand Down
2 changes: 2 additions & 0 deletions src/sdg/IStepExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ interface IStepExecutor {
void xunit(List testResults)
Object CTest(Map kwargs)
Map getEnv()
void withCredentials(List credentials, Closure body)
Object string(Map kwargs)
}
10 changes: 10 additions & 0 deletions src/sdg/StepExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ class StepExecutor implements IStepExecutor{
void setMockEnv(Map env) {
this._mockEnv = env
}

@Override
void withCredentials(List credentials, Closure body) {
this._steps.withCredentials(credentials, body)
}

@Override
Object string(Map kwargs) {
return this._steps.string(kwargs)
}
}
16 changes: 11 additions & 5 deletions src/sdg/stages/RecoverBoard.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ class RecoverBoard implements IStage {
if(to_proceed){
try{
logger.info("Fetching reference boot files")
gauntlet.nebula('dl.bootfiles --board-name=' + board
+ ' --source-root="' + gauntEnv.nebula_local_fs_source_root
+ '" --source=' + gauntEnv.bootfile_source
+ ' --branch="' + ref_branch.toString()
+ '" --filetype="boot_partition"', true, true, true)
def dlCmd = 'dl.bootfiles --board-name=' + board + ' --source-root="' + gauntEnv.nebula_local_fs_source_root + '" --source=' + gauntEnv.bootfile_source + ' --branch="' + ref_branch.toString() + '" --filetype="boot_partition"'
if (gauntEnv.bootfile_source == "cloudsmith") {
gauntlet.stepExecutor.withCredentials([
gauntlet.stepExecutor.string(credentialsId: gauntEnv.cloudsmith_auth_id, variable: 'CLOUDSMITH_AUTH')
]) {
dlCmd += ' --cloudsmith-auth=${CLOUDSMITH_AUTH}'
gauntlet.nebula(dlCmd, true, true, true)
}
} else {
gauntlet.nebula(dlCmd, true, true, true)
}

logger.info("Extracting reference fsbl and u-boot")
steps.sh("cp outs/bootgen_sysfiles.tgz .")
Expand Down
11 changes: 10 additions & 1 deletion src/sdg/stages/UpdateBOOTFiles.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ class UpdateBOOTFiles implements IStage {
cmd += ' --branch=' + gauntEnv.branches.toString()
cmd += (gauntEnv.url_template == 'NA')? "" : ' --url-template=' + gauntEnv.url_template
cmd += gauntEnv.filetype
gauntlet.nebula(cmd, true, true, true)
if (gauntEnv.bootfile_source == "cloudsmith") {
gauntlet.stepExecutor.withCredentials([
gauntlet.stepExecutor.string(credentialsId: gauntEnv.cloudsmith_auth_id, variable: 'CLOUDSMITH_AUTH')
]) {
cmd += ' --cloudsmith-auth=${CLOUDSMITH_AUTH}'
gauntlet.nebula(cmd, true, true, true)
}
} else {
gauntlet.nebula(cmd, true, true, true)
}
}
//get git sha properties of files
gauntlet.get_gitsha(board)
Expand Down
48 changes: 48 additions & 0 deletions test/sdg/stages/TestRecoverBoard.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,54 @@ class TestRecoverBoard extends Specification {
])
}

def "test stageSteps for non-pluto with cloudsmith source"() {
given:

//Mock gauntlet
context.getStepExecutor() >> steps
context.isDefault() >> false
steps.getGauntEnv(_,_,_,_,_) >> getGauntEnv.call("NA","NA","NA","NA","cloudsmith")
steps.isUnix() >> true
steps.sh(script: 'uname', returnStdout: true) >> 'Linux'

steps.fileExists('out.out') >> true
steps.readFile('out.out') >> 'STDOUT of some successful nebula command'
ContextRegistry.registerContext(context)
Gauntlet gauntlet = new Gauntlet()
gauntlet.construct("NA","NA","NA","NA","cloudsmith")

RecoverBoard _stage = new RecoverBoard()
String board = "zynq-zc702-adv7511-ad9361-fmcomms2-3"
gauntlet.set_env("docker_args", [])
gauntlet.set_env("debug_level", 3)
gauntlet.set_env("cloudsmith_auth_id", "cloudsmith-svc-cred")

// trigger board-not-booted exception so recovery proceeds
steps.sh([
script: 'nebula net.check-board-booted --board-name=zynq-zc702-adv7511-ad9361-fmcomms2-3',
returnStdout: true
]) >> { throw new Exception() }

def dl_cmd = 'dl.bootfiles --board-name=' + board +
' --source-root="/var/lib/tftpboot"' +
' --source=cloudsmith' +
' --branch="release"' +
' --filetype="boot_partition"' +
' --cloudsmith-auth=${CLOUDSMITH_AUTH}'

when:
_stage.stageSteps(gauntlet, board)

then:
1 * steps.echo('[INFO] Running RecoverBoard for ' + board)
1 * steps.echo('[INFO] Fetching reference boot files')
1 * steps.withCredentials(_, _) >> { args -> args[1].call() }
1 * steps.string(credentialsId: 'cloudsmith-svc-cred', variable: 'CLOUDSMITH_AUTH')
1 * steps.sh('set -o pipefail; nebula show-log ' + dl_cmd + ' 2>&1 | tee out.out')
1 * steps.echo('[INFO] Extracting reference fsbl and u-boot')
1 * steps.echo('[INFO] Executing board recovery...')
}

def "test stageSteps for non-pluto with exception"() {
given:

Expand Down
65 changes: 57 additions & 8 deletions test/sdg/stages/TestUpdateBOOTFiles.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class TestUpdateBOOTFiles extends Specification {
}

def "test stageSteps for non-pluto"() {

given:
//Mock gauntlet
//Mock gauntlet
context.getStepExecutor() >> steps
context.isDefault() >> false
context.getStepExecutor().getGauntEnv(_,_,_,_,_) >> getGauntEnv.call("NA","NA","release","NA","artifactory")
Expand All @@ -106,10 +106,10 @@ class TestUpdateBOOTFiles extends Specification {
String ml_bootbin_case = "NA"
gauntlet.set_env("docker_args", [])
gauntlet.set_env("debug_level", 3)
def dl_cmd = 'dl.bootfiles --board-name=' + board +
' --source-root=/var/lib/tftpboot' +
' --source=artifactory' +
' --branch=release' +
def dl_cmd = 'dl.bootfiles --board-name=' + board +
' --source-root=/var/lib/tftpboot' +
' --source=artifactory' +
' --branch=release' +
' --filetype="boot_partition"'

when:
Expand All @@ -122,12 +122,61 @@ class TestUpdateBOOTFiles extends Specification {
1 * steps.sh('set -o pipefail; nebula show-log '+ dl_cmd + ' 2>&1 | tee out.out')
1 * steps.sh('set -o pipefail; nebula show-log manager.update-boot-files --board-name=zynq-zc702-adv7511-ad9361-fmcomms2-3 --folder=outs 2>&1 | tee out.out')
1 * steps.sh('set -o pipefail; nebula show-log manager.verify-checksum --board-name=zynq-zc702-adv7511-ad9361-fmcomms2-3 --folder=outs 2>&1 | tee out.out')
1 * steps.archiveArtifacts(artifacts: 'uart_boot_*.log', followSymlinks: false, allowEmptyArchive: true)
1 * steps.archiveArtifacts(artifacts: 'uart_boot_*.log', followSymlinks: false, allowEmptyArchive: true)

assert gauntlet.get_env("elastic_logs")[board]["uboot_reached"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["kernel_started"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["linux_prompt_reached"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["post_boot_failure"] == "False"
}

def "test stageSteps for non-pluto with cloudsmith source"() {

given:
//Mock gauntlet
context.getStepExecutor() >> steps
context.isDefault() >> false
context.getStepExecutor().getGauntEnv(_,_,_,_,_) >> getGauntEnv.call("NA","NA","2026_r1","NA","cloudsmith")
context.getStepExecutor().isUnix() >> true
context.getStepExecutor().sh(script: 'uname', returnStdout: true) >> 'Linux'
context.getStepExecutor().fileExists('out.out') >> true
context.getStepExecutor().readFile('out.out') >> 'STDOUT of some successful nebula command'
ContextRegistry.registerContext(context)
Gauntlet gauntlet = new Gauntlet()
gauntlet.construct("NA","NA","2026_r1","NA","cloudsmith")

UpdateBOOTFiles ubf_stage = new UpdateBOOTFiles()
String board = "zynq-zc706-adv7511-fmcomms2-3"
String ml_bootbin_case = "NA"
gauntlet.set_env("docker_args", [])
gauntlet.set_env("debug_level", 3)
gauntlet.set_env("cloudsmith_auth_id", "cloudsmith-svc-cred")

def dl_cmd = 'dl.bootfiles --board-name=' + board +
' --source-root=/var/lib/tftpboot' +
' --source=cloudsmith' +
' --branch=2026_r1' +
' --filetype="boot_partition"' +
' --cloudsmith-auth=${CLOUDSMITH_AUTH}'

when:
ubf_stage.stageSteps(gauntlet, board, ml_bootbin_case)

then:
1 * steps.echo('[INFO] Running UpdateBOOTFiles for '+ board)
1 * steps.echo('[INFO] Board name passed: ' + board)
1 * steps.echo("[INFO] Branch: " + gauntlet.get_env("branches").toString())
1 * steps.withCredentials(_, _) >> { args -> args[1].call() }
1 * steps.string(credentialsId: 'cloudsmith-svc-cred', variable: 'CLOUDSMITH_AUTH')
1 * steps.sh('set -o pipefail; nebula show-log ' + dl_cmd + ' 2>&1 | tee out.out')
1 * steps.sh('set -o pipefail; nebula show-log manager.update-boot-files --board-name=' + board + ' --folder=outs 2>&1 | tee out.out')
1 * steps.sh('set -o pipefail; nebula show-log manager.verify-checksum --board-name=' + board + ' --folder=outs 2>&1 | tee out.out')
1 * steps.archiveArtifacts(artifacts: 'uart_boot_*.log', followSymlinks: false, allowEmptyArchive: true)

assert gauntlet.get_env("elastic_logs")[board]["uboot_reached"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["kernel_started"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["linux_prompt_reached"] == "True"
assert gauntlet.get_env("elastic_logs")[board]["post_boot_failure"] == "False"
assert gauntlet.get_env("elastic_logs")[board]["post_boot_failure"] == "False"
}
}

Expand Down
1 change: 1 addition & 0 deletions vars/getGauntEnv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private def call(hdlBranch, linuxBranch, bootPartitionBranch,firmwareVersion, bo
recovery_ref: "SD",
log_artifacts: false,
credentials_id: '',
cloudsmith_auth_id: '',
toolbox_generated_bootbin: false,
ml_toolbox: '',
ml_branch: '',
Expand Down
Loading