From 0c67140ae8257ffecbaed4e1634cc95a2d52168a Mon Sep 17 00:00:00 2001 From: Pierre Prinetti Date: Tue, 28 Feb 2023 09:32:29 +0100 Subject: [PATCH] openstack-manifests: Option to run selected test cases Add a `-r ` to `test-manifests.sh` to optionally only run test cases with a matching name. --- hack/openstack/test-manifests.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hack/openstack/test-manifests.sh b/hack/openstack/test-manifests.sh index 295f77f9b79..b6595ece0a3 100755 --- a/hack/openstack/test-manifests.sh +++ b/hack/openstack/test-manifests.sh @@ -11,7 +11,9 @@ declare \ os_cloud='' \ external_network='' \ compute_flavor='' \ - persist='NO' + persist='NO' \ + run='.*' \ + test_counter=0 # Let install-config describe a configuration that is incompatible with the # target CI infrastructure @@ -32,10 +34,11 @@ print_help() { echo -e "\\t${0} -c -e -f [-a ] [-i ] [-t ] [-p]" echo echo -e 'Additional arguments:' - echo -e "\\t-a\\tapiFloatingIP" - echo -e "\\t-i\\tpath to openshift-install (defaults to '${openshift_install}')" - echo -e "\\t-t\\tpath to the tests to be run (defaults to '${tests_dir}')" - echo -e "\\t-p\\tpersist artifacts: do not delete files generated by openshift-install" + echo -e "\\t-a\\t\\tapiFloatingIP" + echo -e "\\t-i\\t\\tpath to openshift-install (defaults to '${openshift_install}')" + echo -e "\\t-t\\t\\tpath to the tests to be run (defaults to '${tests_dir}')" + echo -e "\\t-p\\t\\tpersist artifacts: do not delete files generated by openshift-install" + echo -e "\\t-r \\trun: only run test cases that match the given regular expression" } fill_install_config() { @@ -70,7 +73,7 @@ validate_configuration() { fi } -while getopts a:c:e:f:i:t:ph o; do +while getopts a:c:e:f:i:t:pr:h o; do case "$o" in a) api_fip="$OPTARG" ;; c) os_cloud="$OPTARG" ;; @@ -79,11 +82,12 @@ while getopts a:c:e:f:i:t:ph o; do i) openshift_install="$OPTARG" ;; t) tests_dir="$OPTARG" ;; p) persist='YES' ;; + r) run="$OPTARG" ;; h) print_help; exit 0 ;; *) print_help; exit 1 ;; esac done -readonly api_fip os_cloud external_network compute_flavor openshift_install tests_dir persist +readonly api_fip os_cloud external_network compute_flavor openshift_install tests_dir persist run declare -a temp_dirs cleanup() { @@ -101,9 +105,10 @@ validate_configuration declare result='PASS' for testcase in "${tests_dir}"/* ; do - if [ -d "$testcase" ]; then + if [ -d "$testcase" ] && [[ "$testcase" =~ $run ]]; then echo echo "*** TEST CASE: $(basename "${testcase}")" + ((test_counter+=1)) assets_dir="$(mktemp -d)" temp_dirs+=("$assets_dir") fill_install_config "${testcase}/install-config.yaml" > "${assets_dir}/install-config.yaml" @@ -119,6 +124,7 @@ for testcase in "${tests_dir}"/* ; do fi done +echo "Ran ${test_counter} test cases." if [ "$result" != 'PASS' ]; then echo "FAIL" exit 1