@@ -121,6 +121,29 @@ func describe() {
121121 ginkgo .By ("checking the pod total EPC size annotation is correctly set" )
122122 gomega .Expect (pod .Annotations ["sgx.intel.com/epc" ]).To (gomega .Equal ("3Mi" ))
123123 })
124+ ginkgo .It ("checks that Volumes and VolumeMounts are created only once" , func () {
125+ ginkgo .By ("submitting the pod" )
126+ podSpec := createPodSpec ([]string {"test" }, "aesmd" )
127+ podSpec .Spec .Volumes = make ([]v1.Volume , 0 )
128+ podSpec .Spec .Volumes = append (podSpec .Spec .Volumes , v1.Volume {
129+ Name : "/var/run/aesmd" ,
130+ VolumeSource : v1.VolumeSource {
131+ EmptyDir : & v1.EmptyDirVolumeSource {
132+ Medium : v1 .StorageMediumMemory ,
133+ },
134+ },
135+ })
136+ podSpec .Spec .Containers [0 ].VolumeMounts = make ([]v1.VolumeMount , 0 )
137+ podSpec .Spec .Containers [0 ].VolumeMounts = append (podSpec .Spec .Containers [0 ].VolumeMounts , v1.VolumeMount {
138+ Name : "aesmd-socket" ,
139+ MountPath : "/var/run/aesmd" ,
140+ })
141+ pod := submitCustomPod (f , podSpec )
142+ ginkgo .By ("checking Volumes in the pod" )
143+ gomega .Expect (len (pod .Spec .Volumes )).To (gomega .Equal (1 ))
144+ ginkgo .By ("checking VolumeMounts in the container" )
145+ gomega .Expect (len (pod .Spec .Containers [0 ].VolumeMounts )).To (gomega .Equal (1 ))
146+ })
124147}
125148
126149func checkMutatedVolumes (f * framework.Framework , pod * v1.Pod , volumeName string , volumeType interface {}) {
@@ -160,7 +183,16 @@ func checkMutatedResources(f *framework.Framework, r v1.ResourceRequirements, ex
160183 }
161184}
162185
163- func submitPod (f * framework.Framework , containerNames []string , quoteProvider string ) * v1.Pod {
186+ func submitCustomPod (f * framework.Framework , podSpec * v1.Pod ) * v1.Pod {
187+ pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (context .TODO (),
188+ podSpec , metav1.CreateOptions {})
189+
190+ framework .ExpectNoError (err , "pod Create API error" )
191+
192+ return pod
193+ }
194+
195+ func createPodSpec (containerNames []string , quoteProvider string ) * v1.Pod {
164196 containers := make ([]v1.Container , 0 )
165197
166198 for _ , c := range containerNames {
@@ -189,10 +221,9 @@ func submitPod(f *framework.Framework, containerNames []string, quoteProvider st
189221 },
190222 }
191223
192- pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (context .TODO (),
193- podSpec , metav1.CreateOptions {})
194-
195- framework .ExpectNoError (err , "pod Create API error" )
224+ return podSpec
225+ }
196226
197- return pod
227+ func submitPod (f * framework.Framework , containerNames []string , quoteProvider string ) * v1.Pod {
228+ return submitCustomPod (f , createPodSpec (containerNames , quoteProvider ))
198229}
0 commit comments