Skip to content

Commit 65ac6a8

Browse files
authored
add test to purge pendingDelete IPs in ipampoolmonitor (#1467)
Signed-off-by: Evan Baker <[email protected]>
1 parent 07b39c9 commit 65ac6a8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cns/ipampool/monitor_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,27 @@ func TestPoolIncreaseBatchSizeGreaterThanMaxPodIPCount(t *testing.T) {
215215
assert.Equal(t, initState.max, poolmonitor.spec.RequestedIPCount)
216216
}
217217

218+
func TestIncreaseWithPendingRelease(t *testing.T) {
219+
initState := testState{
220+
batch: 16,
221+
assigned: 16,
222+
allocated: 32,
223+
requestThresholdPercent: 50,
224+
releaseThresholdPercent: 150,
225+
max: 250,
226+
pendingRelease: 16,
227+
}
228+
_, rc, mon := initFakes(initState)
229+
assert.NoError(t, rc.Reconcile(true))
230+
assert.NoError(t, mon.reconcile(context.Background()))
231+
assert.Equal(t, int64(32), mon.spec.RequestedIPCount)
232+
assert.Len(t, mon.spec.IPsNotInUse, 16)
233+
assert.NoError(t, rc.Reconcile(true))
234+
assert.NoError(t, mon.reconcile(context.Background()))
235+
assert.Equal(t, int64(32), mon.spec.RequestedIPCount)
236+
assert.Empty(t, mon.spec.IPsNotInUse)
237+
}
238+
218239
func TestPoolDecrease(t *testing.T) {
219240
initState := testState{
220241
batch: 10,

0 commit comments

Comments
 (0)