This handles intermittent Err* Pod status such as ErrImagePull.
Additionally, remove the duplication of wait_for_pod among the tests.
Issue-ID: MULTICLOUD-1435
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Change-Id: I70c69e0427b80e31b2f97515ebdbc3496a91ced1
done
}
-# wait_for_pod() - Wait until first pod matched by kubectl filters is in running status
+# wait_for_pod() - Wait until pods matched by kubectl filters is in running status
function wait_for_pod {
#Example usage:
# wait_for_pods example_pod
# wait_for_pods --namespace test different_pod
# wait_for_pods -n test -l app=plugin_test
-
- status_phase=""
- while [[ "$status_phase" != "Running" ]]; do
- new_phase="$(kubectl get pods -o 'go-template={{ index .items 0 "status" "phase" }}' "$@" )"
- if [[ "$new_phase" != "$status_phase" ]]; then
- echo "$(date +%H:%M:%S) - Filter=[$*] : $new_phase"
- status_phase="$new_phase"
- fi
- if [[ "$new_phase" == "Err"* ]]; then
- exit 1
- fi
- done
+ kubectl wait --for=condition=Ready --timeout=600s pod "$@"
}
# wait_for_deployment() - Wait until the deployment is ready
#!/bin/bash
source _common.sh
+source _functions.sh
ENV=$(kubectl get nodes --all-namespaces | wc -l)
if [[ $ENV -gt 2 ]]; then
DIR=/tmp
pod_name=cmk-test-pod
-function wait_for_pod_up {
- status_phase=""
- while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods "$@" | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $@ : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod $@ is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
- done
-}
-
function start_nginx_pod {
kubectl delete deployment -n default nginx --ignore-not-found=true
kubectl create deployment nginx --image=nginx
sleep 2
echo "waiting for pod up"
for pod in $pod_name; do
- wait_for_pod_up $pod
+ wait_for_pod $pod
done
echo "waiting for CPU allocation finished ..."
rest=$TOTAL
sleep 2
echo "waiting for pod up"
for pod in $pod_name; do
- wait_for_pod_up $pod
+ wait_for_pod $pod
done
echo "waiting for CPU allocation finished ..."
rest=0
set -o nounset
set -o pipefail
-#source _common_test.sh
-#source _common.sh
-#source _functions.sh
+source _functions.sh
kata_pods="kata-qemu kata-clh"
-function wait_for_pod {
- status_phase=""
- while [[ "$status_phase" != "Running" ]]; do
- new_phase="$(kubectl get pods -o wide | grep ^$1 | awk '{print $3}')"
- if [[ "$new_phase" != "$status_phase" ]]; then
- status_phase="$new_phase"
- fi
- if [[ "$new_phase" == "Err"* ]]; then
- exit 1
- fi
- sleep 2
- done
-}
-
for pod in ${kata_pods};do
echo "Deploying ${pod} pod"
kubectl apply -f ${pod}.yml
set -o pipefail
source _common_test.sh
+source _functions.sh
rm -f $HOME/*.yaml
pod_name=nfd-pod
kubectl create -f $HOME/$pod_name-$podType.yaml --validate=false
for pod in $pod_name; do
- status_phase=""
- while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod-$podType : $new_phase"
- status_phase=$new_phase
- fi
-
- if [[ $new_phase == "Running" ]]; then
- echo " Test is complete.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
- done
+ wait_for_pod $pod
done
kubectl delete pod $pod_name
while kubectl get pod $pod_name &>/dev/null; do
set -o pipefail
+source _functions.sh
+
qat_capable_nodes=$(kubectl get nodes -o json | jq -r '.items[] | select((.status.capacity."qat.intel.com/cy2_dc2"!=null) and ((.status.capacity."qat.intel.com/cy2_dc2"|tonumber)>=1)) | .metadata.name')
if [ -z "$qat_capable_nodes" ]; then
echo "This test case cannot run. QAT device unavailable."
POD
kubectl create -f $HOME/$pod_name.yaml --validate=false
for pod in $pod_name; do
- status_phase=""
- while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
- done
+ wait_for_pod $pod_name
done
allocated_node_resource=$(kubectl describe node | grep "qat.intel.com" | tail -n1 |awk '{print $(NF)}')
set -o pipefail
+source _functions.sh
+
sriov_capable_nodes=$(kubectl get nodes -o json | jq -r '.items[] | select((.status.capacity."intel.com/intel_sriov_nic"!=null) and ((.status.capacity."intel.com/intel_sriov_nic"|tonumber)>=2)) | .metadata.name')
if [ -z "$sriov_capable_nodes" ]; then
echo "SRIOV test case cannot run on the cluster."
kubectl create -f $HOME/$pod_name-$podType.yaml --validate=false
for pod in $pod_name; do
- status_phase=""
- while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod-$podType : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
- done
+ wait_for_pod $pod_name
done
allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_nic" | tail -n1 |awk '{print $(NF)}')
set -o pipefail
+source _functions.sh
+
sriov_capable_nodes=$(kubectl get nodes -o json | jq -r '.items[] | select((.status.capacity."intel.com/intel_sriov_700"!=null) and ((.status.capacity."intel.com/intel_sriov_700"|tonumber)>=2)) | .metadata.name')
if [ -z "$sriov_capable_nodes" ]; then
echo "SRIOV test case cannot run on the cluster."
kubectl create -f $HOME/$pod_name-$podType.yaml --validate=false
for pod in $pod_name; do
- status_phase=""
- while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod-$podType : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
- done
+ wait_for_pod $pod_name
done
allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
kubectl delete pod $pod_name --ignore-not-found=true --now --wait
kubectl create -f ${CSAR_DIR}/${csar_id}/$pod_name.yaml --validate=false
-status_phase=""
-while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod_name | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod_name : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
-done
+wait_for_pod $pod_name
uid=$(kubectl get pod pod-topology-manager -o jsonpath='{.metadata.uid}')
node_name=$(kubectl get pod $pod_name -o jsonpath='{.spec.nodeName}')
kubectl delete pod $pod_name --ignore-not-found=true --now --wait
kubectl create -f ${CSAR_DIR}/${csar_id}/$pod_name.yaml --validate=false
-status_phase=""
-while [[ $status_phase != "Running" ]]; do
- new_phase=$(kubectl get pods $pod_name | awk 'NR==2{print $3}')
- if [[ $new_phase != $status_phase ]]; then
- echo "$(date +%H:%M:%S) - $pod_name : $new_phase"
- status_phase=$new_phase
- fi
- if [[ $new_phase == "Running" ]]; then
- echo "Pod is up and running.."
- fi
- if [[ $new_phase == "Err"* ]]; then
- exit 1
- fi
-done
+wait_for_pod $pod_name
uid=$(kubectl get pod pod-topology-manager -o jsonpath='{.metadata.uid}')
node_name=$(kubectl get pod $pod_name -o jsonpath='{.spec.nodeName}')