From 7f2c1b76c0178135534816ce8917ed84af725284 Mon Sep 17 00:00:00 2001 From: Marwan Ahmed Date: Sun, 6 Oct 2024 09:05:37 -0700 Subject: [PATCH] add e2e test case for chaperon reach a terminal status --- test/e2e/chaperon-terminal-status/test.sh | 46 +++++++++++++++++++++ test/e2e/chaperon-terminal-status/test.yaml | 19 +++++++++ test/e2e/e2e.sh | 2 + 3 files changed, 67 insertions(+) create mode 100644 test/e2e/chaperon-terminal-status/test.sh create mode 100644 test/e2e/chaperon-terminal-status/test.yaml diff --git a/test/e2e/chaperon-terminal-status/test.sh b/test/e2e/chaperon-terminal-status/test.sh new file mode 100644 index 00000000..1423d6a1 --- /dev/null +++ b/test/e2e/chaperon-terminal-status/test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# +# Copyright The Multicluster-Scheduler Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -euo pipefail + +source test/e2e/aliases.sh + +chaperon-terminal-status_test() { + i=$1 + j=$2 + k $j label node --all a=b --overwrite + + k $i apply -f test/e2e/chaperon-terminal-status/test.yaml + while [ $(k $i get pod test-chaperon-terminal-status | wc -l) = 0 ]; do sleep 1; done + uid="$(k $i get pod test-chaperon-terminal-status -o json | jq -er '.metadata.uid')" + + while [ $(k $j get podchaperon -l multicluster.admiralty.io/parent-uid="$uid" | wc -l) = 0 ]; do sleep 1; done + pc="$(k $j get podchaperon -l multicluster.admiralty.io/parent-uid="$uid" -o json)" + echo "found podchaperon: $pc" + + pcName="$(echo $pc | jq -er '.metadata.name')" + k $j wait podchaperon $pcName --for='jsonpath={.status.conditions[?(@.type=="PodScheduled")].status}=False' + + k $i delete -f test/e2e/chaperon-terminal-status/test.yaml + k $j label node --all a- + + #todo: validate conditions are what we expect +} + +if [[ "${BASH_SOURCE[0]:-}" == "${0}" ]]; then + chaperon-terminal-status_test "${@}" +fi \ No newline at end of file diff --git a/test/e2e/chaperon-terminal-status/test.yaml b/test/e2e/chaperon-terminal-status/test.yaml new file mode 100644 index 00000000..ceb9d18c --- /dev/null +++ b/test/e2e/chaperon-terminal-status/test.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: test-chaperon-terminal-status +--- +apiVersion: v1 +kind: Pod +metadata: + name: test-chaperon-terminal-status + annotations: + multicluster.admiralty.io/elect: "" +spec: + serviceAccountName: test-chaperon-terminal-status + nodeSelector: + a: b + containers: + - name: pause + image: gcr.io/google_containers/pause +--- diff --git a/test/e2e/e2e.sh b/test/e2e/e2e.sh index 7334509e..7021d9ae 100755 --- a/test/e2e/e2e.sh +++ b/test/e2e/e2e.sh @@ -33,6 +33,7 @@ source test/e2e/webhook_ready.sh source test/e2e/no-rogue-finalizer/test.sh source test/e2e/delete-chaperon/test.sh source test/e2e/delete-delegate/test.sh +source test/e2e/chaperon-terminal-status/test.sh argo_setup_once cert_manager_setup_once @@ -79,6 +80,7 @@ virtual-node-labels_test 1 2 cleanup_test 1 delete-chaperon_test 1 delete-delegate_test 1 2 +chaperon-terminal-status_test 1 2 no-reservation_test no-rogue-finalizer_test