Skip to content

Commit ca9acdd

Browse files
committed
feat: create_sleep_and_telnet_workloads in run_test.sh
Signed-off-by: Yash Patel <[email protected]>
1 parent f6a1444 commit ca9acdd

File tree

1 file changed

+93
-4
lines changed

1 file changed

+93
-4
lines changed

test/e2e/run_test.sh

Lines changed: 93 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ spec:
155155
port: 15008
156156
protocol: HBONE
157157
EOF
158-
POD=$(kubectl get pods -n $NAMESPACE \
158+
POD=$(kubectl get pods \
159159
--no-headers \
160160
-o custom-columns=NAME:.metadata.name \
161161
| grep '^waypoint' \
162162
| head -n1)
163163
if [[ -z $POD ]]; then
164-
echo "No pod found with prefix 'waypoint' in namespace $NAMESPACE" >&2
164+
echo "No pod found with prefix 'waypoint' in namespace default" >&2
165165
exit 1
166166
fi
167167
echo "Watching pod $POD until it enters Ready..."
168168
while true; do
169-
ready=$(kubectl get pod $POD -n $NAMESPACE \
169+
ready=$(kubectl get pod $POD \
170170
-o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
171171
if [[ "$ready" == "True" ]]; then
172172
echo "✅ Pod $POD is Ready!"
@@ -175,7 +175,6 @@ EOF
175175
echo "⏳ Pod $POD is not ready (status: $ready); sleeping 15s..."
176176
sleep 15
177177
done
178-
179178
}
180179

181180
export KIND_REGISTRY_NAME="kind-registry"
@@ -250,6 +249,95 @@ function cleanup_docker_registry() {
250249
docker rm "${KIND_REGISTRY_NAME}" || echo "Failed to remove or no such registry '${KIND_REGISTRY_NAME}'."
251250
}
252251

252+
function create_sleep_and_telnet_workloads() {
253+
cat <<EOF | kubectl apply -f -
254+
apiVersion: v1
255+
kind: Pod
256+
metadata:
257+
name: telnet-server
258+
labels:
259+
app: busybox-telnet
260+
spec:
261+
containers:
262+
- name: busybox
263+
image: busybox:uclibc
264+
command: ["/bin/sh", "-c", "telnetd -F -p 23 && sleep infinity"]
265+
ports:
266+
- containerPort: 23
267+
restartPolicy: Always
268+
---
269+
apiVersion: v1
270+
kind: Service
271+
metadata:
272+
name: telnet-service
273+
spec:
274+
selector:
275+
app: busybox-telnet
276+
ports:
277+
- protocol: TCP
278+
port: 23
279+
targetPort: 23
280+
type: ClusterIP
281+
EOF
282+
283+
cat <<EOF | kubectl apply -f -
284+
apiVersion: v1
285+
kind: Pod
286+
metadata:
287+
name: sleep
288+
labels:
289+
app: busybox
290+
spec:
291+
containers:
292+
- name: busybox
293+
image: busybox:uclibc
294+
command: ["/bin/sh", "-c", "sleep infinity"]
295+
tty: true
296+
restartPolicy: Always
297+
EOF
298+
POD=$(kubectl get pods \
299+
--no-headers \
300+
-o custom-columns=NAME:.metadata.name \
301+
| grep '^telnet-server' \
302+
| head -n1)
303+
if [[ -z $POD ]]; then
304+
echo "No pod found with prefix 'telnet-server' in namespace default" >&2
305+
exit 1
306+
fi
307+
echo "Watching pod $POD until it enters Ready..."
308+
while true; do
309+
ready=$(kubectl get pod $POD \
310+
-o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
311+
if [[ "$ready" == "True" ]]; then
312+
echo "✅ Pod $POD is Ready!"
313+
break
314+
fi
315+
echo "⏳ Pod $POD is not ready (status: $ready); sleeping 15s..."
316+
sleep 15
317+
done
318+
319+
POD=$(kubectl get pods \
320+
--no-headers \
321+
-o custom-columns=NAME:.metadata.name \
322+
| grep '^sleep' \
323+
| head -n1)
324+
if [[ -z $POD ]]; then
325+
echo "No pod found with prefix 'sleep' in namespace default" >&2
326+
exit 1
327+
fi
328+
echo "Watching pod $POD until it enters Ready..."
329+
while true; do
330+
ready=$(kubectl get pod $POD \
331+
-o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
332+
if [[ "$ready" == "True" ]]; then
333+
echo "✅ Pod $POD is Ready!"
334+
break
335+
fi
336+
echo "⏳ Pod $POD is not ready (status: $ready); sleeping 15s..."
337+
sleep 15
338+
done
339+
}
340+
253341
PARAMS=()
254342

255343
while (( "$#" )); do
@@ -314,6 +402,7 @@ if [[ -z "${SKIP_BUILD:-}" ]]; then
314402
setup_kind_registry
315403
build_and_push_images
316404
setup_waypoint
405+
create_sleep_and_telnet_workloads
317406
fi
318407

319408
kubectl config use-context "kind-$NAME"

0 commit comments

Comments
 (0)