Skip to content

Commit

Permalink
Remove extra params for RF
Browse files Browse the repository at this point in the history
Signed-off-by: Mariia Azbeleva <[email protected]>
  • Loading branch information
azbeleva committed Dec 9, 2024
1 parent 0246bcb commit 7691019
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 103 deletions.
80 changes: 28 additions & 52 deletions ghaf-hw-test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,58 +38,34 @@ def ghaf_robot_test(String testname='boot') {
} else {
env.INCLUDE_TEST_TAGS = "${testname}AND${env.DEVICE_TAG}"
}
// TODO: do we really need credentials to access the target devices?
// Target devices are connected to the testagent, which itself is
// only available over a private network. What is the risk
// we are protecting against by having additional authentication
// for the test devices?
// The current configuration requires additional manual configuration
// on the jenkins UI to add the following secrets:
withCredentials([
string(credentialsId: 'testagent-dut-pass', variable: 'DUT_PASS'),
string(credentialsId: 'testagent-plug-pass', variable: 'PLUG_PASS'),
string(credentialsId: 'testagent-switch-token', variable: 'SW_TOKEN'),
string(credentialsId: 'testagent-switch-secret', variable: 'SW_SECRET'),
string(credentialsId: 'testagent-wifi-ssid', variable: 'WIFI_SSID'),
string(credentialsId: 'testagent-wifi-password', variable: 'WIFI_PSWD'),
]) {
dir("Robot-Framework/test-suites") {
sh 'rm -f *.png output.xml report.html log.html'
// On failure, continue the pipeline execution
try {
// Pass the secrets to the shell as environment variables, as we
// don't want Groovy to interpolate them. Similary, we pass
// other variables as environment variables to shell.
// Ref: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation
sh '''
nix run .#ghaf-robot -- \
-v DEVICE:$DEVICE_NAME \
-v DEVICE_TYPE:$DEVICE_TAG \
-v LOGIN:ghaf \
-v PASSWORD:$DUT_PASS \
-v PLUG_USERNAME:[email protected] \
-v PLUG_PASSWORD:$PLUG_PASS \
-v SWITCH_TOKEN:$SW_TOKEN \
-v SWITCH_SECRET:$SW_SECRET \
-v BUILD_ID:${BUILD_NUMBER} \
-v TEST_WIFI_SSID:${WIFI_SSID} \
-v TEST_WIFI_PSWD:${WIFI_PSWD} \
-i $INCLUDE_TEST_TAGS .
'''
if (testname == 'boot') {
// Set an environment variable to indicate boot test passed
env.BOOT_PASSED = 'true'
}
} catch (Exception e) {
currentBuild.result = "FAILURE"
unstable("FAILED '${testname}': ${e.toString()}")
} finally {
// Move the test output (if any) to a subdirectory
sh """
rm -fr $testname; mkdir -p $testname
mv -f *.png output.xml report.html log.html $testname/ || true
"""
}
dir("Robot-Framework/test-suites") {
sh 'rm -f *.png output.xml report.html log.html'
// On failure, continue the pipeline execution
try {
// Pass the secrets to the shell as environment variables, as we
// don't want Groovy to interpolate them. Similary, we pass
// other variables as environment variables to shell.
// Ref: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation
sh '''
nix run .#ghaf-robot -- \
-v DEVICE:$DEVICE_NAME \
-v DEVICE_TYPE:$DEVICE_TAG \
-v BUILD_ID:${BUILD_NUMBER} \
-i $INCLUDE_TEST_TAGS .
'''
if (testname == 'boot') {
// Set an environment variable to indicate boot test passed
env.BOOT_PASSED = 'true'
}
} catch (Exception e) {
currentBuild.result = "FAILURE"
unstable("FAILED '${testname}': ${e.toString()}")
} finally {
// Move the test output (if any) to a subdirectory
sh """
rm -fr $testname; mkdir -p $testname
mv -f *.png output.xml report.html log.html $testname/ || true
"""
}
}
}
Expand Down
79 changes: 28 additions & 51 deletions tests/x-ghaf-hw-test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -101,58 +101,34 @@ def ghaf_robot_test(String test_tags) {
println "Test tags is empty, give test tags as parameter when build this job!"
}
}
// TODO: do we really need credentials to access the target devices?
// Target devices are connected to the testagent, which itself is
// only available over a private network. What is the risk
// we are protecting against by having additional authentication
// for the test devices?
// The current configuration requires additional manual configuration
// on the jenkins UI to add the following secrets:
withCredentials([
string(credentialsId: 'testagent-dut-pass', variable: 'DUT_PASS'),
string(credentialsId: 'testagent-plug-pass', variable: 'PLUG_PASS'),
string(credentialsId: 'testagent-switch-token', variable: 'SW_TOKEN'),
string(credentialsId: 'testagent-switch-secret', variable: 'SW_SECRET'),
string(credentialsId: 'testagent-wifi-ssid', variable: 'WIFI_SSID'),
string(credentialsId: 'testagent-wifi-password', variable: 'WIFI_PSWD'),
]) {
dir("Robot-Framework/test-suites") {
sh 'rm -f *.png output.xml report.html log.html'
// On failure, continue the pipeline execution
try {
// Pass the secrets to the shell as environment variables, as we
// don't want Groovy to interpolate them. Similary, we pass
// other variables as environment variables to shell.
// Ref: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation
sh '''
nix run .#ghaf-robot -- \
-v DEVICE:$DEVICE_NAME \
-v DEVICE_TYPE:$DEVICE_TAG \
-v LOGIN:ghaf \
-v PASSWORD:$DUT_PASS \
-v PLUG_USERNAME:[email protected] \
-v PLUG_PASSWORD:$PLUG_PASS \
-v SWITCH_TOKEN:$SW_TOKEN \
-v SWITCH_SECRET:$SW_SECRET \
-v BUILD_ID:${BUILD_NUMBER} \
-v TEST_WIFI_SSID:${WIFI_SSID} \
-v TEST_WIFI_PSWD:${WIFI_PSWD} \
-i $INCLUDE_TEST_TAGS .
'''
if (test_tags == 'boot') {
// Set an environment variable to indicate boot test passed
env.BOOT_PASSED = 'true'
}
} catch (Exception e) {
currentBuild.result = "FAILURE"
unstable("FAILED '${test_tags}': ${e.toString()}")
} finally {
// Move the test output (if any) to a subdirectory
sh """
rm -fr $test_tags; mkdir -p $test_tags
mv -f *.png output.xml report.html log.html $test_tags/ || true
"""
dir("Robot-Framework/test-suites") {
sh 'rm -f *.png output.xml report.html log.html'
// On failure, continue the pipeline execution
try {
// Pass the secrets to the shell as environment variables, as we
// don't want Groovy to interpolate them. Similary, we pass
// other variables as environment variables to shell.
// Ref: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation
sh '''
nix run .#ghaf-robot -- \
-v DEVICE:$DEVICE_NAME \
-v DEVICE_TYPE:$DEVICE_TAG \
-v BUILD_ID:${BUILD_NUMBER} \
-i $INCLUDE_TEST_TAGS .
'''
if (test_tags == 'boot') {
// Set an environment variable to indicate boot test passed
env.BOOT_PASSED = 'true'
}
} catch (Exception e) {
currentBuild.result = "FAILURE"
unstable("FAILED '${test_tags}': ${e.toString()}")
} finally {
// Move the test output (if any) to a subdirectory
sh """
rm -fr $test_tags; mkdir -p $test_tags
mv -f *.png output.xml report.html log.html $test_tags/ || true
"""
}
}
}
Expand Down Expand Up @@ -313,6 +289,7 @@ pipeline {
archiveDirName: 'robot-plugin',
outputPath: 'Robot-Framework/test-suites',
outputFileName: '**/output.xml',
otherFiles: '**/*.png',
disableArchiveOutput: false,
reportFileName: '**/report.html',
logFileName: '**/log.html',
Expand Down

0 comments on commit 7691019

Please sign in to comment.