@@ -131,8 +131,8 @@ func TestVirtualHostEquality(t *testing.T) {
131131}
132132
133133func TestClusterEquality (t * testing.T ) {
134- a := & cluster {Name : "foo" , Hosts : []string { "host1" , "host2" }}
135- b := & cluster {Name : "foo" , Hosts : []string { "host1" , "host2" }}
134+ a := & cluster {Name : "foo" , Hosts : []LBHost {{ "host1" , 1 }, { "host2" , 1 } }}
135+ b := & cluster {Name : "foo" , Hosts : []LBHost {{ "host1" , 1 }, { "host2" , 1 } }}
136136
137137 if ! a .Equals (b ) {
138138 t .Error ()
@@ -142,17 +142,17 @@ func TestClusterEquality(t *testing.T) {
142142 t .Error ("cluster is equals nil, expect not to be equal" )
143143 }
144144
145- c := & cluster {Name : "bar" , Hosts : []string { "host1" , "host2" }}
145+ c := & cluster {Name : "bar" , Hosts : []LBHost {{ "host1" , 1 }, { "host2" , 1 } }}
146146 if a .Equals (c ) {
147147 t .Error ("clusters have different names, expected not to be equal" )
148148 }
149149
150- d := & cluster {Name : "foo" , Hosts : []string { "host1" }} // missing host2
150+ d := & cluster {Name : "foo" , Hosts : []LBHost {{ "host1" , 1 } }} // missing host2
151151 if a .Equals (d ) {
152152 t .Error ("clusters have different hosts, should be different" )
153153 }
154154
155- e := & cluster {Name : "foo" , Hosts : []string { "bad1" , "bad2" }}
155+ e := & cluster {Name : "foo" , Hosts : []LBHost {{ "bad1" , 1 }, { "bad2" , 1 } }}
156156 if a .Equals (e ) {
157157 t .Error ("cluster hosts are different, shouldn't be equal" )
158158 }
@@ -162,7 +162,7 @@ func TestClusterEquality(t *testing.T) {
162162 t .Error ("no hosts set" )
163163 }
164164
165- g := & cluster {Name : "foo" , Hosts : []string { "host1" , "host2" }, Timeout : (5 * time .Second )}
165+ g := & cluster {Name : "foo" , Hosts : []LBHost {{ "host1" , 1 }, { "host2" , 1 } }, Timeout : (5 * time .Second )}
166166 if a .Equals (g ) {
167167 t .Error ("clusters with different timeout values should not be equal" )
168168 }
@@ -268,8 +268,12 @@ func TestGeneratesForSingleIngress(t *testing.T) {
268268 if c .Clusters [0 ].Name != "foo_app_com" {
269269 t .Errorf ("expected cluster to be named after ingress host, was %s" , c .Clusters [0 ].Name )
270270 }
271- if c .Clusters [0 ].Hosts [0 ] != "foo.cluster.com" {
272- t .Errorf ("expected cluster host for foo.cluster.com, was %s" , c .Clusters [0 ].Hosts [0 ])
271+ if c .Clusters [0 ].Hosts [0 ].Host != "foo.cluster.com" {
272+ t .Errorf ("expected cluster host for foo.cluster.com, was %s" , c .Clusters [0 ].Hosts [0 ].Host )
273+ }
274+
275+ if c .Clusters [0 ].Hosts [0 ].Weight != 1 {
276+ t .Errorf ("expected cluster host's weight for 1, was %d" , c .Clusters [0 ].Hosts [0 ].Weight )
273277 }
274278
275279 if c .VirtualHosts [0 ].UpstreamCluster != c .Clusters [0 ].Name {
@@ -304,11 +308,11 @@ func TestGeneratesForMultipleIngressSharingSpecHost(t *testing.T) {
304308 if len (c .Clusters [0 ].Hosts ) != 2 {
305309 t .Errorf ("expected 2 host, was %d" , len (c .Clusters [0 ].Hosts ))
306310 }
307- if c .Clusters [0 ].Hosts [0 ] != "foo.com" {
308- t .Errorf ("expected cluster host for foo.com, was %s" , c .Clusters [0 ].Hosts [0 ])
311+ if c .Clusters [0 ].Hosts [0 ]. Host != "foo.com" {
312+ t .Errorf ("expected cluster host for foo.com, was %s" , c .Clusters [0 ].Hosts [0 ]. Host )
309313 }
310- if c .Clusters [0 ].Hosts [1 ] != "bar.com" {
311- t .Errorf ("expected cluster host for bar.com, was %s" , c .Clusters [0 ].Hosts [1 ])
314+ if c .Clusters [0 ].Hosts [1 ]. Host != "bar.com" {
315+ t .Errorf ("expected cluster host for bar.com, was %s" , c .Clusters [0 ].Hosts [1 ]. Host )
312316 }
313317
314318 if c .VirtualHosts [0 ].UpstreamCluster != c .Clusters [0 ].Name {
@@ -340,8 +344,8 @@ func TestFilterNonMatchingIngresses(t *testing.T) {
340344func TestIngressWithIP (t * testing.T ) {
341345 ingress := newIngressIP ("app.com" , "127.0.0.1" )
342346 c := translateIngresses ([]* k8s.Ingress {ingress }, false , []* v1.Secret {})
343- if c .Clusters [0 ].Hosts [0 ] != "127.0.0.1" {
344- t .Errorf ("expected cluster host to be IP address, was %s" , c .Clusters [0 ].Hosts [0 ])
347+ if c .Clusters [0 ].Hosts [0 ]. Host != "127.0.0.1" {
348+ t .Errorf ("expected cluster host to be IP address, was %s" , c .Clusters [0 ].Hosts [0 ]. Host )
345349 }
346350}
347351
0 commit comments