@@ -119,5 +119,66 @@ var _ = Describe("IP Pool Reconciler", func() {
119
119
Entry ("When there is 1 claim with gateway outside of range - GlobalInClusterIPPool" ,
120
120
"GlobalInClusterIPPool" , []string {"10.0.0.10-10.0.0.20" }, "10.0.0.1" , 11 , 1 , 10 ),
121
121
)
122
+
123
+ DescribeTable ("it shows the out of range ips if any" ,
124
+ func (poolType string , addresses []string , gateway string , updatedAddresses []string , numClaims , expectedOutOfRange int ) {
125
+ poolSpec := v1alpha1.InClusterIPPoolSpec {
126
+ Prefix : 24 ,
127
+ Gateway : gateway ,
128
+ Addresses : addresses ,
129
+ }
130
+
131
+ switch poolType {
132
+ case "InClusterIPPool" :
133
+ genericPool = & v1alpha1.InClusterIPPool {
134
+ ObjectMeta : metav1.ObjectMeta {GenerateName : testPool , Namespace : namespace },
135
+ Spec : poolSpec ,
136
+ }
137
+ case "GlobalInClusterIPPool" :
138
+ genericPool = & v1alpha1.GlobalInClusterIPPool {
139
+ ObjectMeta : metav1.ObjectMeta {GenerateName : testPool , Namespace : namespace },
140
+ Spec : poolSpec ,
141
+ }
142
+ default :
143
+ Fail ("Unknown pool type" )
144
+ }
145
+
146
+ Expect (k8sClient .Create (context .Background (), genericPool )).To (Succeed ())
147
+
148
+ for i := 0 ; i < numClaims ; i ++ {
149
+ claim := clusterv1.IPAddressClaim {
150
+ ObjectMeta : metav1.ObjectMeta {
151
+ Name : fmt .Sprintf ("test%d" , i ),
152
+ Namespace : namespace ,
153
+ },
154
+ Spec : clusterv1.IPAddressClaimSpec {
155
+ PoolRef : corev1.TypedLocalObjectReference {
156
+ APIGroup : pointer .String ("ipam.cluster.x-k8s.io" ),
157
+ Kind : poolType ,
158
+ Name : genericPool .GetName (),
159
+ },
160
+ },
161
+ }
162
+ Expect (k8sClient .Create (context .Background (), & claim )).To (Succeed ())
163
+ createdClaimNames = append (createdClaimNames , claim .Name )
164
+ }
165
+
166
+ Eventually (Object (genericPool )).
167
+ WithTimeout (5 * time .Second ).WithPolling (100 * time .Millisecond ).Should (
168
+ HaveField ("Status.Addresses.Used" , Equal (numClaims )))
169
+
170
+ genericPool .PoolSpec ().Addresses = updatedAddresses
171
+ Expect (k8sClient .Update (context .Background (), genericPool )).To (Succeed ())
172
+
173
+ Eventually (Object (genericPool )).
174
+ WithTimeout (5 * time .Second ).WithPolling (100 * time .Millisecond ).Should (
175
+ HaveField ("Status.Addresses.OutOfRange" , Equal (expectedOutOfRange )))
176
+ },
177
+
178
+ Entry ("InClusterIPPool" ,
179
+ "InClusterIPPool" , []string {"10.0.0.10-10.0.0.20" }, "10.0.0.1" , []string {"10.0.0.13-10.0.0.20" }, 5 , 3 ),
180
+ Entry ("GlobalInClusterIPPool" ,
181
+ "GlobalInClusterIPPool" , []string {"10.0.0.10-10.0.0.20" }, "10.0.0.1" , []string {"10.0.0.13-10.0.0.20" }, 5 , 3 ),
182
+ )
122
183
})
123
184
})
0 commit comments