1+ suite : Test Descheduler CronJob and Job Annotations and Labels
2+
3+ templates :
4+ - " *.yaml"
5+
6+ release :
7+ name : descheduler
8+
9+ set :
10+ kind : CronJob
11+
12+ tests :
13+ - it : adds cronJob and job annotations and labels when set
14+ template : templates/cronjob.yaml
15+ set :
16+ cronJobAnnotations :
17+ monitoring.company.com/scrape : " true"
18+ description : " test cronjob"
19+ cronJobLabels :
20+ environment : " test"
21+ team : " platform"
22+ jobAnnotations :
23+ sidecar.istio.io/inject : " false"
24+ job.company.com/retry-limit : " 3"
25+ jobLabels :
26+ job-type : " maintenance"
27+ priority : " high"
28+ asserts :
29+ - equal :
30+ path : metadata.annotations["monitoring.company.com/scrape"]
31+ value : " true"
32+ - equal :
33+ path : metadata.annotations.description
34+ value : " test cronjob"
35+ - equal :
36+ path : metadata.labels.environment
37+ value : " test"
38+ - equal :
39+ path : metadata.labels.team
40+ value : " platform"
41+ - equal :
42+ path : spec.jobTemplate.metadata.annotations["sidecar.istio.io/inject"]
43+ value : " false"
44+ - equal :
45+ path : spec.jobTemplate.metadata.annotations["job.company.com/retry-limit"]
46+ value : " 3"
47+ - equal :
48+ path : spec.jobTemplate.metadata.labels.job-type
49+ value : " maintenance"
50+ - equal :
51+ path : spec.jobTemplate.metadata.labels.priority
52+ value : " high"
53+
54+ - it : does not add cronJob and job metadata when not set
55+ template : templates/cronjob.yaml
56+ asserts :
57+ - isNull :
58+ path : metadata.annotations
59+ - isNotNull :
60+ path : metadata.labels
61+ - equal :
62+ path : metadata.labels["app.kubernetes.io/name"]
63+ value : descheduler
64+ - isNull :
65+ path : spec.jobTemplate.metadata
66+
67+ - it : does not add job metadata when job annotations and labels are empty
68+ template : templates/cronjob.yaml
69+ set :
70+ jobAnnotations : {}
71+ jobLabels : {}
72+ asserts :
73+ - isNull :
74+ path : spec.jobTemplate.metadata
75+
76+ - it : works with all annotation and label types together
77+ template : templates/cronjob.yaml
78+ set :
79+ cronJobAnnotations :
80+ cron-annotation : " cron-value"
81+ cronJobLabels :
82+ cron-label : " cron-value"
83+ jobAnnotations :
84+ job-annotation : " job-value"
85+ jobLabels :
86+ job-label : " job-value"
87+ podAnnotations :
88+ pod-annotation : " pod-value"
89+ podLabels :
90+ pod-label : " pod-value"
91+ asserts :
92+ - equal :
93+ path : metadata.annotations.cron-annotation
94+ value : " cron-value"
95+ - equal :
96+ path : metadata.labels.cron-label
97+ value : " cron-value"
98+ - equal :
99+ path : spec.jobTemplate.metadata.annotations.job-annotation
100+ value : " job-value"
101+ - equal :
102+ path : spec.jobTemplate.metadata.labels.job-label
103+ value : " job-value"
104+ - equal :
105+ path : spec.jobTemplate.spec.template.metadata.annotations.pod-annotation
106+ value : " pod-value"
107+ - equal :
108+ path : spec.jobTemplate.spec.template.metadata.labels.pod-label
109+ value : " pod-value"
0 commit comments