@@ -191,29 +191,9 @@ func (t *dnsTestCommon) restoreDNSConfigMap(configMapData map[string]string) {
191
191
func (t * dnsTestCommon ) createUtilPodLabel (baseName string ) {
192
192
// Actual port # doesn't matter, just needs to exist.
193
193
const servicePort = 10101
194
-
195
- t .utilPod = & v1.Pod {
196
- TypeMeta : metav1.TypeMeta {
197
- Kind : "Pod" ,
198
- },
199
- ObjectMeta : metav1.ObjectMeta {
200
- Namespace : t .f .Namespace .Name ,
201
- Labels : map [string ]string {"app" : baseName },
202
- GenerateName : baseName + "-" ,
203
- },
204
- Spec : v1.PodSpec {
205
- Containers : []v1.Container {
206
- {
207
- Name : "util" ,
208
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
209
- Command : []string {"sleep" , "10000" },
210
- Ports : []v1.ContainerPort {
211
- {ContainerPort : servicePort , Protocol : v1 .ProtocolTCP },
212
- },
213
- },
214
- },
215
- },
216
- }
194
+ podName := fmt .Sprintf ("%s-%s" , baseName , string (uuid .NewUUID ()))
195
+ ports := []v1.ContainerPort {{ContainerPort : servicePort , Protocol : v1 .ProtocolTCP }}
196
+ t .utilPod = e2epod .NewAgnhostPod (t .f .Namespace .Name , podName , nil , nil , ports )
217
197
218
198
var err error
219
199
t .utilPod , err = t .c .CoreV1 ().Pods (t .f .Namespace .Name ).Create (context .TODO (), t .utilPod , metav1.CreateOptions {})
@@ -272,46 +252,31 @@ func (t *dnsTestCommon) deleteCoreDNSPods() {
272
252
}
273
253
274
254
func generateCoreDNSServerPod (corednsConfig * v1.ConfigMap ) * v1.Pod {
275
- return & v1.Pod {
276
- TypeMeta : metav1.TypeMeta {
277
- Kind : "Pod" ,
278
- },
279
- ObjectMeta : metav1.ObjectMeta {
280
- GenerateName : "e2e-dns-configmap-dns-server-" ,
281
- },
282
- Spec : v1.PodSpec {
283
- Volumes : []v1.Volume {
284
- {
285
- Name : "coredns-config" ,
286
- VolumeSource : v1.VolumeSource {
287
- ConfigMap : & v1.ConfigMapVolumeSource {
288
- LocalObjectReference : v1.LocalObjectReference {
289
- Name : corednsConfig .Name ,
290
- },
291
- },
292
- },
293
- },
294
- },
295
- Containers : []v1.Container {
296
- {
297
- Name : "dns" ,
298
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
299
- Command : []string {
300
- "/coredns" ,
301
- "-conf" , "/etc/coredns/Corefile" ,
302
- },
303
- VolumeMounts : []v1.VolumeMount {
304
- {
305
- Name : "coredns-config" ,
306
- MountPath : "/etc/coredns" ,
307
- ReadOnly : true ,
308
- },
255
+ podName := fmt .Sprintf ("e2e-configmap-dns-server-%s" , string (uuid .NewUUID ()))
256
+ volumes := []v1.Volume {
257
+ {
258
+ Name : "coredns-config" ,
259
+ VolumeSource : v1.VolumeSource {
260
+ ConfigMap : & v1.ConfigMapVolumeSource {
261
+ LocalObjectReference : v1.LocalObjectReference {
262
+ Name : corednsConfig .Name ,
309
263
},
310
264
},
311
265
},
312
- DNSPolicy : "Default" ,
313
266
},
314
267
}
268
+ mounts := []v1.VolumeMount {
269
+ {
270
+ Name : "coredns-config" ,
271
+ MountPath : "/etc/coredns" ,
272
+ ReadOnly : true ,
273
+ },
274
+ }
275
+
276
+ pod := e2epod .NewAgnhostPod ("" , podName , volumes , mounts , nil , "-conf" , "/etc/coredns/Corefile" )
277
+ pod .Spec .Containers [0 ].Command = []string {"/coredns" }
278
+ pod .Spec .DNSPolicy = "Default"
279
+ return pod
315
280
}
316
281
317
282
func generateCoreDNSConfigmap (namespaceName string , aRecords map [string ]string ) * v1.ConfigMap {
@@ -382,69 +347,37 @@ func (t *dnsTestCommon) deleteDNSServerPod() {
382
347
}
383
348
384
349
func createDNSPod (namespace , wheezyProbeCmd , jessieProbeCmd , podHostName , serviceName string ) * v1.Pod {
385
- dnsPod := & v1.Pod {
386
- TypeMeta : metav1.TypeMeta {
387
- Kind : "Pod" ,
388
- APIVersion : "v1" ,
389
- },
390
- ObjectMeta : metav1.ObjectMeta {
391
- Name : "dns-test-" + string (uuid .NewUUID ()),
392
- Namespace : namespace ,
393
- },
394
- Spec : v1.PodSpec {
395
- Volumes : []v1.Volume {
396
- {
397
- Name : "results" ,
398
- VolumeSource : v1.VolumeSource {
399
- EmptyDir : & v1.EmptyDirVolumeSource {},
400
- },
401
- },
402
- },
403
- Containers : []v1.Container {
404
- // TODO: Consider scraping logs instead of running a webserver.
405
- {
406
- Name : "webserver" ,
407
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
408
- Args : []string {"test-webserver" },
409
- Ports : []v1.ContainerPort {
410
- {
411
- Name : "http" ,
412
- ContainerPort : 80 ,
413
- },
414
- },
415
- VolumeMounts : []v1.VolumeMount {
416
- {
417
- Name : "results" ,
418
- MountPath : "/results" ,
419
- },
420
- },
421
- },
422
- {
423
- Name : "querier" ,
424
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
425
- Command : []string {"sh" , "-c" , wheezyProbeCmd },
426
- VolumeMounts : []v1.VolumeMount {
427
- {
428
- Name : "results" ,
429
- MountPath : "/results" ,
430
- },
431
- },
432
- },
433
- {
434
- Name : "jessie-querier" ,
435
- Image : imageutils .GetE2EImage (imageutils .JessieDnsutils ),
436
- Command : []string {"sh" , "-c" , jessieProbeCmd },
437
- VolumeMounts : []v1.VolumeMount {
438
- {
439
- Name : "results" ,
440
- MountPath : "/results" ,
441
- },
442
- },
443
- },
350
+ podName := "dns-test-" + string (uuid .NewUUID ())
351
+ volumes := []v1.Volume {
352
+ {
353
+ Name : "results" ,
354
+ VolumeSource : v1.VolumeSource {
355
+ EmptyDir : & v1.EmptyDirVolumeSource {},
444
356
},
445
357
},
446
358
}
359
+ mounts := []v1.VolumeMount {
360
+ {
361
+ Name : "results" ,
362
+ MountPath : "/results" ,
363
+ },
364
+ }
365
+
366
+ // TODO: Consider scraping logs instead of running a webserver.
367
+ dnsPod := e2epod .NewAgnhostPod (namespace , podName , volumes , mounts , nil , "test-webserver" )
368
+ dnsPod .Spec .Containers [0 ].Name = "webserver"
447
369
370
+ querier := e2epod .NewAgnhostContainer ("querier" , mounts , nil , wheezyProbeCmd )
371
+ querier .Command = []string {"sh" , "-c" }
372
+
373
+ jessieQuerier := v1.Container {
374
+ Name : "jessie-querier" ,
375
+ Image : imageutils .GetE2EImage (imageutils .JessieDnsutils ),
376
+ Command : []string {"sh" , "-c" , jessieProbeCmd },
377
+ VolumeMounts : mounts ,
378
+ }
379
+
380
+ dnsPod .Spec .Containers = append (dnsPod .Spec .Containers , querier , jessieQuerier )
448
381
dnsPod .Spec .Hostname = podHostName
449
382
dnsPod .Spec .Subdomain = serviceName
450
383
@@ -617,23 +550,3 @@ func validateTargetedProbeOutput(f *framework.Framework, pod *v1.Pod, fileNames
617
550
618
551
framework .Logf ("DNS probes using %s succeeded\n " , pod .Name )
619
552
}
620
-
621
- func generateDNSUtilsPod () * v1.Pod {
622
- return & v1.Pod {
623
- TypeMeta : metav1.TypeMeta {
624
- Kind : "Pod" ,
625
- },
626
- ObjectMeta : metav1.ObjectMeta {
627
- GenerateName : "e2e-dns-utils-" ,
628
- },
629
- Spec : v1.PodSpec {
630
- Containers : []v1.Container {
631
- {
632
- Name : "util" ,
633
- Image : imageutils .GetE2EImage (imageutils .Agnhost ),
634
- Command : []string {"sleep" , "10000" },
635
- },
636
- },
637
- },
638
- }
639
- }
0 commit comments