@@ -120,6 +120,33 @@ var (
120120 },
121121 },
122122 }
123+
124+ testIngressMultiLabel = & networkingv1.Ingress {
125+ ObjectMeta : metav1.ObjectMeta {
126+ Name : "testMultiLabel" ,
127+ Namespace : "testNamespace" ,
128+ Annotations : map [string ]string {
129+ "com.uswitch.heimdall/5xx-rate" : "0.001" ,
130+ ownerAnnotation : "testIngressOwner" ,
131+ environmentAnnotation : "testing" ,
132+ criticalityAnnotation : "low" ,
133+ sensitivityAnnotation : "public" ,
134+ "com.uswitch.heimdall/label-priority" : "p2" ,
135+ "com.uswitch.heimdall/label-channel" : "testing" ,
136+ "com.uswitch.heimdall/label-region" : "eu-west-1" ,
137+ },
138+ },
139+ Spec : networkingv1.IngressSpec {
140+ DefaultBackend : & networkingv1.IngressBackend {
141+ Service : & networkingv1.IngressServiceBackend {
142+ Name : "testService" ,
143+ Port : networkingv1.ServiceBackendPort {
144+ Number : 80 ,
145+ },
146+ },
147+ },
148+ },
149+ }
123150)
124151
125152func TestIngressAnnotationsDefaultBackend (t * testing.T ) {
@@ -191,3 +218,19 @@ func TestNamesMatch(t *testing.T) {
191218 service = checkNamesMatch (services )
192219 assert .Equal (t , "" , service )
193220}
221+
222+ func TestIngressMultipleCustomLabels (t * testing.T ) {
223+ log .Setup (log .DEBUG_LEVEL )
224+
225+ client := fake .NewSimpleClientset (testService , testDeployment , testReplicaset , testPod )
226+
227+ template , err := NewPrometheusRuleTemplateManager ("../../kube/config/templates" , client )
228+
229+ promrules , err := template .CreateFromIngress (testIngressMultiLabel )
230+ assert .Assert (t , is .Nil (err ))
231+ assert .Assert (t , is .Len (promrules , 1 ))
232+ assert .Equal (t , promrules [0 ].Spec .Groups [0 ].Rules [0 ].Labels ["priority" ], "p2" )
233+ assert .Equal (t , promrules [0 ].Spec .Groups [0 ].Rules [0 ].Labels ["channel" ], "testing" )
234+ assert .Equal (t , promrules [0 ].Spec .Groups [0 ].Rules [0 ].Labels ["region" ], "eu-west-1" )
235+ }
236+
0 commit comments