update funtion_test.sh support CLI mode
This commit is contained in:
@@ -1,54 +1,118 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "
|
show_help() {
|
||||||
--folder Specify a single folder to run from a collection.
|
echo "
|
||||||
1.Query
|
Usage: $(basename "$0") [-f FOLDER_NUMBER] [-a] [-v] [-e]
|
||||||
2.Dataset
|
|
||||||
3.Database
|
Options:
|
||||||
4.Util
|
-f FOLDER_NUMBER Specify a single folder to run from a collection:
|
||||||
5.Troubleshooting
|
1. Query
|
||||||
6.HOS
|
2. Dataset
|
||||||
7.Knowledge Base File
|
3. Database
|
||||||
|
4. Util
|
||||||
|
5. Troubleshooting
|
||||||
|
6. HOS
|
||||||
|
7. Knowledge Base File
|
||||||
|
-a Run all options [1-7]
|
||||||
|
-v Enable verbose reporting
|
||||||
|
-e Enable emojitrain reporting
|
||||||
|
-h, --help Show this help message and exit
|
||||||
"
|
"
|
||||||
|
}
|
||||||
|
|
||||||
BASE_DIR="$(dirname "$(pwd)")"
|
BASE_DIR="$(dirname "$(pwd)")"
|
||||||
CONFIG_PATH="$BASE_DIR/config"
|
CONFIG_PATH="$BASE_DIR/config"
|
||||||
|
FOLDER=""
|
||||||
|
ALL=false
|
||||||
|
VERBOSE_FLAG=false
|
||||||
|
EMOJITRAIN_FLAG=false
|
||||||
|
|
||||||
#COLLECTION_FILE=`find $BIN_PATH -name '*'function-test-collection.json|xargs| awk -F" " '{print $1}'`
|
# Flag to check if any valid option is provided
|
||||||
#ENV_FILE=environment.json
|
VALID_OPTION_PROVIDED=false
|
||||||
|
|
||||||
FOLDER="--folder "
|
# Parse command-line arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
if [[ -n "$1" ]];then
|
case $1 in
|
||||||
case $1 in
|
-f)
|
||||||
1)
|
VALID_OPTION_PROVIDED=true
|
||||||
FOLDER+="Query"
|
if [[ -n $2 && $2 =~ ^[1-7]$ ]]; then
|
||||||
;;
|
case $2 in
|
||||||
2)
|
1) FOLDER="--folder Query" ;;
|
||||||
FOLDER+="Dataset"
|
2) FOLDER="--folder Dataset" ;;
|
||||||
;;
|
3) FOLDER="--folder Database" ;;
|
||||||
3)
|
4) FOLDER="--folder Util" ;;
|
||||||
FOLDER+="Database"
|
5) FOLDER="--folder Troubleshooting" ;;
|
||||||
;;
|
6) FOLDER="--folder HOS" ;;
|
||||||
4)
|
7) FOLDER="--folder Knowledge Base File" ;;
|
||||||
FOLDER+="Util"
|
esac
|
||||||
;;
|
shift 2
|
||||||
5)
|
else
|
||||||
FOLDER+="Troubleshooting"
|
echo "Error: Invalid folder number."
|
||||||
;;
|
show_help
|
||||||
6)
|
exit 1
|
||||||
FOLDER+="HOS"
|
fi
|
||||||
;;
|
;;
|
||||||
7)
|
-a)
|
||||||
FOLDER+="Knowledge Base File"
|
VALID_OPTION_PROVIDED=true
|
||||||
;;
|
ALL=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v)
|
||||||
|
VERBOSE_FLAG=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-e)
|
||||||
|
EMOJITRAIN_FLAG=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
FOLDER=""
|
echo "Error: Unknown option $1"
|
||||||
esac
|
show_help
|
||||||
else
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! $VALID_OPTION_PROVIDED; then
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $ALL; then
|
||||||
FOLDER=""
|
FOLDER=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $FOLDER
|
NEW_MAN_OPTS=(
|
||||||
|
"$CONFIG_PATH/tsg-olap-function-test-collection.json"
|
||||||
|
-n 1
|
||||||
|
-e "$CONFIG_PATH/environment.json"
|
||||||
|
-g "$CONFIG_PATH/globals.json"
|
||||||
|
--delay-request 200
|
||||||
|
--timeout-script 10000
|
||||||
|
--timeout-request 300000
|
||||||
|
--timeout 3600000
|
||||||
|
--insecure
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add verbose reporting option if enabled
|
||||||
|
if $VERBOSE_FLAG; then
|
||||||
|
NEW_MAN_OPTS+=(--verbose)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add folder option if set
|
||||||
|
if [[ -n $FOLDER ]]; then
|
||||||
|
NEW_MAN_OPTS+=($FOLDER)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add emojitrain reporting option if enabled
|
||||||
|
if $EMOJITRAIN_FLAG; then
|
||||||
|
NEW_MAN_OPTS+=(-r emojitrain)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the newman command
|
||||||
|
newman run "${NEW_MAN_OPTS[@]}"
|
||||||
|
|
||||||
newman run $CONFIG_PATH/tsg-olap-function-test-collection.json -n 1 -e $CONFIG_PATH/environment.json -g $CONFIG_PATH/globals.json --verbose --delay-request 200 --timeout-script 10000 --timeout-request 300000 --timeout 3600000 --insecure \
|
|
||||||
$FOLDER
|
|
||||||
|
|||||||
@@ -1,54 +1,118 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "
|
show_help() {
|
||||||
--folder Specify a single folder to run from a collection.
|
echo "
|
||||||
1.Query
|
Usage: $(basename "$0") [-f FOLDER_NUMBER] [-a] [-v] [-e]
|
||||||
2.Dataset
|
|
||||||
3.Database
|
Options:
|
||||||
4.Util
|
-f FOLDER_NUMBER Specify a single folder to run from a collection:
|
||||||
5.Troubleshooting
|
1. Query
|
||||||
6.HOS
|
2. Dataset
|
||||||
7.Knowledge Base File
|
3. Database
|
||||||
|
4. Util
|
||||||
|
5. Troubleshooting
|
||||||
|
6. HOS
|
||||||
|
7. Knowledge Base File
|
||||||
|
-a Run all options [1-7]
|
||||||
|
-v Enable verbose reporting
|
||||||
|
-e Enable emojitrain reporting
|
||||||
|
-h, --help Show this help message and exit
|
||||||
"
|
"
|
||||||
|
}
|
||||||
|
|
||||||
BASE_DIR="$(dirname "$(pwd)")"
|
BASE_DIR="$(dirname "$(pwd)")"
|
||||||
CONFIG_PATH="$BASE_DIR/config"
|
CONFIG_PATH="$BASE_DIR/config"
|
||||||
|
FOLDER=""
|
||||||
|
ALL=false
|
||||||
|
VERBOSE_FLAG=false
|
||||||
|
EMOJITRAIN_FLAG=false
|
||||||
|
|
||||||
#COLLECTION_FILE=`find $BIN_PATH -name '*'function-test-collection.json|xargs| awk -F" " '{print $1}'`
|
# Flag to check if any valid option is provided
|
||||||
#ENV_FILE=environment.json
|
VALID_OPTION_PROVIDED=false
|
||||||
|
|
||||||
FOLDER="--folder "
|
# Parse command-line arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
if [[ -n "$1" ]];then
|
case $1 in
|
||||||
case $1 in
|
-f)
|
||||||
1)
|
VALID_OPTION_PROVIDED=true
|
||||||
FOLDER+="Query"
|
if [[ -n $2 && $2 =~ ^[1-7]$ ]]; then
|
||||||
;;
|
case $2 in
|
||||||
2)
|
1) FOLDER="--folder Query" ;;
|
||||||
FOLDER+="Dataset"
|
2) FOLDER="--folder Dataset" ;;
|
||||||
;;
|
3) FOLDER="--folder Database" ;;
|
||||||
3)
|
4) FOLDER="--folder Util" ;;
|
||||||
FOLDER+="Database"
|
5) FOLDER="--folder Troubleshooting" ;;
|
||||||
;;
|
6) FOLDER="--folder HOS" ;;
|
||||||
4)
|
7) FOLDER="--folder Knowledge Base File" ;;
|
||||||
FOLDER+="Util"
|
esac
|
||||||
;;
|
shift 2
|
||||||
5)
|
else
|
||||||
FOLDER+="Troubleshooting"
|
echo "Error: Invalid folder number."
|
||||||
;;
|
show_help
|
||||||
6)
|
exit 1
|
||||||
FOLDER+="HOS"
|
fi
|
||||||
;;
|
;;
|
||||||
7)
|
-a)
|
||||||
FOLDER+="Knowledge Base File"
|
VALID_OPTION_PROVIDED=true
|
||||||
;;
|
ALL=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v)
|
||||||
|
VERBOSE_FLAG=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-e)
|
||||||
|
EMOJITRAIN_FLAG=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
FOLDER=""
|
echo "Error: Unknown option $1"
|
||||||
esac
|
show_help
|
||||||
else
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! $VALID_OPTION_PROVIDED; then
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $ALL; then
|
||||||
FOLDER=""
|
FOLDER=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $FOLDER
|
NEW_MAN_OPTS=(
|
||||||
|
"$CONFIG_PATH/tsg-olap-function-test-collection.json"
|
||||||
|
-n 1
|
||||||
|
-e "$CONFIG_PATH/environment.json"
|
||||||
|
-g "$CONFIG_PATH/globals.json"
|
||||||
|
--delay-request 200
|
||||||
|
--timeout-script 10000
|
||||||
|
--timeout-request 300000
|
||||||
|
--timeout 3600000
|
||||||
|
--insecure
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add verbose reporting option if enabled
|
||||||
|
if $VERBOSE_FLAG; then
|
||||||
|
NEW_MAN_OPTS+=(--verbose)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add folder option if set
|
||||||
|
if [[ -n $FOLDER ]]; then
|
||||||
|
NEW_MAN_OPTS+=($FOLDER)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add emojitrain reporting option if enabled
|
||||||
|
if $EMOJITRAIN_FLAG; then
|
||||||
|
NEW_MAN_OPTS+=(-r emojitrain)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the newman command
|
||||||
|
newman run "${NEW_MAN_OPTS[@]}"
|
||||||
|
|
||||||
newman run $CONFIG_PATH/tsg-olap-function-test-collection.json -n 1 -e $CONFIG_PATH/environment.json -g $CONFIG_PATH/globals.json --verbose --delay-request 200 --timeout-script 10000 --timeout-request 300000 --timeout 3600000 --insecure \
|
|
||||||
$FOLDER
|
|
||||||
|
|||||||
Reference in New Issue
Block a user