@@ -99,6 +99,67 @@ var _ = Describe("IP Pool Reconciler", func() {
99
99
Entry ("When there is 1 claim with gateway outside of range - GlobalInClusterIPPool" ,
100
100
"GlobalInClusterIPPool" , []string {"10.0.0.10-10.0.0.20" }, "10.0.0.1" , 11 , 1 , 10 ),
101
101
)
102
+
103
+ DescribeTable ("it shows the out of range ips if any" ,
104
+ func (poolType string , addresses []string , gateway string , updatedAddresses []string , numClaims , expectedOutOfRange int ) {
105
+ poolSpec := v1alpha1.InClusterIPPoolSpec {
106
+ Prefix : 24 ,
107
+ Gateway : gateway ,
108
+ Addresses : addresses ,
109
+ }
110
+
111
+ switch poolType {
112
+ case "InClusterIPPool" :
113
+ genericPool = & v1alpha1.InClusterIPPool {
114
+ ObjectMeta : metav1.ObjectMeta {GenerateName : testPool , Namespace : namespace },
115
+ Spec : poolSpec ,
116
+ }
117
+ case "GlobalInClusterIPPool" :
118
+ genericPool = & v1alpha1.GlobalInClusterIPPool {
119
+ ObjectMeta : metav1.ObjectMeta {GenerateName : testPool , Namespace : namespace },
120
+ Spec : poolSpec ,
121
+ }
122
+ default :
123
+ Fail ("Unknown pool type" )
124
+ }
125
+
126
+ Expect (k8sClient .Create (context .Background (), genericPool )).To (Succeed ())
127
+
128
+ for i := 0 ; i < numClaims ; i ++ {
129
+ claim := ipamv1.IPAddressClaim {
130
+ ObjectMeta : metav1.ObjectMeta {
131
+ Name : fmt .Sprintf ("test%d" , i ),
132
+ Namespace : namespace ,
133
+ },
134
+ Spec : ipamv1.IPAddressClaimSpec {
135
+ PoolRef : corev1.TypedLocalObjectReference {
136
+ APIGroup : pointer .String ("ipam.cluster.x-k8s.io" ),
137
+ Kind : poolType ,
138
+ Name : genericPool .GetName (),
139
+ },
140
+ },
141
+ }
142
+ Expect (k8sClient .Create (context .Background (), & claim )).To (Succeed ())
143
+ createdClaimNames = append (createdClaimNames , claim .Name )
144
+ }
145
+
146
+ Eventually (Object (genericPool )).
147
+ WithTimeout (5 * time .Second ).WithPolling (100 * time .Millisecond ).Should (
148
+ HaveField ("Status.Addresses.Used" , Equal (numClaims )))
149
+
150
+ genericPool .PoolSpec ().Addresses = updatedAddresses
151
+ Expect (k8sClient .Update (context .Background (), genericPool )).To (Succeed ())
152
+
153
+ Eventually (Object (genericPool )).
154
+ WithTimeout (5 * time .Second ).WithPolling (100 * time .Millisecond ).Should (
155
+ HaveField ("Status.Addresses.OutOfRange" , Equal (expectedOutOfRange )))
156
+ },
157
+
158
+ Entry ("InClusterIPPool" ,
159
+ "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 ),
160
+ Entry ("GlobalInClusterIPPool" ,
161
+ "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 ),
162
+ )
102
163
})
103
164
104
165
Context ("when the pool has IPAddresses" , func () {
0 commit comments