@@ -297,5 +297,75 @@ spec:
297297 g .Expect (strings .TrimSpace (out )).NotTo (BeEmpty ())
298298 }).Should (Succeed ())
299299 })
300+
301+ It ("keeps VM Pending with unmatched taint, schedules VM with matching toleration" , func () {
302+ By ("adding custom taint e2e-test=blocked:NoSchedule to node" )
303+ _ , err := utils .Run (exec .Command ("kubectl" , "taint" , "nodes" , nodeName ,
304+ "e2e-test=blocked:NoSchedule" ))
305+ Expect (err ).NotTo (HaveOccurred ())
306+
307+ By ("creating ImpVM without toleration" )
308+ noTolManifest := `
309+ apiVersion: imp.dev/v1alpha1
310+ kind: ImpVM
311+ metadata:
312+ name: e2e-sched-notoleration
313+ namespace: default
314+ spec:
315+ classRef:
316+ name: small
317+ image: ghcr.io/syscode-labs/test:latest
318+ lifecycle: ephemeral
319+ `
320+ applyCmd := exec .Command ("kubectl" , "apply" , "-f" , "-" )
321+ applyCmd .Stdin = strings .NewReader (noTolManifest )
322+ _ , err = utils .Run (applyCmd )
323+ Expect (err ).NotTo (HaveOccurred ())
324+
325+ By ("verifying VM without toleration stays Pending" )
326+ Consistently (func (g Gomega ) {
327+ getCmd := exec .Command ("kubectl" , "get" , "impvm" , "e2e-sched-notoleration" ,
328+ "-n" , "default" , "-o" , "jsonpath={.spec.nodeName}" )
329+ out , getErr := utils .Run (getCmd )
330+ g .Expect (getErr ).NotTo (HaveOccurred ())
331+ g .Expect (strings .TrimSpace (out )).To (BeEmpty ())
332+ }, 20 * time .Second , time .Second ).Should (Succeed ())
333+
334+ By ("deleting VM without toleration" )
335+ _ , _ = utils .Run (exec .Command ("kubectl" , "delete" , "impvm" , "e2e-sched-notoleration" ,
336+ "-n" , "default" , "--ignore-not-found" ))
337+
338+ By ("creating ImpVM with matching toleration" )
339+ tolManifest := `
340+ apiVersion: imp.dev/v1alpha1
341+ kind: ImpVM
342+ metadata:
343+ name: e2e-sched-toleration
344+ namespace: default
345+ spec:
346+ classRef:
347+ name: small
348+ image: ghcr.io/syscode-labs/test:latest
349+ lifecycle: ephemeral
350+ tolerations:
351+ - key: e2e-test
352+ operator: Equal
353+ value: blocked
354+ effect: NoSchedule
355+ `
356+ applyCmd2 := exec .Command ("kubectl" , "apply" , "-f" , "-" )
357+ applyCmd2 .Stdin = strings .NewReader (tolManifest )
358+ _ , err = utils .Run (applyCmd2 )
359+ Expect (err ).NotTo (HaveOccurred ())
360+
361+ By ("verifying VM with matching toleration gets scheduled" )
362+ Eventually (func (g Gomega ) {
363+ getCmd := exec .Command ("kubectl" , "get" , "impvm" , "e2e-sched-toleration" ,
364+ "-n" , "default" , "-o" , "jsonpath={.spec.nodeName}" )
365+ out , getErr := utils .Run (getCmd )
366+ g .Expect (getErr ).NotTo (HaveOccurred ())
367+ g .Expect (strings .TrimSpace (out )).NotTo (BeEmpty ())
368+ }).Should (Succeed ())
369+ })
300370 })
301371})
0 commit comments