Skip to content

Commit 05e962a

Browse files
Add E2E tests
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 085c179 commit 05e962a

File tree

5,752 files changed

+1885404
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,752 files changed

+1885404
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.idea
77
[._]*.sw[a-p]
88
coverage.out
9+
bin

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,9 @@ PHONY: .shell
218218
-w /work \
219219
--user $$(id -u):$$(id -g) \
220220
$(BUILDIMAGE)
221+
222+
GINKGO = $(CURDIR)/bin/ginkgo
223+
GINKGO_VERSION ?= $(shell cd $(CURDIR)/tests && go list -m -f '{{.Version}}' github.com/onsi/ginkgo/v2)
224+
.PHONY: ginkgo
225+
ginkgo: ## Download ginkgo locally if necessary.
226+
@GOBIN=$(CURDIR)/bin GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)

hack/e2e-test.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors.
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+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SOURCE_DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
22+
ROOT_DIR="$SOURCE_DIR/.."
23+
24+
GINKGO="$ROOT_DIR"/bin/ginkgo
25+
GINKGO_ARGS=${GINKGO_ARGS:-}
26+
27+
# Check if ginkgo binary is present
28+
if [ ! -f "$GINKGO" ]; then
29+
echo "ginkgo binary not found at $GINKGO, building it"
30+
make ginkgo
31+
fi
32+
33+
# shellcheck disable=SC2086
34+
$GINKGO $GINKGO_ARGS -v --json-report ginkgo.json ./tests/e2e/... -- --config $ROOT_DIR/tests/e2e/config.yaml

tests/e2e/cleanup_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
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+
18+
package e2e
19+
20+
import (
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
23+
. "github.com/onsi/gomega"
24+
)
25+
26+
func cleanup() {
27+
deployed, err := helmClient.ListDeployedReleases()
28+
Expect(err).NotTo(HaveOccurred())
29+
30+
for _, release := range deployed {
31+
switch release.Name {
32+
case helmReleaseName:
33+
err := helmClient.UninstallReleaseByName(helmReleaseName)
34+
Expect(err).NotTo(HaveOccurred())
35+
case "gfd":
36+
// We check if GFD installation was required, if so, we uninstall it
37+
// in cases where it was skipped (ENABLE_GFD=false) we don't need to uninstall it
38+
if EnableGFD {
39+
err := helmClient.UninstallReleaseByName("gfd")
40+
Expect(err).NotTo(HaveOccurred())
41+
}
42+
default:
43+
continue
44+
}
45+
}
46+
47+
// list all resourceclaimtemplates.resource.k8s.io on the testnamespace
48+
resourceClaimTemplates, err := clientSet.ResourceV1beta1().ResourceClaimTemplates(testNamespace.Name).List(ctx, metav1.ListOptions{})
49+
Expect(err).NotTo(HaveOccurred())
50+
51+
// delete all resourceclaimtemplates.resource.k8s.io
52+
for _, resourceClaimTemplate := range resourceClaimTemplates.Items {
53+
err := clientSet.ResourceV1beta1().ResourceClaimTemplates(testNamespace.Name).Delete(ctx, resourceClaimTemplate.Name, metav1.DeleteOptions{})
54+
Expect(err).NotTo(HaveOccurred())
55+
}
56+
}
57+
58+
func cleanupCRDs() {
59+
crds := []string{
60+
"computedomains.resource.nvidia.com",
61+
}
62+
63+
if EnableGFD {
64+
crds = append(crds, "nodefeatures.nfd.k8s-sigs.io", "nodefeaturerules.nfd.k8s-sigs.io")
65+
}
66+
67+
// Delete CRDs
68+
for _, crd := range crds {
69+
err := extClient.ApiextensionsV1().CustomResourceDefinitions().Delete(ctx, crd, metav1.DeleteOptions{})
70+
Expect(err).NotTo(HaveOccurred())
71+
}
72+
}

tests/e2e/data/test-pod1.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: gpu-test1
6+
7+
---
8+
apiVersion: resource.k8s.io/v1beta1
9+
kind: ResourceClaimTemplate
10+
metadata:
11+
namespace: gpu-test1
12+
name: single-gpu
13+
spec:
14+
spec:
15+
devices:
16+
requests:
17+
- name: gpu
18+
deviceClassName: gpu.nvidia.com
19+
20+
---
21+
apiVersion: resource.nvidia.com/v1beta1
22+
kind: ComputeDomain
23+
metadata:
24+
namespace: gpu-test1
25+
name: imex-channel-injection
26+
spec:
27+
numNodes: 1
28+
channel:
29+
resourceClaimTemplate:
30+
name: imex-channel-0
31+
32+
---
33+
apiVersion: v1
34+
kind: Pod
35+
metadata:
36+
namespace: gpu-test1
37+
name: pod1
38+
labels:
39+
app: pod
40+
spec:
41+
containers:
42+
- name: ctr
43+
image: ubuntu:22.04
44+
command: ["bash", "-c"]
45+
args: ["nvidia-smi -L; trap 'exit 0' TERM; sleep 9999 & wait"]
46+
resources:
47+
claims:
48+
- name: gpu
49+
- name: imex-channel-0
50+
resourceClaims:
51+
- name: gpu
52+
resourceClaimTemplateName: single-gpu
53+
- name: imex-channel-0
54+
resourceClaimTemplateName: imex-channel-0
55+
tolerations:
56+
- key: "nvidia.com/gpu"
57+
operator: "Exists"
58+
effect: "NoSchedule"

0 commit comments

Comments
 (0)