diff --git a/README.md b/README.md index e836ec9..d1ab1c0 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ Automated validation tool for testing DevWorkspace instances on OpenShift cluste # Debug mode - verbose + runs only first test + no cleanup ./dw-auto-validate.sh -d +# Skip interactive scenario choice (valid values: sshd, jetbrains, vscode) +./dw-auto-validate.sh -s vscode + # Help ./dw-auto-validate.sh -h ``` @@ -56,6 +59,7 @@ Automated validation tool for testing DevWorkspace instances on OpenShift cluste - `-v`: Verbose mode - enables `log()` output, shows detailed progress - `-f`: Full mode - uses `images/images-full.txt` and `devfiles/devfiles-full.txt` instead of their default counterparts - `-d`: Debug mode - enables verbose + debug output, runs only first test, skips cleanup +- `-s `: Skip interactive scenario prompt by specifying the scenario directly (`sshd`, `jetbrains`, or `vscode`) - `-h`: Help - displays usage information **Debug mode specifics**: Sets `DEBUG=1`, `FULL=0`, `VERBOSE=1`, runs only the first test iteration (`[[ ${DEBUG} -eq 1 && ${total_count} == 1 ]] && continue`), skips cleanup to allow resource inspection. diff --git a/dw-auto-validate.sh b/dw-auto-validate.sh index 85c4298..3b02b3d 100755 --- a/dw-auto-validate.sh +++ b/dw-auto-validate.sh @@ -2,6 +2,7 @@ VERBOSE=0 FULL=0 DEBUG=0 +SCENARIO="" # colors for fun RED='\033[1;91m' @@ -16,9 +17,9 @@ NC='\033[0m' # No Color # Parameters for fun or experts # ################################# -while getopts "vfdh" o; do +while getopts "vfdhs:" o; do case "${o}" in - v) + v) VERBOSE=1 echo "Using verbose mode." ;; @@ -32,8 +33,16 @@ while getopts "vfdh" o; do VERBOSE=1 echo -e "Using verbose mode AND do not clean resource. ${YELLOW}WARNING${NC} - This mode uses only the first item of the test matrix." ;; + s) + SCENARIO="${OPTARG}" + if [[ ! "${SCENARIO}" =~ ^(sshd|jetbrains|vscode)$ ]]; then + echo -e "${RED}Error:${NC} Invalid scenario '${SCENARIO}'. Valid options are: sshd, jetbrains, vscode." >&2 + exit 1 + fi + echo "Using scenario '${SCENARIO}'." + ;; h) - echo "Help: This script accepts -v for verbose mode, -d for debug mode and -f for full images test and -h for help." + echo "Help: This script accepts -v for verbose mode, -d for debug mode, -f for full images test, -s to skip scenario choice (sshd|jetbrains|vscode) and -h for help." ;; \?) echo "Invalid option: -$OPTARG" @@ -122,17 +131,18 @@ else fi # Choose scenario -echo -e "${BLUE}Choose the dedicated scenario to run the validation test suite.${NC}\n1-sshd\n2-jetbrains\n3-vscode" -SCENARIO="" -while true; do - read -p "(1/2/3)? : " scenario - case $scenario in - 1 ) SCENARIO=sshd; break;; - 2 ) SCENARIO=jetbrains; break;; - 3 ) SCENARIO=vscode; break;; - * ) echo "Please answer 1 or 2 or 3";; - esac -done +if [ -z "${SCENARIO}" ]; then + echo -e "${BLUE}Choose the dedicated scenario to run the validation test suite.${NC}\n1-sshd\n2-jetbrains\n3-vscode" + while true; do + read -p "(1/2/3)? : " scenario + case $scenario in + 1 ) SCENARIO=sshd; break;; + 2 ) SCENARIO=jetbrains; break;; + 3 ) SCENARIO=vscode; break;; + * ) echo "Please answer 1 or 2 or 3";; + esac + done +fi # Read values from scenario's setting . settings/settings-${SCENARIO}.env