mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #98756 from pacoxu/ut/faster
networking nodeipam UT: set node poll interval to 1s in UT
This commit is contained in:
		@@ -76,6 +76,10 @@ const (
 | 
			
		||||
	updateMaxRetries = 10
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// nodePollInterval is used in listing node
 | 
			
		||||
// This is a variable instead of a const to enable testing.
 | 
			
		||||
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 {
 | 
			
		||||
@@ -123,7 +127,7 @@ func listNodes(kubeClient clientset.Interface) (*v1.NodeList, error) {
 | 
			
		||||
	var nodeList *v1.NodeList
 | 
			
		||||
	// We must poll because apiserver might not be up. This error causes
 | 
			
		||||
	// controller manager to restart.
 | 
			
		||||
	if pollErr := wait.Poll(10*time.Second, apiserverStartupGracePeriod, func() (bool, error) {
 | 
			
		||||
	if pollErr := wait.Poll(nodePollInterval, apiserverStartupGracePeriod, func() (bool, error) {
 | 
			
		||||
		var err error
 | 
			
		||||
		nodeList, err = kubeClient.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{
 | 
			
		||||
			FieldSelector: fields.Everything().String(),
 | 
			
		||||
 
 | 
			
		||||
@@ -32,9 +32,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller/testutil"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	nodePollInterval = 100 * time.Millisecond
 | 
			
		||||
)
 | 
			
		||||
const testNodePollInterval = 10 * time.Millisecond
 | 
			
		||||
 | 
			
		||||
var alwaysReady = func() bool { return true }
 | 
			
		||||
 | 
			
		||||
@@ -320,6 +318,13 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
 | 
			
		||||
	// Non-parallel test (overrides global var)
 | 
			
		||||
	oldNodePollInterval := nodePollInterval
 | 
			
		||||
	nodePollInterval = testNodePollInterval
 | 
			
		||||
	defer func() {
 | 
			
		||||
		nodePollInterval = oldNodePollInterval
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	// all tests operate on a single node
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
@@ -700,6 +705,13 @@ type releaseTestCase struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestReleaseCIDRSuccess(t *testing.T) {
 | 
			
		||||
	// Non-parallel test (overrides global var)
 | 
			
		||||
	oldNodePollInterval := nodePollInterval
 | 
			
		||||
	nodePollInterval = testNodePollInterval
 | 
			
		||||
	defer func() {
 | 
			
		||||
		nodePollInterval = oldNodePollInterval
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	testCases := []releaseTestCase{
 | 
			
		||||
		{
 | 
			
		||||
			description: "Correctly release preallocated CIDR",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user