mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +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:
commit
53492f79df
@ -76,6 +76,10 @@ const (
|
|||||||
updateMaxRetries = 10
|
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
|
// CIDRAllocator is an interface implemented by things that know how
|
||||||
// to allocate/occupy/recycle CIDR for nodes.
|
// to allocate/occupy/recycle CIDR for nodes.
|
||||||
type CIDRAllocator interface {
|
type CIDRAllocator interface {
|
||||||
@ -123,7 +127,7 @@ func listNodes(kubeClient clientset.Interface) (*v1.NodeList, error) {
|
|||||||
var nodeList *v1.NodeList
|
var nodeList *v1.NodeList
|
||||||
// We must poll because apiserver might not be up. This error causes
|
// We must poll because apiserver might not be up. This error causes
|
||||||
// controller manager to restart.
|
// 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
|
var err error
|
||||||
nodeList, err = kubeClient.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{
|
nodeList, err = kubeClient.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{
|
||||||
FieldSelector: fields.Everything().String(),
|
FieldSelector: fields.Everything().String(),
|
||||||
|
@ -32,9 +32,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/controller/testutil"
|
"k8s.io/kubernetes/pkg/controller/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const testNodePollInterval = 10 * time.Millisecond
|
||||||
nodePollInterval = 100 * time.Millisecond
|
|
||||||
)
|
|
||||||
|
|
||||||
var alwaysReady = func() bool { return true }
|
var alwaysReady = func() bool { return true }
|
||||||
|
|
||||||
@ -320,6 +318,13 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllocateOrOccupyCIDRSuccess(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
|
// all tests operate on a single node
|
||||||
testCases := []testCase{
|
testCases := []testCase{
|
||||||
{
|
{
|
||||||
@ -700,6 +705,13 @@ type releaseTestCase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReleaseCIDRSuccess(t *testing.T) {
|
func TestReleaseCIDRSuccess(t *testing.T) {
|
||||||
|
// Non-parallel test (overrides global var)
|
||||||
|
oldNodePollInterval := nodePollInterval
|
||||||
|
nodePollInterval = testNodePollInterval
|
||||||
|
defer func() {
|
||||||
|
nodePollInterval = oldNodePollInterval
|
||||||
|
}()
|
||||||
|
|
||||||
testCases := []releaseTestCase{
|
testCases := []releaseTestCase{
|
||||||
{
|
{
|
||||||
description: "Correctly release preallocated CIDR",
|
description: "Correctly release preallocated CIDR",
|
||||||
|
Loading…
Reference in New Issue
Block a user