Skip to content

Commit

Permalink
Add checkPodSpecBySelectorWithTimeout function
Browse files Browse the repository at this point in the history
Similar to checkPodStatusWithTimeout(), but uses selectors and checks
the pod spec for matches.

Signed-off-by: Sergey Stankevich <[email protected]>
  • Loading branch information
stankevich committed Nov 8, 2024
1 parent adb38e5 commit 2553001
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/endtoend/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,32 @@ function dockerContainersInspect() {
done
}

function checkPodSpecBySelectorWithTimeout() {
local pod_selector="$1"
local pods_expected="$2"
local spec_matcher="$3"

local out pods_matched

for i in {1..1200}; do
# YAML output is convenient to grep
out="$(kubectl get pods --selector="${pod_selector}" --output=yaml)"
pods_matched="$(echo "${out}" | grep -cE -- "${spec_matcher}")"

if [[ "${pods_matched}" -eq "${pods_expected}" ]]; then
echo "${spec_matcher} found"
return
fi
sleep 1
done

echo "ERROR: checkPodSpecBySelectorWithTimeout timeout, didn't get ${pods_expected} matches for: ${spec_matcher}"
if echo "${pod_selector}" | grep -q "vttablet"; then
printMysqlErrorFiles
fi
exit 1
}

# checkPodStatusWithTimeout:
# $1: regex used to match pod names
# $2: number of pods to match (default: 1)
Expand Down

0 comments on commit 2553001

Please sign in to comment.