X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Fcommon%2Ftestcase_common.sh;h=78f27fd2662d8ada23188d7d5d2cf334906a5b54;hb=8fbc63697f2edaaf2c9db40f54b318e7211361e2;hp=d16ee6ec7a25fce2e82df2c8be0d75a3016fa010;hpb=2918bef3d237c99e6cf7e9c1ab1722781128617b;p=nonrtric.git diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index d16ee6ec..78f27fd2 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -30,7 +30,7 @@ __print_args() { echo " [--repo-policy local|remote] [--cluster-timeout ] [--print-stats]" echo " [--override ] [--pre-clean] [--gen-stats] [--delete-namespaces]" echo " [--delete-containers] [--endpoint-stats] [--kubeconfig ] [--host-path-dir ]" - echo " [--kubecontext ]" + echo " [--kubecontext ] [--docker-host ] [--docker-proxy ]" } if [ $# -eq 1 ] && [ "$1" == "help" ]; then @@ -68,6 +68,8 @@ if [ $# -eq 1 ] && [ "$1" == "help" ]; then echo "--kubeconfig - Configure kubectl to use cluster specific cluster config file" echo "--host-path-dir - (Base-)path on local-hostmounted to all VMs (nodes), for hostpath volumes in kube" echo "--kubecontext - Configure kubectl to use a certain context, e.g 'minikube'" + echo "--docker-host - Configure docker to use docker in e.g. a VM" + echo "--docker-proxy - Configure ip/host to docker when docker is running in a VM" echo "" echo "List of app short names supported: "$APP_SHORT_NAMES exit 0 @@ -268,6 +270,14 @@ DELETE_CONTAINERS=0 #Var to configure kubectl from a config file or context KUBECONF="" +#Localhost, may be set to another host/ip by cmd parameter +LOCALHOST_NAME="localhost" + +#Reseting vars related to token/keys used by kubeproxy when istio is enabled +#The vars are populated if istio is used in the testcase +KUBE_PROXY_CURL_JWT="" +KUBE_PROXY_ISTIO_JWKS_KEYS="" + #Var pointing to dir mounted to each kubernetes node (master and workers) #Persistent volumes using "hostpath" are allocated beneath the point. #Typically it is a dir on local host mounted to each VM running the master and worker. @@ -883,6 +893,55 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do fi else HOST_PATH_BASE_DIR=$1 + echo "Option set - Host path for kube set to: "$1 + shift + foundparm=0 + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--docker-host" ]; then + shift; + if [ -z "$1" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No url found for : '--docker-host'" + fi + else + export DOCKER_HOST="$1" + echo "Option set - DOCKER_HOST set to: "$1 + shift + foundparm=0 + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--docker-host" ]; then + shift; + if [ -z "$1" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No url found for : '--docker-host'" + fi + else + export DOCKER_HOST="$1" + echo "Option set - DOCKER_HOST set to: "$1 + shift + foundparm=0 + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--docker-proxy" ]; then + shift; + if [ -z "$1" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No ip/host found for : '--docker-proxy'" + fi + else + export LOCALHOST_NAME=$1 + echo "Option set - docker proxy set to: "$1 shift foundparm=0 fi @@ -905,11 +964,6 @@ if [ $paramerror -eq 1 ]; then exit 1 fi -#Localhost constants -LOCALHOST_NAME="localhost" -# if [ ! -z "$DOCKER_HOST" ]; then -# LOCALHOST_NAME=$(echo $DOCKER_HOST | awk -F[/:] '{print $4}' ) -# fi LOCALHOST_HTTP="http://$LOCALHOST_NAME" LOCALHOST_HTTPS="https://$LOCALHOST_NAME" @@ -1063,7 +1117,7 @@ if [ $RUNMODE == "DOCKER" ]; then echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED exit 1 else - tmp=$(docker-compose version --short) + tmp=$(docker-compose version) echo " docker-compose installed and using version $tmp" if [[ "$tmp" == *'v2'* ]]; then DOCKER_COMPOSE_VERION="V2" @@ -2293,7 +2347,7 @@ __kube_delete_all_resources() { namespace=$1 labelname=$2 labelid=$3 - resources="deployments replicaset statefulset services pods configmaps persistentvolumeclaims persistentvolumes serviceaccounts clusterrolebindings secrets" + resources="deployments replicaset statefulset services pods configmaps persistentvolumeclaims persistentvolumes serviceaccounts clusterrolebindings secrets authorizationpolicies requestauthentications" deleted_resourcetypes="" for restype in $resources; do ns_flag="-n $namespace" @@ -2306,7 +2360,7 @@ __kube_delete_all_resources() { ns_flag="" ns_text="" fi - result=$(kubectl $KUBECONF get $restype $ns_flag -o jsonpath='{.items[?(@.metadata.labels.'$labelname'=="'$labelid'")].metadata.name}') + result=$(kubectl $KUBECONF get $restype $ns_flag -o jsonpath='{.items[?(@.metadata.labels.'$labelname'=="'$labelid'")].metadata.name}' 2> /dev/null) if [ $? -eq 0 ] && [ ! -z "$result" ]; then deleted_resourcetypes=$deleted_resourcetypes" "$restype for resid in $result; do @@ -2409,7 +2463,7 @@ __kube_delete_namespace() { return 0 } -# Removes a namespace +# Removes and re-create a namespace # args: # (Not for test scripts) clean_and_create_namespace() { @@ -2427,7 +2481,22 @@ clean_and_create_namespace() { if [ $? -ne 0 ]; then return 1 fi +} +# Add/remove label on non-namespaced kube object +# args: