From a8b8ef5c4ba48cdb88a8835cb40360b409b76ac9 Mon Sep 17 00:00:00 2001 From: jh629g Date: Fri, 21 Jun 2019 07:12:01 -0500 Subject: [PATCH] Update Ranger Tempest Tests to Stestr This change moves ranger tempest tests to using stestr rather than ostestr. Change-Id: I9535461fc1e6f45d0357eeba8303d210254346be --- .../tempest_setup/.stestr.conf | 6 + .../tempest_setup/ranger-tempest.sh | 104 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 ranger-tempest-plugin/tempest_setup/.stestr.conf create mode 100755 ranger-tempest-plugin/tempest_setup/ranger-tempest.sh diff --git a/ranger-tempest-plugin/tempest_setup/.stestr.conf b/ranger-tempest-plugin/tempest_setup/.stestr.conf new file mode 100644 index 00000000..23070afa --- /dev/null +++ b/ranger-tempest-plugin/tempest_setup/.stestr.conf @@ -0,0 +1,6 @@ +[DEFAULT] +test_path=../ranger/ranger-tempest-plugin/ranger_tempest_plugin/tests/ +top_dir=../ranger/ranger-tempest-plugin/ +test_command=${PYTHON:-python} -m subunit.run discover orm $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/ranger-tempest-plugin/tempest_setup/ranger-tempest.sh b/ranger-tempest-plugin/tempest_setup/ranger-tempest.sh new file mode 100755 index 00000000..0c7f9d88 --- /dev/null +++ b/ranger-tempest-plugin/tempest_setup/ranger-tempest.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# Shell script to move to tempest, copy tempest.conf, and +# initialize tempest tests using stestr +# It should be noted that this script can not be ran out of +# the box and does require configuration before running. + +function execute_tests { + # move to Tempest directory + cd ${TEMPEST_DIRECTORY} + + # check for necessary folders, make them if not found + if [[ ! -d tempest_lock ]]; then + mkdir tempest_lock + fi + if [[ ! -d images ]]; then + mkdir images + fi + if [[ ! -d .stestr ]]; then + stestr init + fi + + # sets RANGER_DIRECTORY to relevant subdirectory and copies files for tests + RANGER_DIRECTORY=${RANGER_DIRECTORY}/ranger-tempest-plugin/tempest_setup + + # check for necessary files, copy them from ranger if not found + if [[ ! -e ./.stestr.conf ]]; then + cp ${RANGER_DIRECTORY}/.stestr.conf ./ + fi + if [[ ! -e etc/tempest.conf ]]; then + cp ${RANGER_DIRECTORY}/tempest.conf etc/ + fi + if [[ ! -e etc/create_tenant.sh ]]; then + cp ${RANGER_DIRECTORY}/create_tenant.sh etc/ + fi + if [[ ! -e etc/accounts.yaml ]]; then + cp ${RANGER_DIRECTORY}/accounts.yaml etc/ + fi + + # runs tests using stestr and regex, ex: ranger_tempest_plugin.tests.api.test_regions + stestr run --concurrency ${CONCURRENCY} --log-file /home/stack/tempest_run.log ${TEST_REGEX} +} + +usage() +{ +cat << EOF +usage: ./ranger-tempest.sh -t TEMPEST_DIRECTORY -c CONCURRENCY -r RANGER_DIRECTORY -f TEST_REGEX + +This script automates a few steps necessary to run Tempest against Ranger + +OPTIONS: + -h Show this message + -t The Tempest Folder fully-formed path + -c Concurrency + -r The location of your Ranger folder + -f The regex representing the tests that will be ran +EOF +} + +TEMPEST_DIRECTORY= +CONCURRENCY=1 +TEST_REGEX= +RANGER_DIRECTORY= +while getopts "ht:c:f:r:" OPTION +do + case $OPTION in + h) + usage + exit 1 + ;; + t) + TEMPEST_DIRECTORY=$OPTARG + ;; + c) + CONCURRENCY=$OPTARG + ;; + f) + TEST_REGEX=$OPTARG + ;; + r) + RANGER_DIRECTORY=$OPTARG + ;; + ?) + usage + exit + ;; + esac +done + +if [[ -z $TEMPEST_DIRECTORY ]]; then + echo "The script requires the location of the Tempest folder" + usage + exit 1 +#elif [[ -z $TEST_REGEX ]]; then +# echo "The script expects a regex of tests to run" +# usage +# exit 1 +elif [[ -z $RANGER_DIRECTORY ]]; then + echo "This script requires the location of the Ranger folder" + usage + exit 1 +else + execute_tests +fi +