diff --git a/pkg/controller/nodeipam/ipam/cidr_allocator.go b/pkg/controller/nodeipam/ipam/cidr_allocator.go index 0e34c094857..6261672bd61 100644 --- a/pkg/controller/nodeipam/ipam/cidr_allocator.go +++ b/pkg/controller/nodeipam/ipam/cidr_allocator.go @@ -75,11 +75,11 @@ const ( // updateMaxRetries is the max retries for a failed node updateMaxRetries = 10 - - // nodePollInterval is used in listing node - nodePollInterval = 10 * time.Second ) +// nodePollInterval is used in listing node +var nodePollInterval = 10 * time.Second + // CIDRAllocator is an interface implemented by things that know how // to allocate/occupy/recycle CIDR for nodes. type CIDRAllocator interface { diff --git a/pkg/controller/nodeipam/ipam/range_allocator_test.go b/pkg/controller/nodeipam/ipam/range_allocator_test.go index c83567033a7..a5d59483875 100644 --- a/pkg/controller/nodeipam/ipam/range_allocator_test.go +++ b/pkg/controller/nodeipam/ipam/range_allocator_test.go @@ -292,6 +292,13 @@ func TestOccupyPreExistingCIDR(t *testing.T) { } func TestAllocateOrOccupyCIDRSuccess(t *testing.T) { + // Non-parallel test (overrides global var) + oldNodePollInterval := nodePollInterval + nodePollInterval = test.NodePollInterval + defer func() { + nodePollInterval = oldNodePollInterval + }() + // all tests operate on a single node testCases := []testCase{ { @@ -673,6 +680,13 @@ type releaseTestCase struct { } func TestReleaseCIDRSuccess(t *testing.T) { + // Non-parallel test (overrides global var) + oldNodePollInterval := nodePollInterval + nodePollInterval = test.NodePollInterval + defer func() { + nodePollInterval = oldNodePollInterval + }() + testCases := []releaseTestCase{ { description: "Correctly release preallocated CIDR",