Skip to content

Commit

Permalink
add e2e test case for chaperon reach a terminal status
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Oct 6, 2024
1 parent 2ba3f97 commit 7f2c1b7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/e2e/chaperon-terminal-status/test.sh
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/e2e/chaperon-terminal-status/test.yaml
Original file line number Diff line number Diff line change
@@ -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
---
2 changes: 2 additions & 0 deletions test/e2e/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f2c1b7

Please sign in to comment.