mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
set node poll interval to 10ms in UT
Signed-off-by: pacoxu <paco.xu@daocloud.io>
This commit is contained in:
parent
074a517720
commit
cef6e81fb3
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user