Skip to content

Commit 8136453

Browse files
committed
feat: Consolidate CLI e2e tests with proper assertions and CI integration
1 parent 9e0285e commit 8136453

File tree

10 files changed

+398
-0
lines changed

10 files changed

+398
-0
lines changed

.github/workflows/operator-ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ jobs:
6161
test-suite: deployment-policy
6262
kind-config: k8s-tests/chainsaw/deployment-policy/kind-config.yaml
6363
make-target: deployment-policy-tests
64+
# CLI e2e tests on K8s 1.34 only
65+
- k8s-version: "1.34.0"
66+
test-suite: cli-e2e
67+
make-target: cli-e2e-tests
6468
fail-fast: false # Continue testing other versions if one fails
6569
name: ${{ matrix.test-suite }}-tests (k8s-${{ matrix.k8s-version }})
6670
steps:
@@ -118,6 +122,9 @@ jobs:
118122
if [ "${{ matrix.test-suite }}" = "e2e" ]; then
119123
make setup-kind-cluster
120124
make test
125+
elif [ "${{ matrix.test-suite }}" = "cli-e2e" ]; then
126+
make setup-kind-cluster
127+
make ${{ matrix.make-target }}
121128
else
122129
make ${{ matrix.make-target }}
123130
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
apiVersion: v1
18+
kind: Node
19+
metadata:
20+
labels:
21+
skyhook.nvidia.com/test-node: skyhooke2e
22+
skyhook.nvidia.com/ignore: "true"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
apiVersion: v1
18+
kind: Node
19+
metadata:
20+
labels:
21+
skyhook.nvidia.com/test-node: skyhooke2e
22+
annotations: {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
apiVersion: v1
18+
kind: Node
19+
metadata:
20+
labels:
21+
skyhook.nvidia.com/test-node: skyhooke2e
22+
labels:
23+
(has(metadata.labels.skyhook.nvidia.com/ignore)): false
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
18+
apiVersion: chainsaw.kyverno.io/v1alpha1
19+
kind: Test
20+
metadata:
21+
name: cli-node
22+
spec:
23+
description: |
24+
Test all CLI node commands:
25+
- node list: shows nodes targeted by a Skyhook
26+
- node status: shows Skyhook activity on nodes
27+
- node ignore/unignore: excludes/includes nodes from processing
28+
- node reset: resets package state on a node
29+
timeouts:
30+
assert: 120s
31+
exec: 90s
32+
steps:
33+
# Step 1: Create a Skyhook and wait for activity
34+
- name: setup-skyhook
35+
try:
36+
- apply:
37+
file: skyhook.yaml
38+
- script:
39+
timeout: 60s
40+
content: |
41+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
42+
echo "Waiting for Skyhook activity on node $NODE..."
43+
for i in $(seq 1 30); do
44+
ANNOTATION=$(kubectl get node "$NODE" -o jsonpath='{.metadata.annotations.skyhook\.nvidia\.com/nodeState_cli-node-test}' 2>/dev/null)
45+
if [ -n "$ANNOTATION" ]; then
46+
echo "Skyhook activity detected"
47+
exit 0
48+
fi
49+
sleep 2
50+
done
51+
echo "Timeout waiting for activity"
52+
exit 1
53+
54+
# Step 2: Test node list (table format)
55+
- name: test-node-list
56+
try:
57+
- script:
58+
timeout: 30s
59+
content: |
60+
../../../../operator/bin/skyhook node list --skyhook cli-node-test
61+
- script:
62+
timeout: 30s
63+
content: |
64+
../../../../operator/bin/skyhook node list --skyhook cli-node-test -o json
65+
66+
# Step 3: Test node status
67+
- name: test-node-status
68+
try:
69+
- script:
70+
timeout: 30s
71+
content: |
72+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
73+
../../../../operator/bin/skyhook node status "$NODE"
74+
- script:
75+
timeout: 30s
76+
content: |
77+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
78+
../../../../operator/bin/skyhook node status "$NODE" --skyhook cli-node-test
79+
- script:
80+
timeout: 30s
81+
content: |
82+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
83+
../../../../operator/bin/skyhook node status "$NODE" -o json
84+
85+
# Step 4: Test node ignore/unignore
86+
- name: test-node-ignore
87+
try:
88+
- script:
89+
timeout: 30s
90+
content: |
91+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
92+
../../../../operator/bin/skyhook node ignore "$NODE"
93+
- assert:
94+
file: assert-node-ignored.yaml
95+
- name: test-node-unignore
96+
try:
97+
- script:
98+
timeout: 30s
99+
content: |
100+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
101+
../../../../operator/bin/skyhook node unignore "$NODE"
102+
- assert:
103+
file: assert-node-unignored.yaml
104+
105+
# Step 5: Test node reset
106+
- name: test-node-reset
107+
try:
108+
- script:
109+
timeout: 30s
110+
content: |
111+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
112+
../../../../operator/bin/skyhook node reset "$NODE" --skyhook cli-node-test --confirm
113+
- assert:
114+
file: assert-node-reset.yaml
115+
116+
# Cleanup
117+
- name: cleanup
118+
try:
119+
- script:
120+
content: |
121+
kubectl delete skyhook cli-node-test 2>/dev/null || true
122+
for NODE in $(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[*].metadata.name}'); do
123+
kubectl annotate node "$NODE" skyhook.nvidia.com/nodeState_cli-node-test- 2>/dev/null || true
124+
kubectl label node "$NODE" skyhook.nvidia.com/ignore- 2>/dev/null || true
125+
done
126+
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+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-node-test
21+
spec:
22+
nodeSelectors:
23+
matchLabels:
24+
skyhook.nvidia.com/test-node: skyhooke2e
25+
packages:
26+
hello-world:
27+
version: "3.2.3"
28+
image: ghcr.io/nvidia/skyhook/agentless
29+
env:
30+
- name: SLEEP_LEN
31+
value: "10"
32+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
apiVersion: v1
18+
kind: Node
19+
metadata:
20+
labels:
21+
skyhook.nvidia.com/test-node: skyhooke2e
22+
annotations:
23+
skyhook.nvidia.com/status_cli-package-test: "in_progress"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
18+
apiVersion: chainsaw.kyverno.io/v1alpha1
19+
kind: Test
20+
metadata:
21+
name: cli-package
22+
spec:
23+
description: |
24+
Test all CLI package commands:
25+
- package status: shows package status across nodes
26+
- package logs: retrieves logs from package pods
27+
- package rerun: forces a package to re-run
28+
timeouts:
29+
assert: 120s
30+
exec: 90s
31+
steps:
32+
# Step 1: Create a Skyhook and wait for package activity
33+
- name: setup-skyhook
34+
try:
35+
- apply:
36+
file: skyhook.yaml
37+
- script:
38+
timeout: 60s
39+
content: |
40+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
41+
echo "Waiting for Skyhook activity on node $NODE..."
42+
for i in $(seq 1 30); do
43+
ANNOTATION=$(kubectl get node "$NODE" -o jsonpath='{.metadata.annotations.skyhook\.nvidia\.com/nodeState_cli-package-test}' 2>/dev/null)
44+
if [ -n "$ANNOTATION" ]; then
45+
echo "Skyhook activity detected"
46+
exit 0
47+
fi
48+
sleep 2
49+
done
50+
echo "Timeout waiting for activity"
51+
exit 1
52+
53+
# Step 2: Test package status (table format)
54+
- name: test-package-status
55+
try:
56+
- script:
57+
timeout: 30s
58+
content: |
59+
../../../../operator/bin/skyhook package status hello-world --skyhook cli-package-test
60+
- script:
61+
timeout: 30s
62+
content: |
63+
../../../../operator/bin/skyhook package status hello-world --skyhook cli-package-test -o json
64+
65+
# Step 3: Test package logs
66+
- name: test-package-logs
67+
try:
68+
- script:
69+
timeout: 30s
70+
content: |
71+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
72+
73+
# Run logs command - it should succeed (may show waiting or actual logs)
74+
../../../../operator/bin/skyhook package logs hello-world --skyhook cli-package-test --node "$NODE"
75+
76+
# Step 4: Test package rerun
77+
- name: test-package-rerun
78+
try:
79+
- script:
80+
timeout: 30s
81+
content: |
82+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
83+
84+
# Test dry-run first
85+
../../../../operator/bin/skyhook package rerun hello-world --skyhook cli-package-test --node "$NODE" --dry-run
86+
- script:
87+
timeout: 30s
88+
content: |
89+
NODE=$(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[0].metadata.name}')
90+
91+
# Run actual rerun with confirm flag and stage
92+
../../../../operator/bin/skyhook package rerun hello-world --skyhook cli-package-test --node "$NODE" --stage apply --confirm
93+
- assert:
94+
file: assert-package-rerun.yaml
95+
96+
# Cleanup
97+
- name: cleanup
98+
try:
99+
- script:
100+
content: |
101+
kubectl delete skyhook cli-package-test 2>/dev/null || true
102+
for NODE in $(kubectl get nodes -l skyhook.nvidia.com/test-node=skyhooke2e -o jsonpath='{.items[*].metadata.name}'); do
103+
kubectl annotate node "$NODE" skyhook.nvidia.com/nodeState_cli-package-test- 2>/dev/null || true
104+
done
105+

0 commit comments

Comments
 (0)