Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions test/network/wireserver_metadata_test.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
#!/bin/bash
# Optional per-pool parameterization: when POOL is set the throwaway pods are
# named "wget-${POOL}" and pinned to that agent pool via nodeSelector, so this
# test can run per-pool in parallel. When POOL is empty the behavior is
# unchanged (pod name "wget", no node selector).
# The two connectivity checks each run a throwaway busybox pod named
# "${POD_NAME}-wireserver-${SUFFIX}" / "${POD_NAME}-metadata-${SUFFIX}", where
# POD_NAME is "wget" (or "wget-${POOL}" when POOL is set) and SUFFIX is a random
# value for uniqueness across retries. When POOL is set the pods are also pinned
# to that agent pool. The pods always target Linux nodes (kubernetes.io/os=linux)
# so the Linux busybox image is never scheduled onto a Windows node, where it
# cannot be pulled/run and the check would time out.
POOL="${POOL:-}"
POD_NAME="wget"
OVERRIDES=()
NODE_SELECTOR='"kubernetes.io/os":"linux"'
if [ -n "$POOL" ]; then
POD_NAME="wget-${POOL}"
OVERRIDES=(--overrides="{\"spec\":{\"nodeSelector\":{\"agentpool\":\"${POOL}\"}}}")
NODE_SELECTOR="${NODE_SELECTOR},\"agentpool\":\"${POOL}\""
fi
OVERRIDES=(--overrides="{\"spec\":{\"nodeSelector\":{${NODE_SELECTOR}}}}")

kubectl run "$POD_NAME" -it --rm --image busybox --restart Never "${OVERRIDES[@]}" -- wget --timeout=3 --header=Metadata:true "http://168.63.129.16/machine/plugins?comp=nmagent&type=getinterfaceinfov1"
SUFFIX="${RANDOM}"
Comment thread
QxBytes marked this conversation as resolved.

kubectl run "$POD_NAME-wireserver-${SUFFIX}" -it --rm --image busybox --restart Never --pod-running-timeout=1m "${OVERRIDES[@]}" -- wget --timeout=3 --header=Metadata:true "http://168.63.129.16/machine/plugins?comp=nmagent&type=getinterfaceinfov1"
if [ $? -eq 0 ]; then
echo "wireserver connectivity expected to fail but succeeded"
exit 1
fi

kubectl run "$POD_NAME" -it --rm --image busybox --restart Never "${OVERRIDES[@]}" -- wget --timeout=3 --header=Metadata:true "http://169.254.169.254/metadata/instance?api-version=2021-02-01"
kubectl run "$POD_NAME-metadata-${SUFFIX}" -it --rm --image busybox --restart Never --pod-running-timeout=1m "${OVERRIDES[@]}" -- wget --timeout=3 --header=Metadata:true "http://169.254.169.254/metadata/instance?api-version=2021-02-01"
if [ $? -ne 0 ]; then
echo "metadata server connectivity expected to succeed but failed"
exit 1
Expand Down
Loading