@@ -82,16 +82,20 @@ func TestIstioRouter_Sync(t *testing.T) {
82
82
gateways := vsClone .Spec .Gateways
83
83
gateways = append (gateways , "test-gateway.istio-system" )
84
84
vsClone .Spec .Gateways = gateways
85
+ totalGateways := len (mocks .canary .Spec .Service .Gateways )
85
86
86
87
vsGateways , err := mocks .meshClient .NetworkingV1alpha3 ().VirtualServices ("default" ).Update (vsClone )
87
88
if err != nil {
88
89
t .Fatal (err .Error ())
89
90
}
90
- if len (vsGateways .Spec .Gateways ) != 2 {
91
- t .Errorf ("Got Istio VS gateway %v wanted %v" , vsGateways .Spec .Gateways , 2 )
91
+
92
+ totalGateways ++
93
+ if len (vsGateways .Spec .Gateways ) != totalGateways {
94
+ t .Errorf ("Got Istio VS gateway %v wanted %v" , vsGateways .Spec .Gateways , totalGateways )
92
95
}
93
96
94
97
// undo change
98
+ totalGateways --
95
99
err = router .Reconcile (mocks .canary )
96
100
if err != nil {
97
101
t .Fatal (err .Error ())
@@ -102,8 +106,8 @@ func TestIstioRouter_Sync(t *testing.T) {
102
106
if err != nil {
103
107
t .Fatal (err .Error ())
104
108
}
105
- if len (vs .Spec .Gateways ) != 1 {
106
- t .Errorf ("Got Istio VS gateways %v wanted %v" , vs .Spec .Gateways , 1 )
109
+ if len (vs .Spec .Gateways ) != totalGateways {
110
+ t .Errorf ("Got Istio VS gateways %v wanted %v" , vs .Spec .Gateways , totalGateways )
107
111
}
108
112
}
109
113
@@ -438,3 +442,28 @@ func TestIstioRouter_ABTest(t *testing.T) {
438
442
t .Errorf ("Got mirror %v wanted nil" , mirror )
439
443
}
440
444
}
445
+
446
+ func TestIstioRouter_GatewayPort (t * testing.T ) {
447
+ mocks := newFixture ()
448
+ router := & IstioRouter {
449
+ logger : mocks .logger ,
450
+ flaggerClient : mocks .flaggerClient ,
451
+ istioClient : mocks .meshClient ,
452
+ kubeClient : mocks .kubeClient ,
453
+ }
454
+
455
+ err := router .Reconcile (mocks .canary )
456
+ if err != nil {
457
+ t .Fatal (err .Error ())
458
+ }
459
+
460
+ vs , err := mocks .meshClient .NetworkingV1alpha3 ().VirtualServices ("default" ).Get ("podinfo" , metav1.GetOptions {})
461
+ if err != nil {
462
+ t .Fatal (err .Error ())
463
+ }
464
+
465
+ port := vs .Spec .Http [0 ].Route [0 ].Destination .Port .Number
466
+ if port != uint32 (mocks .canary .Spec .Service .Port ) {
467
+ t .Fatalf ("Got port %v wanted %v" , port , mocks .canary .Spec .Service .Port )
468
+ }
469
+ }
0 commit comments