-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add e2e tests for deployment policy #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c0cb322
feat: add e2e tests for deployment policy
t0mmylam cc13e9f
fix shell issue
t0mmylam 4c7a525
update wording
t0mmylam 30274a3
fix webhook timing
t0mmylam e7b3bfe
replace scripts with Chainsaw assertions in deployment policy tests
t0mmylam 543a98d
consolidate test jobs in ci
t0mmylam f8f4a1a
add ordered assertions for batch states to tests
t0mmylam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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. | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Shared Kind cluster configuration for all deployment policy tests | ||
| # 15 worker nodes + 1 control-plane | ||
| # - Multi-compartment test uses all 15 nodes | ||
| # - Linear strategy test uses first 8 nodes | ||
| # - Overlapping selectors test uses first 6 nodes | ||
|
|
||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| nodes: | ||
| - role: control-plane | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker | ||
| - role: worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/bin/bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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 -e | ||
|
|
||
| # Usage: label-nodes.sh <operation> <node_range> <label1=value1> [label2=value2] ... | ||
| # Examples: | ||
| # label-nodes.sh add 0-4 priority=critical skyhook.nvidia.com/test-node=skyhooke2e | ||
| # label-nodes.sh remove 0-14 priority env region | ||
| # label-nodes.sh clean-all skyhook.nvidia.com/test-node | ||
|
|
||
| OPERATION=$1 | ||
| shift | ||
|
|
||
| if [ "$OPERATION" = "clean-all" ]; then | ||
| LABEL_PREFIX=$1 | ||
| echo "Cleaning all labels matching: $LABEL_PREFIX" | ||
| kubectl label nodes --all "${LABEL_PREFIX}-" --overwrite 2>/dev/null || true | ||
| echo "✓ Cleanup complete" | ||
| exit 0 | ||
| fi | ||
|
|
||
| NODE_RANGE=$1 | ||
| shift | ||
|
|
||
| # Get all worker nodes (excluding control-plane) | ||
| WORKERS=($(kubectl get nodes --no-headers -o custom-columns=NAME:.metadata.name | grep -v control-plane | sort)) | ||
|
|
||
| # Parse node range | ||
| if [[ $NODE_RANGE == *-* ]]; then | ||
| START=$(echo $NODE_RANGE | cut -d'-' -f1) | ||
| END=$(echo $NODE_RANGE | cut -d'-' -f2) | ||
| else | ||
| START=$NODE_RANGE | ||
| END=$NODE_RANGE | ||
| fi | ||
|
|
||
| # Validate we have enough nodes | ||
| if [ ${#WORKERS[@]} -lt $((END + 1)) ]; then | ||
| echo "ERROR: Need at least $((END + 1)) worker nodes for this operation" | ||
| echo "Found: ${#WORKERS[@]} workers" | ||
| exit 1 | ||
| fi | ||
|
|
||
| case "$OPERATION" in | ||
| add) | ||
| LABELS="$@" | ||
| echo "Adding labels to nodes [$START-$END]: $LABELS" | ||
| for i in $(seq $START $END); do | ||
| if [ -n "${WORKERS[$i]}" ]; then | ||
| kubectl label node ${WORKERS[$i]} $LABELS --overwrite | ||
| fi | ||
| done | ||
| ;; | ||
| remove) | ||
| LABELS_TO_REMOVE="" | ||
| for label in "$@"; do | ||
| LABELS_TO_REMOVE="$LABELS_TO_REMOVE ${label}-" | ||
| done | ||
| echo "Removing labels from nodes [$START-$END]: $@" | ||
| for i in $(seq $START $END); do | ||
| if [ -n "${WORKERS[$i]}" ]; then | ||
| kubectl label node ${WORKERS[$i]} $LABELS_TO_REMOVE --overwrite 2>/dev/null || true | ||
| fi | ||
| done | ||
| ;; | ||
| *) | ||
| echo "ERROR: Unknown operation: $OPERATION" | ||
| echo "Usage: $0 {add|remove|clean-all} ..." | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| echo "✓ Operation complete" | ||
|
|
28 changes: 28 additions & 0 deletions
28
k8s-tests/chainsaw/deployment-policy/legacy-compatibility/assert-default-compartment.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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. | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| apiVersion: skyhook.nvidia.com/v1alpha1 | ||
| kind: Skyhook | ||
| metadata: | ||
| name: legacy-interruption-budget-test | ||
| status: | ||
| compartmentStatuses: | ||
| __default__: | ||
| matched: 6 | ||
| ceiling: 3 |
81 changes: 81 additions & 0 deletions
81
k8s-tests/chainsaw/deployment-policy/legacy-compatibility/chainsaw-test.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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. | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
| apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
| kind: Test | ||
| metadata: | ||
| name: legacy-interruption-budget-compatibility | ||
| spec: | ||
| description: | | ||
| Tests backwards compatibility with legacy InterruptionBudget. | ||
| - Creates Skyhook with interruptionBudget (count: 3) instead of deploymentPolicy | ||
| - Verifies that a synthetic __default__ compartment is created | ||
| - Verifies that the budget ceiling is respected (max 3 nodes in progress) | ||
| - Ensures existing customers' configurations continue to work | ||
| timeouts: | ||
| exec: 180s | ||
| assert: 120s | ||
| steps: | ||
| - name: setup-nodes | ||
| try: | ||
| - script: | ||
| content: | | ||
| chmod +x ../label-nodes.sh | ||
| # Clean up any existing labels from previous tests | ||
| ../label-nodes.sh clean-all skyhook.nvidia.com/test-node | ||
| # Label first 6 worker nodes | ||
| ../label-nodes.sh add 0-5 skyhook.nvidia.com/test-node=skyhooke2e | ||
| echo "✓ Node labeling complete" | ||
| kubectl get nodes -L skyhook.nvidia.com/test-node --sort-by=.metadata.name | head -8 | ||
|
|
||
| - name: apply-skyhook | ||
| try: | ||
| - apply: | ||
| file: skyhook.yaml | ||
| - sleep: | ||
| duration: 10s | ||
|
|
||
| - name: verify-default-compartment | ||
| try: | ||
| - assert: | ||
| file: assert-default-compartment.yaml | ||
|
|
||
| - name: verify-metrics | ||
| try: | ||
| - script: | ||
| content: | | ||
| echo "=== Verifying legacy compatibility metrics ===" | ||
|
|
||
| # Verify metrics for synthetic __default__ compartment | ||
| ../../metrics_test.py skyhook_rollout_matched_nodes 6 -t skyhook_name=legacy-interruption-budget-test -t policy_name=legacy -t compartment_name=__default__ -t strategy=fixed | ||
| ../../metrics_test.py skyhook_rollout_ceiling 3 -t skyhook_name=legacy-interruption-budget-test -t policy_name=legacy -t compartment_name=__default__ -t strategy=fixed | ||
|
|
||
| # Verify that the legacy policy name is "legacy" and not a real policy | ||
| echo "✓ Legacy compatibility metrics verified!" | ||
| echo "✓ Metrics use policy_name=legacy for backwards compatibility" | ||
|
|
||
| - name: cleanup | ||
| try: | ||
| - script: | ||
| content: | | ||
| # Clean up node annotations | ||
| ../../skyhook/rest_test.sh legacy-interruption-budget-test | ||
| # Clean up labels | ||
| ../label-nodes.sh clean-all skyhook.nvidia.com/test-node |
36 changes: 36 additions & 0 deletions
36
k8s-tests/chainsaw/deployment-policy/legacy-compatibility/skyhook.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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. | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| apiVersion: skyhook.nvidia.com/v1alpha1 | ||
| kind: Skyhook | ||
| metadata: | ||
| name: legacy-interruption-budget-test | ||
| spec: | ||
| priority: 100 | ||
| # Use legacy InterruptionBudget instead of DeploymentPolicy | ||
| interruptionBudget: | ||
| count: 3 # Max 3 nodes at once | ||
| nodeSelectors: | ||
| matchLabels: | ||
| skyhook.nvidia.com/test-node: skyhooke2e | ||
| packages: | ||
| test-pkg: | ||
| version: "6.2.0" | ||
| image: "ghcr.io/nvidia/skyhook/agentless" | ||
|
|
28 changes: 28 additions & 0 deletions
28
k8s-tests/chainsaw/deployment-policy/linear-strategy/assert-batch-1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # 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. | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Assert: Batch 1 - At least 1 node completed (initial batch) | ||
| apiVersion: skyhook.nvidia.com/v1alpha1 | ||
| kind: Skyhook | ||
| metadata: | ||
| name: linear-strategy-test | ||
| status: | ||
| compartmentStatuses: | ||
| production: | ||
| (completed >= `1`): true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.