@@ -30,7 +30,7 @@ func networkingIngress(name string, port int, serviceName string) *networkingv1.
30
30
return & networkingv1.Ingress {
31
31
ObjectMeta : metav1.ObjectMeta {
32
32
Name : name ,
33
- Namespace : "some-namespace" ,
33
+ Namespace : metav1 . NamespaceDefault ,
34
34
Annotations : map [string ]string {
35
35
"annotation-key1" : "annotation-value1" ,
36
36
},
@@ -511,6 +511,46 @@ func TestReconcileStableAndCanaryIngressFoundPatch(t *testing.T) {
511
511
}
512
512
}
513
513
514
+ func TestReconcileWillInvokeNetworkingIngress (t * testing.T ) {
515
+ // given
516
+ rollout := fakeRollout ("stable-service" , "canary-service" , "stable-ingress" )
517
+ stableIngress := networkingIngress ("stable-ingress" , 80 , "stable-service" )
518
+ canaryIngress := networkingIngress ("rollout-stable-ingress-canary" , 80 , "canary-service" )
519
+ canaryIngress .SetAnnotations (map [string ]string {
520
+ "nginx.ingress.kubernetes.io/canary" : "true" ,
521
+ "nginx.ingress.kubernetes.io/canary-weight" : "15" ,
522
+ })
523
+ canaryIngress .SetOwnerReferences ([]metav1.OwnerReference {* metav1 .NewControllerRef (rollout , schema.GroupVersionKind {Group : "argoproj.io" , Version : "v1alpha1" , Kind : "Rollout" })})
524
+ client := fake .NewSimpleClientset (stableIngress , canaryIngress )
525
+ k8sI := kubeinformers .NewSharedInformerFactory (client , 0 )
526
+ k8sI .Networking ().V1 ().Ingresses ().Informer ().GetIndexer ().Add (stableIngress )
527
+ k8sI .Networking ().V1 ().Ingresses ().Informer ().GetIndexer ().Add (canaryIngress )
528
+ ingressWrapper , err := ingressutil .NewIngressWrapper (ingressutil .IngressModeNetworking , client , k8sI )
529
+ if err != nil {
530
+ t .Fatal (err )
531
+ }
532
+ r := NewReconciler (ReconcilerConfig {
533
+ Rollout : rollout ,
534
+ Client : client ,
535
+ Recorder : record .NewFakeEventRecorder (),
536
+ ControllerKind : schema.GroupVersionKind {Group : "foo" , Version : "v1" , Kind : "Bar" },
537
+ IngressWrapper : ingressWrapper ,
538
+ })
539
+
540
+ // when
541
+ err = r .SetWeight (10 )
542
+
543
+ // then
544
+ assert .Nil (t , err , "Reconcile returns no error" )
545
+ actions := client .Actions ()
546
+ assert .Len (t , actions , 1 )
547
+ if ! t .Failed () {
548
+ // Avoid "index out of range" errors
549
+ assert .Equal (t , "patch" , actions [0 ].GetVerb (), "action: patch canary ingress" )
550
+ assert .Equal (t , schema.GroupVersionResource {Group : "networking.k8s.io" , Version : "v1" , Resource : "ingresses" }, actions [0 ].GetResource (), "action: patch canary ingress" )
551
+ }
552
+ }
553
+
514
554
func TestReconcileStableAndCanaryIngressFoundNoChange (t * testing.T ) {
515
555
rollout := fakeRollout ("stable-service" , "canary-service" , "stable-ingress" )
516
556
stableIngress := extensionsIngress ("stable-ingress" , 80 , "stable-service" )
0 commit comments