@@ -1916,6 +1916,62 @@ var _ = Describe("IPPool manager", func() {
1916
1916
expectedGateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
1917
1917
expectedPrefix : 24 ,
1918
1918
}),
1919
+ Entry ("One pool, with start and existing address, ipAddress label present" , testCaseAllocateAddress {
1920
+ ipPool : & ipamv1.IPPool {
1921
+ Spec : ipamv1.IPPoolSpec {
1922
+ Pools : []ipamv1.Pool {
1923
+ {
1924
+ Start : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.11" )),
1925
+ End : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.20" )),
1926
+ },
1927
+ },
1928
+ Prefix : 24 ,
1929
+ Gateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
1930
+ },
1931
+ },
1932
+ ipClaim : & ipamv1.IPClaim {
1933
+ ObjectMeta : metav1.ObjectMeta {
1934
+ Name : "TestRef" ,
1935
+ Labels : map [string ]string {
1936
+ IpAddressLabel : "192.168.0.16" ,
1937
+ },
1938
+ },
1939
+ },
1940
+ addresses : map [ipamv1.IPAddressStr ]string {
1941
+ ipamv1 .IPAddressStr ("192.168.0.12" ): "bcde" ,
1942
+ ipamv1 .IPAddressStr ("192.168.0.11" ): "abcd" ,
1943
+ },
1944
+ expectedAddress : ipamv1 .IPAddressStr ("192.168.0.16" ),
1945
+ expectedGateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
1946
+ expectedPrefix : 24 ,
1947
+ }),
1948
+ Entry ("One pool, with start and existing address, ipAddress label present but alraedy acquired" , testCaseAllocateAddress {
1949
+ ipPool : & ipamv1.IPPool {
1950
+ Spec : ipamv1.IPPoolSpec {
1951
+ Pools : []ipamv1.Pool {
1952
+ {
1953
+ Start : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.11" )),
1954
+ End : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.20" )),
1955
+ },
1956
+ },
1957
+ Prefix : 24 ,
1958
+ Gateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
1959
+ },
1960
+ },
1961
+ ipClaim : & ipamv1.IPClaim {
1962
+ ObjectMeta : metav1.ObjectMeta {
1963
+ Name : "TestRef" ,
1964
+ Labels : map [string ]string {
1965
+ IpAddressLabel : "192.168.0.11" ,
1966
+ },
1967
+ },
1968
+ },
1969
+ addresses : map [ipamv1.IPAddressStr ]string {
1970
+ ipamv1 .IPAddressStr ("192.168.0.12" ): "bcde" ,
1971
+ ipamv1 .IPAddressStr ("192.168.0.11" ): "abcd" ,
1972
+ },
1973
+ expectError : true ,
1974
+ }),
1919
1975
Entry ("One pool, with subnet and override prefix" , testCaseAllocateAddress {
1920
1976
ipPool : & ipamv1.IPPool {
1921
1977
Spec : ipamv1.IPPoolSpec {
@@ -2230,6 +2286,62 @@ var _ = Describe("IPPool manager", func() {
2230
2286
expectedGateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
2231
2287
expectedPrefix : 24 ,
2232
2288
}),
2289
+ Entry ("One pool, with start and existing address, ipAddress label" , testCapiCaseAllocateAddress {
2290
+ ipPool : & ipamv1.IPPool {
2291
+ Spec : ipamv1.IPPoolSpec {
2292
+ Pools : []ipamv1.Pool {
2293
+ {
2294
+ Start : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.11" )),
2295
+ End : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.20" )),
2296
+ },
2297
+ },
2298
+ Prefix : 24 ,
2299
+ Gateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
2300
+ },
2301
+ },
2302
+ ipAddressClaim : & capipamv1.IPAddressClaim {
2303
+ ObjectMeta : metav1.ObjectMeta {
2304
+ Name : "TestRef" ,
2305
+ Labels : map [string ]string {
2306
+ IpAddressLabel : "192.168.0.16" ,
2307
+ },
2308
+ },
2309
+ },
2310
+ addresses : map [ipamv1.IPAddressStr ]string {
2311
+ ipamv1 .IPAddressStr ("192.168.0.12" ): "bcde" ,
2312
+ ipamv1 .IPAddressStr ("192.168.0.11" ): "abcd" ,
2313
+ },
2314
+ expectedAddress : ipamv1 .IPAddressStr ("192.168.0.16" ),
2315
+ expectedGateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
2316
+ expectedPrefix : 24 ,
2317
+ }),
2318
+ Entry ("One pool, with start and existing address, ipAddress label but alraedy acquired" , testCapiCaseAllocateAddress {
2319
+ ipPool : & ipamv1.IPPool {
2320
+ Spec : ipamv1.IPPoolSpec {
2321
+ Pools : []ipamv1.Pool {
2322
+ {
2323
+ Start : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.11" )),
2324
+ End : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.20" )),
2325
+ },
2326
+ },
2327
+ Prefix : 24 ,
2328
+ Gateway : (* ipamv1 .IPAddressStr )(ptr .To ("192.168.0.1" )),
2329
+ },
2330
+ },
2331
+ ipAddressClaim : & capipamv1.IPAddressClaim {
2332
+ ObjectMeta : metav1.ObjectMeta {
2333
+ Name : "TestRef" ,
2334
+ Labels : map [string ]string {
2335
+ IpAddressLabel : "192.168.0.12" ,
2336
+ },
2337
+ },
2338
+ },
2339
+ addresses : map [ipamv1.IPAddressStr ]string {
2340
+ ipamv1 .IPAddressStr ("192.168.0.12" ): "bcde" ,
2341
+ ipamv1 .IPAddressStr ("192.168.0.11" ): "abcd" ,
2342
+ },
2343
+ expectError : true ,
2344
+ }),
2233
2345
Entry ("One pool, with subnet and override prefix" , testCapiCaseAllocateAddress {
2234
2346
ipPool : & ipamv1.IPPool {
2235
2347
Spec : ipamv1.IPPoolSpec {
0 commit comments