From 76910192c8a9510cf70586335c3e3bd4f1e038d2 Mon Sep 17 00:00:00 2001 From: Mariia Azbeleva Date: Fri, 29 Nov 2024 15:04:15 +0200 Subject: [PATCH] Remove extra params for RF Signed-off-by: Mariia Azbeleva --- ghaf-hw-test.groovy | 80 +++++++++++++------------------------ tests/x-ghaf-hw-test.groovy | 79 +++++++++++++----------------------- 2 files changed, 56 insertions(+), 103 deletions(-) diff --git a/ghaf-hw-test.groovy b/ghaf-hw-test.groovy index 61374c0..0ee58ba 100644 --- a/ghaf-hw-test.groovy +++ b/ghaf-hw-test.groovy @@ -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:ghaftester@gmail.com \ - -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 + """ } } } diff --git a/tests/x-ghaf-hw-test.groovy b/tests/x-ghaf-hw-test.groovy index 0873d73..0379f62 100644 --- a/tests/x-ghaf-hw-test.groovy +++ b/tests/x-ghaf-hw-test.groovy @@ -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:ghaftester@gmail.com \ - -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 + """ } } } @@ -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',