From d48ad9482567bb19641b1cad04bd9f5acb5bd9a2 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 14 Aug 2024 15:30:49 +0000 Subject: [PATCH] tests: Add kubernetes stability test This PR adds a k8s stability test that will be part of the CoCo Kata stability tests that will run weekly. Signed-off-by: Gabriela Cervantes --- tests/stability/kubernetes_stability.sh | 55 +++++++++++++++++++ .../stability-test.yaml | 16 ++++++ 2 files changed, 71 insertions(+) create mode 100755 tests/stability/kubernetes_stability.sh create mode 100644 tests/stability/runtimeclass_workloads/stability-test.yaml diff --git a/tests/stability/kubernetes_stability.sh b/tests/stability/kubernetes_stability.sh new file mode 100755 index 0000000000..0b6b4b5066 --- /dev/null +++ b/tests/stability/kubernetes_stability.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright (c) 2024 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -o pipefail +set -x + +SCRIPT_PATH=$(dirname "$(readlink -f "$0")") +source "${SCRIPT_PATH}/../metrics/lib/common.bash" + +# Timeout is the duration of this test (seconds) +timeout=3600 +start_time=$(date +%s) +end_time=$((start_time+timeout)) + + +function main() { + # Check no processes are left behind + check_processes + + # Create pod + kubectl create -f "${SCRIPT_PATH}/runtimeclass_workloads/stability-test.yaml" + # Verify pod is running + pod_name="stability-test" + kubectl wait --for=condition=Ready --timeout=30s pod "${pod_name}" + + echo "Running kubernetes stability test" + count=0 + while [[ "${end_time}" > $(date +%s) ]]; do + echo "This is the number of iterations $count" + count=$((count+1)) + + cmd1="echo 'hello world' > file" + kubectl exec "${pod_name}" -- /bin/bash -c "${cmd1}" + + cmd2="rm -rf /file" + kubectl exec "${pod_name}" -- /bin/bash -c "${cmd2}" + + cmd3="touch /tmp/execWorks" + kubectl exec "${pod_name}" -- /bin/bash -c "${cmd3}" + + cmd4="ls /tmp | grep execWorks" + kubectl exec "${pod_name}" -- /bin/bash -c "${cmd4}" + + cmd5="rm -rf /tmp/execWorks" + kubectl exec "${pod_name}" -- /bin/bash -c "${cmd5}" + done + + kubectl delete -f "${SCRIPT_PATH}/runtimeclass_workloads/stability-test.yaml" +} + +main "$@" diff --git a/tests/stability/runtimeclass_workloads/stability-test.yaml b/tests/stability/runtimeclass_workloads/stability-test.yaml new file mode 100644 index 0000000000..06a9103232 --- /dev/null +++ b/tests/stability/runtimeclass_workloads/stability-test.yaml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2024 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +apiVersion: v1 +kind: Pod +metadata: + name: stability-test +spec: + terminationGracePeriodSeconds: 0 + runtimeClassName: kata + containers: + - name: stability-test + image: quay.io/bedrock/ubuntu:latest + command: ["/bin/sh", "-c", "tail -f /dev/null"]