From c04a80521598dee2e4632ca464b03784ecf3113b Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 20 Aug 2024 23:00:46 +0000 Subject: [PATCH] stability: Add kubernetes parallel test This PR adds a kubernetes parallel test that will launch multiple replicas from a kubernetes deployment and we will iterate this multiple times to verify that we are able to do this using CoCo Kata. This test will be part of the CoCo Kata stability CI. Signed-off-by: Gabriela Cervantes --- tests/stability/kubernetes_soak_test.sh | 46 +++++++++++++++++++ .../pod-deployment.yaml | 25 ++++++++++ 2 files changed, 71 insertions(+) create mode 100755 tests/stability/kubernetes_soak_test.sh create mode 100644 tests/stability/runtimeclass_workloads/pod-deployment.yaml diff --git a/tests/stability/kubernetes_soak_test.sh b/tests/stability/kubernetes_soak_test.sh new file mode 100755 index 0000000000..bf15327c93 --- /dev/null +++ b/tests/stability/kubernetes_soak_test.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# Copyright (c) 2024 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +SCRIPT_PATH=$(dirname "$(readlink -f "$0")") +source "${SCRIPT_PATH}/../metrics/lib/common.bash" + +set -x + +replicas="${replicas:-8}" +deployment_name="${deployment_name:-deploymenttest}" +# How many times will we run the test loop... +iterations="${iterations:-20}" + +function delete_deployment() { + kubectl delete deployment "${deployment_name}" +} + +function go() { + kubectl scale deployment/"${deployment_name}" --replicas="${replicas}" + cmd="kubectl get deployment/${deployment_name} -o yaml | grep 'availableReplicas: ${replicas}'" + waitForProcess "300" "30" "${cmd}" +} + +function init() { + kubectl create -f "${SCRIPT_PATH}/runtimeclass_workloads/pod-deployment.yaml" + kubectl wait --for=condition=Available --timeout=30s deployment/"${deployment_name}" +} + +function main() { + check_processes + local i=0 + for (( i=1; i<="${iterations}"; i++ )); do + info "Start iteration $i of $iterations" + init + #spin them up + go + #shut them all down + delete_deployment + done +} + +main "$@" diff --git a/tests/stability/runtimeclass_workloads/pod-deployment.yaml b/tests/stability/runtimeclass_workloads/pod-deployment.yaml new file mode 100644 index 0000000000..df535234e9 --- /dev/null +++ b/tests/stability/runtimeclass_workloads/pod-deployment.yaml @@ -0,0 +1,25 @@ +# +# Copyright (c) 2024 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +apiVersion: apps/v1 +kind: Deployment +metadata: + name: deploymenttest +spec: + selector: + matchLabels: + purpose: pod-test + replicas: 2 + template: + metadata: + labels: + purpose: pod-test + spec: + terminationGracePeriodSeconds: 0 + runtimeClassName: kata + containers: + - name: pod-test + image: quay.io/prometheus/busybox:latest + command: ["tail", "-f", "/dev/null"]