@@ -65,6 +65,81 @@ func TestNewLoadBalancer(t *testing.T) {
6565 Connection : cloud.Connection {IdleTimeout : 60 },
6666 IngressAddress : cloud .Hostname ,
6767 },
68+ }, {
69+ name : "autogenerated names are truncated to 32 chars (non multi-az)" ,
70+ svc : & corev1.Service {
71+ ObjectMeta : metav1.ObjectMeta {
72+ Name : "foo" ,
73+ UID : "5dbb147b-3878-4d10-bf2d-96b2b463b8eb" ,
74+ },
75+ Spec : corev1.ServiceSpec {
76+ SessionAffinity : corev1 .ServiceAffinityNone ,
77+ Ports : []corev1.ServicePort {{Protocol : corev1 .ProtocolTCP , Port : 42 , NodePort : 43 }},
78+ },
79+ },
80+ lb : & cloud.LoadBalancer {
81+ Name : []string {"5dbb147b38784d10bf2d96b2b463b8eb" },
82+ Instances : 1 ,
83+ ServiceName : "foo" ,
84+ Listeners : []cloud.Listener {{
85+ Port : 42 ,
86+ BackendPort : 43 ,
87+ }},
88+ ListenerDefaults : cloud.ListenerDefaults {
89+ SSLPorts : []string {"*" },
90+ },
91+ TargetRole : cloud .DefaultLoadBalancerConfiguration .TargetRole ,
92+ HealthCheck : cloud.HealthCheck {
93+ Port : 43 ,
94+ Protocol : "tcp" ,
95+ Interval : cloud .DefaultLoadBalancerConfiguration .HealthCheck .Interval ,
96+ Timeout : cloud .DefaultLoadBalancerConfiguration .HealthCheck .Timeout ,
97+ HealthyThreshold : cloud .DefaultLoadBalancerConfiguration .HealthCheck .HealthyThreshold ,
98+ UnhealthyThreshold : cloud .DefaultLoadBalancerConfiguration .HealthCheck .UnhealthyThreshold ,
99+ },
100+ AllowFrom : ipNetSet ("0.0.0.0/0" ),
101+ Connection : cloud.Connection {IdleTimeout : 60 },
102+ IngressAddress : cloud .Hostname ,
103+ },
104+ }, {
105+ name : "autogenerated names are truncated to 32 chars (multi-az)" ,
106+ svc : & corev1.Service {
107+ ObjectMeta : metav1.ObjectMeta {
108+ Name : "foo" ,
109+ UID : "5dbb147b-3878-4d10-bf2d-96b2b463b8eb" ,
110+ Annotations : map [string ]string {
111+ "service.beta.kubernetes.io/osc-load-balancer-instances" : "2" ,
112+ },
113+ },
114+ Spec : corev1.ServiceSpec {
115+ SessionAffinity : corev1 .ServiceAffinityNone ,
116+ Ports : []corev1.ServicePort {{Protocol : corev1 .ProtocolTCP , Port : 42 , NodePort : 43 }},
117+ },
118+ },
119+ lb : & cloud.LoadBalancer {
120+ Name : []string {"5dbb147b38784d10bf2d96b2b463b8-a" , "5dbb147b38784d10bf2d96b2b463b8-b" },
121+ Instances : 2 ,
122+ ServiceName : "foo" ,
123+ Listeners : []cloud.Listener {{
124+ Port : 42 ,
125+ BackendPort : 43 ,
126+ }},
127+ ListenerDefaults : cloud.ListenerDefaults {
128+ SSLPorts : []string {"*" },
129+ },
130+ TargetRole : cloud .DefaultLoadBalancerConfiguration .TargetRole ,
131+ HealthCheck : cloud.HealthCheck {
132+ Port : 43 ,
133+ Protocol : "tcp" ,
134+ Interval : cloud .DefaultLoadBalancerConfiguration .HealthCheck .Interval ,
135+ Timeout : cloud .DefaultLoadBalancerConfiguration .HealthCheck .Timeout ,
136+ HealthyThreshold : cloud .DefaultLoadBalancerConfiguration .HealthCheck .HealthyThreshold ,
137+ UnhealthyThreshold : cloud .DefaultLoadBalancerConfiguration .HealthCheck .UnhealthyThreshold ,
138+ },
139+ AllowFrom : ipNetSet ("0.0.0.0/0" ),
140+ Connection : cloud.Connection {IdleTimeout : 60 },
141+ IngressAddress : cloud .Hostname ,
142+ },
68143 }, {
69144 name : "Annotations are loaded" ,
70145 svc : & corev1.Service {
0 commit comments