Skip to content

Commit f8f4a1a

Browse files
committed
add ordered assertions for batch states to tests
1 parent 543a98d commit f8f4a1a

File tree

12 files changed

+336
-45
lines changed

12 files changed

+336
-45
lines changed

k8s-tests/chainsaw/deployment-policy/legacy-compatibility/chainsaw-test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ spec:
6464
echo "=== Verifying legacy compatibility metrics ==="
6565
6666
# Verify metrics for synthetic __default__ compartment
67-
../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
68-
../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
67+
../../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
68+
../../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
6969
7070
# Verify that the legacy policy name is "legacy" and not a real policy
7171
echo "✓ Legacy compatibility metrics verified!"
@@ -75,4 +75,7 @@ spec:
7575
try:
7676
- script:
7777
content: |
78+
# Clean up node annotations
79+
../../skyhook/rest_test.sh legacy-interruption-budget-test
80+
# Clean up labels
7881
../label-nodes.sh clean-all skyhook.nvidia.com/test-node
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 1 - At least 1 node completed (initial batch)
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: linear-strategy-test
25+
status:
26+
compartmentStatuses:
27+
production:
28+
(completed >= `1`): true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 2 - At least 2 nodes completed (1 + delta 1)
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: linear-strategy-test
25+
status:
26+
compartmentStatuses:
27+
production:
28+
(completed >= `2`): true
29+
batchState:
30+
(currentBatch >= `2`): true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 3 - At least 3 nodes completed (1 + 1 + delta 1)
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: linear-strategy-test
25+
status:
26+
compartmentStatuses:
27+
production:
28+
(completed >= `3`): true
29+
batchState:
30+
(currentBatch >= `3`): true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 4 - At least 4 nodes completed (ceiling reached)
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: linear-strategy-test
25+
status:
26+
compartmentStatuses:
27+
production:
28+
(completed >= `4`): true
29+
batchState:
30+
(currentBatch >= `4`): true

k8s-tests/chainsaw/deployment-policy/linear-strategy/chainsaw-test.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,23 @@ spec:
5959
echo "=== Verifying initial metrics ==="
6060
6161
# Verify matched nodes and ceiling for production compartment
62-
../metrics_test.py skyhook_rollout_matched_nodes 8 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
62+
../../metrics_test.py skyhook_rollout_matched_nodes 8 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
6363
# Budget is count=4
64-
../metrics_test.py skyhook_rollout_ceiling 4 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
64+
../../metrics_test.py skyhook_rollout_ceiling 4 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
6565
6666
echo "✓ Initial metrics verified"
6767
68+
- name: track-batch-progression
69+
try:
70+
- assert:
71+
file: assert-batch-1.yaml
72+
- assert:
73+
file: assert-batch-2.yaml
74+
- assert:
75+
file: assert-batch-3.yaml
76+
- assert:
77+
file: assert-batch-4.yaml
78+
6879
- name: wait-for-completion
6980
try:
7081
- assert:
@@ -78,23 +89,26 @@ spec:
7889
echo "=== Verifying final metrics ==="
7990
8091
# All nodes should be completed
81-
../metrics_test.py skyhook_rollout_completed 8 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
82-
../metrics_test.py skyhook_rollout_in_progress 0 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
83-
../metrics_test.py skyhook_rollout_progress_percent 100 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
92+
../../metrics_test.py skyhook_rollout_completed 8 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
93+
../../metrics_test.py skyhook_rollout_in_progress 0 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
94+
../../metrics_test.py skyhook_rollout_progress_percent 100 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
8495
8596
# Verify no consecutive failures
86-
../metrics_test.py skyhook_rollout_consecutive_failures 0 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
97+
../../metrics_test.py skyhook_rollout_consecutive_failures 0 -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
8798
8899
# Verify current_batch metric exists and is greater than 0
89100
CURRENT_BATCH=$(kubectl get skyhook linear-strategy-test -o jsonpath='{.status.compartmentStatuses.production.batchState.currentBatch}')
90-
../metrics_test.py skyhook_rollout_current_batch "$CURRENT_BATCH" -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
101+
../../metrics_test.py skyhook_rollout_current_batch "$CURRENT_BATCH" -t skyhook_name=linear-strategy-test -t policy_name=linear-ramp-policy -t compartment_name=production -t strategy=linear
91102
92103
echo "✓ All final metrics verified!"
93104
94105
- name: cleanup
95106
try:
96107
- script:
97108
content: |
109+
# Clean up node annotations
110+
../../skyhook/rest_test.sh linear-strategy-test
111+
# Clean up labels
98112
../label-nodes.sh clean-all tier
99113
../label-nodes.sh clean-all skyhook.nvidia.com/test-node
100114
- delete:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 1 - Initial batch started for all compartments
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: multi-compartment-test
25+
status:
26+
compartmentStatuses:
27+
critical:
28+
(completed >= `1`): true
29+
standard:
30+
(completed >= `1`): true
31+
test:
32+
(completed >= `2`): true # initialBatch: 2
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
# Assert: Batch 2 - Exponential growth (1 -> 2, 1 -> 2, 2 -> 4)
21+
apiVersion: skyhook.nvidia.com/v1alpha1
22+
kind: Skyhook
23+
metadata:
24+
name: multi-compartment-test
25+
status:
26+
compartmentStatuses:
27+
critical:
28+
(completed >= `2`): true # 1 * 2 = 2, but ceiling is 2
29+
batchState:
30+
(currentBatch >= `2`): true
31+
standard:
32+
(completed >= `1`): true # 1 * 2 = 2, but ceiling is 1
33+
test:
34+
(completed >= `4`): true # 2 * 2 = 4, ceiling is 2
35+
batchState:
36+
(currentBatch >= `2`): true

0 commit comments

Comments
 (0)