@@ -31,11 +31,12 @@ import (
3131 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232 "k8s.io/apimachinery/pkg/util/rand"
3333
34+ "github.com/NVIDIA/k8s-device-plugin/tests/e2e/internal"
3435 "github.com/NVIDIA/k8s-test-infra/pkg/diagnostics"
3536)
3637
3738// Actual test suite
38- var _ = Describe ("GPU Feature Discovery" , Ordered , func () {
39+ var _ = Describe ("GPU Feature Discovery" , Ordered , Label ( "gfd" , "gpu" , "e2e" ), func () {
3940 expectedLabelPatterns := k8sLabels {
4041 "nvidia.com/gfd.timestamp" : "[0-9]{10}" ,
4142 "nvidia.com/cuda.driver.major" : "[0-9]+" ,
@@ -97,7 +98,7 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
9798 collectLogsFrom = strings .Split (CollectLogsFrom , "," )
9899 }
99100
100- BeforeAll (func (ctx context. Context ) {
101+ BeforeAll (func (ctx SpecContext ) {
101102 helmReleaseName = "gfd-e2e-test" + rand .String (5 )
102103
103104 // reset Helm Client
@@ -114,10 +115,25 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
114115 By ("Installing GFD Helm chart" )
115116 _ , err := helmClient .InstallChart (ctx , & chartSpec , nil )
116117 Expect (err ).NotTo (HaveOccurred ())
118+
119+ // Wait for all DaemonSets to be ready
120+ // Note: DaemonSet names are dynamically generated with the Helm release prefix,
121+ // so we wait for all DaemonSets in the namespace rather than specific names
122+ By ("Waiting for all DaemonSets to be ready" )
123+ err = internal .WaitForAllDaemonSetsReady (ctx , clientSet , testNamespace .Name )
124+ Expect (err ).NotTo (HaveOccurred ())
125+ })
126+
127+ AfterAll (func (ctx SpecContext ) {
128+ By ("Uninstalling GFD Helm chart" )
129+ err := helmClient .UninstallReleaseByName (helmReleaseName )
130+ if err != nil {
131+ GinkgoWriter .Printf ("Failed to uninstall helm release %s: %v\n " , helmReleaseName , err )
132+ }
117133 })
118134
119135 // Cleanup before next test run
120- AfterEach (func (ctx context. Context ) {
136+ AfterEach (func (ctx SpecContext ) {
121137 // Run diagnostic collector if test failed
122138 if CurrentSpecReport ().Failed () {
123139 var err error
@@ -135,9 +151,17 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
135151 }
136152 })
137153
138- When ("When deploying GFD" , Ordered , func () {
154+ When ("When deploying GFD" , Ordered , Label ( "serial" ), func () {
139155 Context ("NV Driver is not installed" , func () {
140- It ("it should create nvidia.com timestamp label" , func (ctx context.Context ) {
156+ BeforeEach (func () {
157+ // Skip this context when driver is enabled since "NV Driver is installed"
158+ // context provides more comprehensive testing
159+ if NVIDIA_DRIVER_ENABLED {
160+ Skip ("Skipping driver-not-installed tests when NVIDIA_DRIVER_ENABLED is true" )
161+ }
162+ })
163+
164+ It ("it should create nvidia.com timestamp label" , Label ("timestamp" ), func (ctx SpecContext ) {
141165 nodeList , err := clientSet .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {})
142166 Expect (err ).NotTo (HaveOccurred ())
143167 Expect (len (nodeList .Items )).ToNot (BeZero ())
@@ -157,7 +181,7 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
157181 eventuallyNonControlPlaneNodes (ctx , clientSet ).Should (MatchLabels (labelChecker , nodes ))
158182 })
159183 Context ("and the NodeFeature API is enabled" , func () {
160- It ("gfd should create node feature object" , func (ctx context. Context ) {
184+ It ("gfd should create node feature object" , Label ( "nodefeature" ), func (ctx SpecContext ) {
161185 By ("Updating GFD Helm chart values" )
162186 newValues := values
163187 newValues .Values = append (newValues .Values , "nfd.enableNodeFeatureApi=true" )
@@ -172,9 +196,9 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
172196
173197 targetNodeName := nodes [0 ].Name
174198 Expect (targetNodeName ).ToNot (BeEmpty ())
175- Eventually (func () bool {
199+ Eventually (func (g Gomega ) bool {
176200 return checkNodeFeatureObject (ctx , targetNodeName )
177- }, 2 * time .Minute , 5 * time .Second ).Should (BeTrue ())
201+ }). WithContext ( ctx ). WithPolling ( 5 * time .Second ). WithTimeout ( 2 * time .Minute ).Should (BeTrue ())
178202
179203 By ("Checking that node labels are created from NodeFeature object" )
180204 labelChecker := map [string ]k8sLabels {
@@ -187,7 +211,7 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
187211 })
188212
189213 When ("NV Driver is installed" , func () {
190- It ("it should create nvidia.com labels" , func (ctx context. Context ) {
214+ It ("it should create nvidia.com labels" , Label ( "driver" , "labels" ), func (ctx SpecContext ) {
191215 if ! NVIDIA_DRIVER_ENABLED {
192216 Skip ("NVIDIA_DRIVER_ENABLED is not set" )
193217 }
@@ -210,7 +234,7 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
210234 eventuallyNonControlPlaneNodes (ctx , clientSet ).Should (MatchLabels (labelChecker , nodes ))
211235 })
212236 Context ("and the NodeFeature API is enabled" , func () {
213- It ("gfd should create node feature object" , func (ctx context. Context ) {
237+ It ("gfd should create node feature object" , Label ( "driver" , "nodefeature" ), func (ctx SpecContext ) {
214238 if ! NVIDIA_DRIVER_ENABLED {
215239 Skip ("NVIDIA_DRIVER_ENABLED is not set" )
216240 }
@@ -228,9 +252,9 @@ var _ = Describe("GPU Feature Discovery", Ordered, func() {
228252
229253 targetNodeName := nodes [0 ].Name
230254 Expect (targetNodeName ).ToNot (BeEmpty ())
231- Eventually (func () bool {
255+ Eventually (func (g Gomega ) bool {
232256 return checkNodeFeatureObject (ctx , targetNodeName )
233- }, 2 * time .Minute , 5 * time .Second ).Should (BeTrue ())
257+ }). WithContext ( ctx ). WithPolling ( 5 * time .Second ). WithTimeout ( 2 * time .Minute ).Should (BeTrue ())
234258
235259 By ("Checking that node labels are created from NodeFeature CR object" )
236260 checkForLabels := map [string ]k8sLabels {
0 commit comments