aboutsummaryrefslogtreecommitdiffstats
path: root/kud
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2021-05-21 00:23:45 +0000
committerGerrit Code Review <gerrit@onap.org>2021-05-21 00:23:45 +0000
commit99f2be307f194e1f6a60e4098e82f6775c8dad5b (patch)
tree1190ae2a816a5d224e2c6195c91e0a7e9c8db8b3 /kud
parent5a9b1ba5df2ec5ace82954a3e0b342156ed3745d (diff)
parent201a95507e2743beba871f51ffae55aaa5ed5ff4 (diff)
Merge "Exit cmk test script on error"
Diffstat (limited to 'kud')
-rwxr-xr-xkud/tests/cmk.sh32
1 files changed, 19 insertions, 13 deletions
diff --git a/kud/tests/cmk.sh b/kud/tests/cmk.sh
index 1a14b5b8..e8e77c6c 100755
--- a/kud/tests/cmk.sh
+++ b/kud/tests/cmk.sh
@@ -1,4 +1,7 @@
#!/bin/bash
+
+source _common.sh
+
ENV=$(kubectl get nodes --all-namespaces | wc -l)
if [[ $ENV -gt 2 ]]; then
COMPUTE_NODE=$(kubectl get nodes --all-namespaces | grep -v master | awk 'NR==2{print $1}')
@@ -31,13 +34,11 @@ function wait_for_pod_up {
done
}
-
function start_nginx_pod {
kubectl delete deployment -n default nginx --ignore-not-found=true
kubectl create deployment nginx --image=nginx
- sleep 2
+ kubectl wait deployment nginx --for=condition=available
nginx_pod=$(kubectl get pods --all-namespaces| grep nginx | awk 'NR==1{print $2}')
- wait_for_pod_up $nginx_pod
kubectl delete deployment -n default nginx --ignore-not-found=true
pod_status="Running"
until [[ $pod_status == "" ]]; do
@@ -59,8 +60,8 @@ for ((i=0;i<$num;i++)); do
echo "##################################"
if [ "${case[$POOL]}" == "exclusive" ]; then
echo "TC: to allocate ${case[$CORE]} CPU(s) from pool of ${case[$POOL]} on node of ${case[$NODE]}"
- TOTAL=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq .spec.report.description.pools.${case[$POOL]} | jq .cpuLists | awk -F '{' '{print $(NF)}' | awk -F '}' '{print $(NF)}' | awk -F ',' '{print $(NF)}' | grep "\"tasks\": \[" | wc -l)
- echo "ready to generate yaml"
+ TOTAL=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq --arg pool "${case[$POOL]}" '.spec.report.description.pools[$pool].cpuLists|length')
+ echo "ready to generate yaml"
cat << EOF > $DIR/$pod_name.yaml
apiVersion: v1
kind: Pod
@@ -113,8 +114,11 @@ EOF
done
echo "waiting for CPU allocation finished ..."
rest=$TOTAL
- until [[ $TOTAL -gt $rest ]]; do
- rest=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq .spec.report.description.pools.exclusive | jq .cpuLists | awk -F '{' '{print $(NF)}' | awk -F '}' '{print $(NF)}' | awk -F ',' '{print $(NF)}' | grep "\"tasks\": \[\]" | wc -l)
+ timeout=0
+ until [[ $TOTAL -gt $rest || $timeout == 180 ]]; do
+ sleep 1
+ rest=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq '.spec.report.description.pools.exclusive.cpuLists[].tasks|select(type=="array" and length==0)' | wc -l) || echo "$TOTAL"
+ timeout=$((timeout+1))
done
let allocated=`expr $TOTAL - $rest`
echo "The allocated CPU amount is:" $allocated
@@ -123,7 +127,7 @@ EOF
if [[ $allocated == ${case[$CORE]} ]]; then
echo "CPU was allocated as expected, TC passed !!"
else
- echo "failed to allocate CPU, TC failed !!"
+ echo "failed to allocate CPU ($allocated != ${case[$CORE]}), TC failed !!"
fi
rm -f $DIR/$pod_name.yaml
echo "ready to delete pod"
@@ -132,6 +136,7 @@ EOF
echo "##################################"
echo
echo
+ [[ $allocated == ${case[$CORE]} ]]
else
echo "TC: to allocate CPU(s) from pool of ${case[$POOL]} on node of ${case[$NODE]}"
echo "ready to generate yaml"
@@ -207,10 +212,10 @@ EOF
echo "waiting for CPU allocation finished ..."
rest=0
timeout=0
- until [ $rest == 2 -o $timeout == 180 ]; do
- rest=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq .spec.report.description.pools.shared | jq .cpuLists | awk -F '{' '{print $(NF)}' | awk -F '}' '{print $(NF)}' | grep -v "cpus" | grep " "| grep -v "tasks"| grep -v "\]" | wc -l)
- sleep -- 1
- let timeout++
+ until [[ $rest == 2 || $timeout == 180 ]]; do
+ sleep 1
+ rest=$(kubectl get cmk-nodereport ${case[$NODE]} -o json | jq '.spec.report.description.pools.shared.cpuLists[].tasks' | jq length) || echo "0"
+ timeout=$((timeout+1))
done
echo "The CPU allocated in shared pool for 2 tasks"
echo "deploy a nginx pod"
@@ -218,7 +223,7 @@ EOF
if [[ $rest == 2 ]]; then
echo "CPU was allocated as expected, TC passed !!"
else
- echo "failed to allocate CPU, TC failed !!"
+ echo "failed to allocate CPU ($rest != 2), TC failed !!"
fi
rm -f $DIR/$pod_name.yaml
echo "ready to delete pod"
@@ -227,5 +232,6 @@ EOF
echo "##################################"
echo
echo
+ [[ $rest == 2 ]]
fi
done