@@ -55,6 +55,7 @@ func TestPluginOnPodCreate(t *testing.T) {
5555 ObjectMeta : metav1.ObjectMeta {
5656 Name : "Job1" ,
5757 Namespace : namespace ,
58+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
5859 },
5960 },
6061 Pod : buildPod (namespace , "pod1" , v1 .PodPending , nil ),
@@ -66,6 +67,7 @@ func TestPluginOnPodCreate(t *testing.T) {
6667 Job : & batch.Job {
6768 ObjectMeta : metav1.ObjectMeta {
6869 Name : "Job1" ,
70+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
6971 },
7072 },
7173 Pod : buildPod (namespace , "pod1" , v1 .PodPending , nil ),
@@ -124,7 +126,7 @@ func TestPluginOnPodCreate(t *testing.T) {
124126 }
125127 exist := false
126128 for _ , volume := range container .VolumeMounts {
127- if volume .Name == fmt .Sprint ( testcase .Job .Name , "- ssh" ) {
129+ if volume .Name == fmt .Sprintf ( "%s-%s-%s" , testcase .Job .Name , testcase . Job . UID , " ssh" ) {
128130 exist = true
129131 }
130132 }
@@ -153,6 +155,7 @@ func TestPluginOnJobAdd(t *testing.T) {
153155 ObjectMeta : metav1.ObjectMeta {
154156 Name : "job1" ,
155157 Namespace : namespace ,
158+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
156159 },
157160 },
158161 Plugins : []string {"svc" , "ssh" , "env" },
@@ -163,6 +166,7 @@ func TestPluginOnJobAdd(t *testing.T) {
163166 Job : & batch.Job {
164167 ObjectMeta : metav1.ObjectMeta {
165168 Name : "Job1" ,
169+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
166170 },
167171 },
168172 Plugins : []string {"new" },
@@ -202,9 +206,10 @@ func TestPluginOnJobAdd(t *testing.T) {
202206 }
203207
204208 if plugin == "ssh" {
205- _ , err := fakeController .kubeClient .CoreV1 ().ConfigMaps (namespace ).Get (fmt .Sprint (testcase .Job .Name , "-ssh" ), metav1.GetOptions {})
209+ _ , err := fakeController .kubeClient .CoreV1 ().Secrets (namespace ).Get (
210+ fmt .Sprintf ("%s-%s-%s" , testcase .Job .Name , testcase .Job .UID , "ssh" ), metav1.GetOptions {})
206211 if err != nil {
207- t .Errorf ("Case %d (%s): expected: ConfigMap to be created, but not created because of error %s" , i , testcase .Name , err .Error ())
212+ t .Errorf ("Case %d (%s): expected: Secret to be created, but not created because of error %s" , i , testcase .Name , err .Error ())
208213 }
209214 }
210215
@@ -233,6 +238,7 @@ func TestPluginOnJobDelete(t *testing.T) {
233238 ObjectMeta : metav1.ObjectMeta {
234239 Name : "job1" ,
235240 Namespace : namespace ,
241+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
236242 },
237243 },
238244 Plugins : []string {"svc" , "ssh" , "env" },
@@ -243,6 +249,7 @@ func TestPluginOnJobDelete(t *testing.T) {
243249 Job : & batch.Job {
244250 ObjectMeta : metav1.ObjectMeta {
245251 Name : "Job1" ,
252+ UID : "e7f18111-1cec-11ea-b688-fa163ec79500" ,
246253 },
247254 },
248255 Plugins : []string {"new" },
@@ -272,23 +279,23 @@ func TestPluginOnJobDelete(t *testing.T) {
272279 if plugin == "svc" {
273280 _ , err := fakeController .kubeClient .CoreV1 ().ConfigMaps (namespace ).Get (fmt .Sprint (testcase .Job .Name , "-svc" ), metav1.GetOptions {})
274281 if err == nil {
275- t .Errorf ("Case %d (%s): expected: ConfigMap to be deleted, but not deleted because of error %s " , i , testcase .Name , err . Error () )
282+ t .Errorf ("Case %d (%s): expected: ConfigMap to be deleted, but not deleted. " , i , testcase .Name )
276283 }
277284
278285 _ , err = fakeController .kubeClient .CoreV1 ().Services (namespace ).Get (testcase .Job .Name , metav1.GetOptions {})
279286 if err == nil {
280- t .Errorf ("Case %d (%s): expected: Service to be deleted, but not deleted because of error %s " , i , testcase .Name , err . Error () )
287+ t .Errorf ("Case %d (%s): expected: Service to be deleted, but not deleted. " , i , testcase .Name )
281288 }
282289 }
283290
284291 if plugin == "ssh" {
285- _ , err := fakeController .kubeClient .CoreV1 ().ConfigMaps (namespace ).Get (fmt .Sprint (testcase .Job .Name , "-ssh" ), metav1.GetOptions {})
292+ _ , err := fakeController .kubeClient .CoreV1 ().Secrets (namespace ).Get (
293+ fmt .Sprintf ("%s-%s-%s" , testcase .Job .Name , testcase .Job .UID , "ssh" ), metav1.GetOptions {})
286294 if err == nil {
287- t .Errorf ("Case %d (%s): expected: ConfigMap to be deleted, but not deleted because of error %s " , i , testcase .Name , err . Error () )
295+ t .Errorf ("Case %d (%s): expected: secret to be deleted, but not deleted. " , i , testcase .Name )
288296 }
289297 }
290298 }
291299 })
292-
293300 }
294301}
0 commit comments