@@ -52,7 +52,7 @@ func describe() {
5252 framework .Failf ("unable to locate %q: %v" , kustomizationYaml , errFailedToLocateRepoFile )
5353 }
5454
55- ginkgo .It ( "checks availability of GPU resources" , func (ctx context.Context ) {
55+ ginkgo .BeforeEach ( func (ctx context.Context ) {
5656 ginkgo .By ("deploying GPU plugin" )
5757 e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "apply" , "-k" , filepath .Dir (kustomizationPath ))
5858
@@ -69,49 +69,54 @@ func describe() {
6969 if err = utils .TestPodsFileSystemInfo (podList .Items ); err != nil {
7070 framework .Failf ("container filesystem info checks failed: %v" , err )
7171 }
72+ })
7273
73- ginkgo .By ("checking if the resource is allocatable" )
74- if err = utils .WaitForNodesWithResource (ctx , f .ClientSet , "gpu.intel.com/i915" , 30 * time .Second ); err != nil {
75- framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
76- }
77-
78- ginkgo .By ("submitting a pod requesting GPU resources" )
79- podSpec := & v1.Pod {
80- ObjectMeta : metav1.ObjectMeta {Name : "gpuplugin-tester" },
81- Spec : v1.PodSpec {
82- Containers : []v1.Container {
83- {
84- Args : []string {"-c" , "ls /dev/dri" },
85- Name : containerName ,
86- Image : imageutils .GetE2EImage (imageutils .BusyBox ),
87- Command : []string {"/bin/sh" },
88- Resources : v1.ResourceRequirements {
89- Requests : v1.ResourceList {"gpu.intel.com/i915" : resource .MustParse ("1" )},
90- Limits : v1.ResourceList {"gpu.intel.com/i915" : resource .MustParse ("1" )},
74+ ginkgo .Context ("When GPU resources are available" , func () {
75+ ginkgo .BeforeEach (func (ctx context.Context ) {
76+ ginkgo .By ("checking if the resource is allocatable" )
77+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , "gpu.intel.com/i915" , 30 * time .Second ); err != nil {
78+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
79+ }
80+ })
81+ ginkgo .It ("checks availability of GPU resources" , func (ctx context.Context ) {
82+ ginkgo .By ("submitting a pod requesting GPU resources" )
83+ podSpec := & v1.Pod {
84+ ObjectMeta : metav1.ObjectMeta {Name : "gpuplugin-tester" },
85+ Spec : v1.PodSpec {
86+ Containers : []v1.Container {
87+ {
88+ Args : []string {"-c" , "ls /dev/dri" },
89+ Name : containerName ,
90+ Image : imageutils .GetE2EImage (imageutils .BusyBox ),
91+ Command : []string {"/bin/sh" },
92+ Resources : v1.ResourceRequirements {
93+ Requests : v1.ResourceList {"gpu.intel.com/i915" : resource .MustParse ("1" )},
94+ Limits : v1.ResourceList {"gpu.intel.com/i915" : resource .MustParse ("1" )},
95+ },
9196 },
9297 },
98+ RestartPolicy : v1 .RestartPolicyNever ,
9399 },
94- RestartPolicy : v1 .RestartPolicyNever ,
95- },
96- }
97- pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (ctx , podSpec , metav1.CreateOptions {})
98- framework .ExpectNoError (err , "pod Create API error" )
100+ }
101+ pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (ctx , podSpec , metav1.CreateOptions {})
102+ framework .ExpectNoError (err , "pod Create API error" )
99103
100- ginkgo .By ("waiting the pod to finish successfully" )
101- e2epod .NewPodClient (f ).WaitForSuccess (ctx , pod .ObjectMeta .Name , 60 * time .Second )
104+ ginkgo .By ("waiting the pod to finish successfully" )
105+ e2epod .NewPodClient (f ).WaitForSuccess (ctx , pod .ObjectMeta .Name , 60 * time .Second )
102106
103- ginkgo .By ("checking log output" )
104- log , err := e2epod .GetPodLogs (ctx , f .ClientSet , f .Namespace .Name , pod .Name , containerName )
107+ ginkgo .By ("checking log output" )
108+ log , err := e2epod .GetPodLogs (ctx , f .ClientSet , f .Namespace .Name , pod .Name , containerName )
105109
106- if err != nil {
107- framework .Failf ("unable to get log from pod: %v" , err )
108- }
110+ if err != nil {
111+ framework .Failf ("unable to get log from pod: %v" , err )
112+ }
109113
110- if ! strings .Contains (log , "card" ) || ! strings .Contains (log , "renderD" ) {
111- framework .Logf ("log output: %s" , log )
112- framework .Failf ("device mounts not found from log" )
113- }
114+ if ! strings .Contains (log , "card" ) || ! strings .Contains (log , "renderD" ) {
115+ framework .Logf ("log output: %s" , log )
116+ framework .Failf ("device mounts not found from log" )
117+ }
114118
115- framework .Logf ("found card and renderD from the log" )
119+ framework .Logf ("found card and renderD from the log" )
120+ })
116121 })
117122}
0 commit comments