Skip to content

Commit

Permalink
[sdn_tests]: Adding testrunner to pins_ondatra. (#12678)
Browse files Browse the repository at this point in the history
* [sdn_tests]: Adding Build support for pins_ondatra

* [sdn_tests]: Adding binding infra to pins_ondatra.

* [sdn_tests]: Adding cert generation script and certs folder to pins_ondatra.

* [sdn_tests]: Adding Data Infra to pins_ondatra.

* [sdn_tests]: Adding gnmi testhelper to pins_ondatra.

* [sdn_tests]: Adding GNOI testhelper to pins_ondatra.

* [sdn_tests]: Adding LACP testhelper to pins_ondatra.

* [sdn_tests]: Adding P4RT testhelper to pins_ondatra.

* [sdn_tests]: Adding Platform and port_management testhelper to pins_ondatra.

* [sdn_tests]: Adding testhelper to pins_ondatra.

* [sdn_tests]: Adding Augment testhelper Infra to pins_ondatra.

* [sdn_tests]: Adding results testhelper to pins_ondatra.

* [sdn_tests]: Adding ssh testhelper to pins_ondatra.

* [sdn_tests]: Adding ondatra bazel tests to pins_ondatra.

* [sdn_tests]: Adding testrunner to pins_ondatra.
  • Loading branch information
VSuryaprasad-HCL authored May 20, 2024
1 parent 252d600 commit d3571dd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ go_library(
"platform_info.go",
"port_management.go",
"results.go",
"ssh.go",
"ssh.go",
"//infrastructure/testhelper/platform_info:platform_info",
],
data = [
Expand Down
49 changes: 49 additions & 0 deletions sdn_tests/pins_ondatra/testrunner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

test_name=''
push_config_after_test='false'
push_config_before_test='false'
push_config_success='true'

print_usage() {
printf "Use:\n\t'-t tests/ondatra:test_name' to run the test.\n\t'-b' to push the switch config before the test.\n\t'-a' to push the config after the test.\n"
}

while getopts 'abt:' arg; do
case "${arg}" in
t) test_name="${OPTARG}" ;;
a) push_config_after_test='true' ;;
b) push_config_before_test='true' ;;
*) print_usage
exit 1 ;;
esac
done

function push_config() {
bazel test --test_output=streamed tests/ondatra:installation_test --test_strategy=exclusive --cache_test_results=no
if [ $? -ne 0 ]; then
push_config_success='false'
fi
}

# Pushes the config before/after test.
function run_test() {
if [ -z "$test_name" ]; then
print_usage
exit 1
fi

if [ $push_config_before_test = 'true' ]; then
push_config
fi

if [ $push_config_success = 'true' ]; then
bazel test --test_output=streamed "$test_name" --test_strategy=exclusive --cache_test_results=no --test_timeout=10000000
fi

if [ $push_config_after_test = 'true' ]; then
push_config
fi
}

run_test

0 comments on commit d3571dd

Please sign in to comment.