@@ -43,9 +43,12 @@ func newTestScheme() *runtime.Scheme {
4343
4444var _ = Describe ("DataOpJobReconciler" , func () {
4545 const (
46- controllerUIDKey = "controller-uid"
47- testNodeName = "node01"
48- testPodName = "test-pod"
46+ controllerUIDKey = "controller-uid"
47+ testNodeName = "node01"
48+ testPodName = "test-pod"
49+ testJobName = "test-job"
50+ customLabelKey = "custom-label"
51+ testControllerUID = "test-uid"
4952 )
5053
5154 var testScheme * runtime.Scheme
@@ -115,8 +118,6 @@ var _ = Describe("DataOpJobReconciler", func() {
115118
116119 Context ("when job is a valid fluid job without affinity annotation" , func () {
117120 It ("injects the dataflow affinity annotation and returns no requeue" , func () {
118- const testJobName = "test-job"
119-
120121 job := & batchv1.Job {
121122 ObjectMeta : metav1.ObjectMeta {
122123 Name : testJobName ,
@@ -211,13 +212,13 @@ var _ = Describe("DataOpJobReconciler", func() {
211212 common .K8sNodeNameLabelKey : testNodeName ,
212213 common .K8sRegionLabelKey : "region01" ,
213214 common .K8sZoneLabelKey : "zone01" ,
214- "custom-label" : "custom-value" ,
215+ customLabelKey : "custom-value" ,
215216 }
216217 exposedLabelNames := []string {
217218 common .K8sNodeNameLabelKey ,
218219 common .K8sRegionLabelKey ,
219220 common .K8sZoneLabelKey ,
220- "custom-label" ,
221+ customLabelKey ,
221222 }
222223
223224 fillCustomizedNodeAffinity (annotationsToInject , nodeLabels , exposedLabelNames )
@@ -226,7 +227,7 @@ var _ = Describe("DataOpJobReconciler", func() {
226227 Expect (annotationsToInject [common .AnnotationDataFlowCustomizedAffinityPrefix + common .K8sNodeNameLabelKey ]).To (Equal (testNodeName ))
227228 Expect (annotationsToInject [common .AnnotationDataFlowCustomizedAffinityPrefix + common .K8sRegionLabelKey ]).To (Equal ("region01" ))
228229 Expect (annotationsToInject [common .AnnotationDataFlowCustomizedAffinityPrefix + common .K8sZoneLabelKey ]).To (Equal ("zone01" ))
229- Expect (annotationsToInject [common .AnnotationDataFlowCustomizedAffinityPrefix + "custom-label" ]).To (Equal ("custom-value" ))
230+ Expect (annotationsToInject [common .AnnotationDataFlowCustomizedAffinityPrefix + customLabelKey ]).To (Equal ("custom-value" ))
230231 })
231232
232233 It ("skips non-existent labels" , func () {
@@ -266,7 +267,7 @@ var _ = Describe("DataOpJobReconciler", func() {
266267 It ("injects node labels as annotations onto the job" , func () {
267268 job := & batchv1.Job {
268269 ObjectMeta : metav1.ObjectMeta {
269- Name : "test-job" ,
270+ Name : testJobName ,
270271 Labels : map [string ]string {
271272 common .LabelAnnotationManagedBy : common .Fluid ,
272273 },
@@ -376,15 +377,15 @@ var _ = Describe("DataOpJobReconciler", func() {
376377 It ("returns an error" , func () {
377378 job := & batchv1.Job {
378379 ObjectMeta : metav1.ObjectMeta {
379- Name : "test-job" ,
380+ Name : testJobName ,
380381 Labels : map [string ]string {
381382 common .LabelAnnotationManagedBy : common .Fluid ,
382383 },
383384 },
384385 Spec : batchv1.JobSpec {
385386 Selector : & metav1.LabelSelector {
386387 MatchLabels : map [string ]string {
387- controllerUIDKey : "test-uid" ,
388+ controllerUIDKey : testControllerUID ,
388389 },
389390 },
390391 },
@@ -393,7 +394,7 @@ var _ = Describe("DataOpJobReconciler", func() {
393394 ObjectMeta : metav1.ObjectMeta {
394395 Name : testPodName ,
395396 Labels : map [string ]string {
396- controllerUIDKey : "test-uid" ,
397+ controllerUIDKey : testControllerUID ,
397398 },
398399 },
399400 Spec : v1.PodSpec {NodeName : "" },
@@ -413,7 +414,7 @@ var _ = Describe("DataOpJobReconciler", func() {
413414 It ("creates the annotations map before injecting labels" , func () {
414415 job := & batchv1.Job {
415416 ObjectMeta : metav1.ObjectMeta {
416- Name : "test-job" ,
417+ Name : testJobName ,
417418 Labels : map [string ]string {
418419 common .LabelAnnotationManagedBy : common .Fluid ,
419420 },
@@ -422,7 +423,7 @@ var _ = Describe("DataOpJobReconciler", func() {
422423 Spec : batchv1.JobSpec {
423424 Selector : & metav1.LabelSelector {
424425 MatchLabels : map [string ]string {
425- controllerUIDKey : "test-uid" ,
426+ controllerUIDKey : testControllerUID ,
426427 },
427428 },
428429 },
@@ -431,7 +432,7 @@ var _ = Describe("DataOpJobReconciler", func() {
431432 ObjectMeta : metav1.ObjectMeta {
432433 Name : testPodName ,
433434 Labels : map [string ]string {
434- controllerUIDKey : "test-uid" ,
435+ controllerUIDKey : testControllerUID ,
435436 },
436437 },
437438 Spec : v1.PodSpec {NodeName : testNodeName },
0 commit comments