Skip to content

Commit f98f08c

Browse files
[no-relnote] E2E Create test objects from file
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 1438e10 commit f98f08c

File tree

7 files changed

+339
-316
lines changed

7 files changed

+339
-316
lines changed

tests/e2e/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

tests/e2e/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ This test code is released under the same license as the NVIDIA k8s‑device‑
170170
## 11  References
171171
* [Ginkgo v2](https://github.com/onsi/ginkgo)
172172
* [mittwald/go‑helm‑client](https://github.com/mittwald/go-helm-client)
173-
* [Kubernetes‑sigs/Node Feature Discovery](https://github.com/kubernetes-sigs/node-feature-discovery)
173+
* [kubernetes‑sigs/node-feature-discovery](https://github.com/kubernetes-sigs/node-feature-discovery)
174174
* [Kubernetes blog – *End‑to‑End Testing for Everyone*](https://kubernetes.io/blog/2020/07/27/kubernetes-e2e-testing-for-everyone/)

tests/e2e/cleanup_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package e2e
1818

1919
import (
20-
"context"
2120
"fmt"
2221
"strings"
2322
"time"
@@ -41,8 +40,8 @@ func cleanupNamespaceResources(namespace string) {
4140
err = cleanupHelmDeployments(namespace)
4241
Expect(err).NotTo(HaveOccurred())
4342

44-
cleanupNode(ctx, clientSet)
45-
cleanupNFDObjects(ctx, nfdClient, testNamespace.Name)
43+
cleanupNode(clientSet)
44+
cleanupNFDObjects(nfdClient, testNamespace.Name)
4645
cleanupCRDs()
4746
}
4847

@@ -145,7 +144,7 @@ func cleanupCRDs() {
145144

146145
// cleanupNode deletes all NFD/GFD related metadata from the Node object, i.e.
147146
// labels and annotations
148-
func cleanupNode(ctx context.Context, cs clientset.Interface) {
147+
func cleanupNode(cs clientset.Interface) {
149148
// Per-node cleanup function
150149
cleanup := func(nodeName string) error {
151150
node, err := cs.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
@@ -236,13 +235,13 @@ func cleanupNode(ctx context.Context, cs clientset.Interface) {
236235
}
237236
}
238237

239-
func cleanupNFDObjects(ctx context.Context, cli *nfdclient.Clientset, namespace string) {
240-
cleanupNodeFeatureRules(ctx, cli)
241-
cleanupNodeFeatures(ctx, cli, namespace)
238+
func cleanupNFDObjects(cli *nfdclient.Clientset, namespace string) {
239+
cleanupNodeFeatureRules(cli)
240+
cleanupNodeFeatures(cli, namespace)
242241
}
243242

244243
// cleanupNodeFeatures deletes all NodeFeature objects in the given namespace
245-
func cleanupNodeFeatures(ctx context.Context, cli *nfdclient.Clientset, namespace string) {
244+
func cleanupNodeFeatures(cli *nfdclient.Clientset, namespace string) {
246245
nfs, err := cli.NfdV1alpha1().NodeFeatures(namespace).List(ctx, metav1.ListOptions{})
247246
if errors.IsNotFound(err) {
248247
// Omitted error, nothing to do.
@@ -264,7 +263,7 @@ func cleanupNodeFeatures(ctx context.Context, cli *nfdclient.Clientset, namespac
264263
}
265264

266265
// cleanupNodeFeatureRules deletes all NodeFeatureRule objects
267-
func cleanupNodeFeatureRules(ctx context.Context, cli *nfdclient.Clientset) {
266+
func cleanupNodeFeatureRules(cli *nfdclient.Clientset) {
268267
nfrs, err := cli.NfdV1alpha1().NodeFeatureRules().List(ctx, metav1.ListOptions{})
269268
if errors.IsNotFound(err) {
270269
// Omitted error, nothing to do.

tests/e2e/data/job-1.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: j-e2e-1
5+
labels:
6+
app.nvidia.com: k8s-device-plugin-test-app
7+
spec:
8+
template:
9+
metadata:
10+
name: gpu-pod
11+
spec:
12+
restartPolicy: Never
13+
containers:
14+
- name: cuda-container
15+
image: nvcr.io/nvidia/k8s/cuda-sample:nbody-cuda11.7.1-ubuntu18.04
16+
args:
17+
- "--benchmark"
18+
- "--numbodies=10000"
19+
resources:
20+
limits:
21+
nvidia.com/gpu: "1"
22+
tolerations:
23+
- key: "nvidia.com/gpu"
24+
operator: "Exists"
25+
effect: "NoSchedule"

tests/e2e/device-plugin_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,12 @@ var _ = Describe("GPU Device Plugin", Ordered, func() {
133133
})
134134
It("it should run GPU jobs", func(ctx context.Context) {
135135
By("Creating a GPU job")
136-
job := newGPUJob(testNamespace.Name)
137-
job.Namespace = testNamespace.Name
138-
139-
_, err := clientSet.BatchV1().Jobs(testNamespace.Name).Create(ctx, job, metav1.CreateOptions{})
136+
job, err := CreateOrUpdateJobsFromFile(ctx, clientSet, "job-1.yaml", testNamespace.Name)
140137
Expect(err).NotTo(HaveOccurred())
141138

142139
By("Waiting for job to complete")
143140
Eventually(func() error {
144-
job, err := clientSet.BatchV1().Jobs(testNamespace.Name).Get(ctx, job.Name, metav1.GetOptions{})
141+
job, err := clientSet.BatchV1().Jobs(testNamespace.Name).Get(ctx, job[0], metav1.GetOptions{})
145142
if err != nil {
146143
return err
147144
}

0 commit comments

Comments
 (0)