k8s.io/kubernetes@v1.29.3/test/e2e/framework/timeouts.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package framework
    18  
    19  import "time"
    20  
    21  var defaultTimeouts = TimeoutContext{
    22  	Poll:                      2 * time.Second, // from the former e2e/framework/pod poll interval
    23  	PodStart:                  5 * time.Minute,
    24  	PodStartShort:             2 * time.Minute,
    25  	PodStartSlow:              15 * time.Minute,
    26  	PodDelete:                 5 * time.Minute,
    27  	ClaimProvision:            5 * time.Minute,
    28  	ClaimProvisionShort:       1 * time.Minute,
    29  	DataSourceProvision:       5 * time.Minute,
    30  	ClaimBound:                3 * time.Minute,
    31  	PVReclaim:                 3 * time.Minute,
    32  	PVBound:                   3 * time.Minute,
    33  	PVCreate:                  3 * time.Minute,
    34  	PVDelete:                  5 * time.Minute,
    35  	PVDeleteSlow:              20 * time.Minute,
    36  	SnapshotCreate:            5 * time.Minute,
    37  	SnapshotDelete:            5 * time.Minute,
    38  	SnapshotControllerMetrics: 5 * time.Minute,
    39  	SystemPodsStartup:         10 * time.Minute,
    40  	NodeSchedulable:           30 * time.Minute,
    41  	SystemDaemonsetStartup:    5 * time.Minute,
    42  	NodeNotReady:              3 * time.Minute,
    43  }
    44  
    45  // TimeoutContext contains timeout settings for several actions.
    46  type TimeoutContext struct {
    47  	// Poll is how long to wait between API calls when waiting for some condition.
    48  	Poll time.Duration
    49  
    50  	// PodStart is how long to wait for the pod to be started.
    51  	// This value is the default for gomega.Eventually.
    52  	PodStart time.Duration
    53  
    54  	// PodStartShort is same as `PodStart`, but shorter.
    55  	// Use it in a case-by-case basis, mostly when you are sure pod start will not be delayed.
    56  	// This value is the default for gomega.Consistently.
    57  	PodStartShort time.Duration
    58  
    59  	// PodStartSlow is same as `PodStart`, but longer.
    60  	// Use it in a case-by-case basis, mostly when you are sure pod start will take longer than usual.
    61  	PodStartSlow time.Duration
    62  
    63  	// PodDelete is how long to wait for the pod to be deleted.
    64  	PodDelete time.Duration
    65  
    66  	// ClaimProvision is how long claims have to become dynamically provisioned.
    67  	ClaimProvision time.Duration
    68  
    69  	// DataSourceProvision is how long claims have to become dynamically provisioned from source claim.
    70  	DataSourceProvision time.Duration
    71  
    72  	// ClaimProvisionShort is the same as `ClaimProvision`, but shorter.
    73  	ClaimProvisionShort time.Duration
    74  
    75  	// ClaimBound is how long claims have to become bound.
    76  	ClaimBound time.Duration
    77  
    78  	// PVReclaim is how long PVs have to become reclaimed.
    79  	PVReclaim time.Duration
    80  
    81  	// PVBound is how long PVs have to become bound.
    82  	PVBound time.Duration
    83  
    84  	// PVCreate is how long PVs have to be created.
    85  	PVCreate time.Duration
    86  
    87  	// PVDelete is how long PVs have to become deleted.
    88  	PVDelete time.Duration
    89  
    90  	// PVDeleteSlow is the same as PVDelete, but slower.
    91  	PVDeleteSlow time.Duration
    92  
    93  	// SnapshotCreate is how long for snapshot to create snapshotContent.
    94  	SnapshotCreate time.Duration
    95  
    96  	// SnapshotDelete is how long for snapshot to delete snapshotContent.
    97  	SnapshotDelete time.Duration
    98  
    99  	// SnapshotControllerMetrics is how long to wait for snapshot controller metrics.
   100  	SnapshotControllerMetrics time.Duration
   101  
   102  	// SystemPodsStartup is how long to wait for system pods to be running.
   103  	SystemPodsStartup time.Duration
   104  
   105  	// NodeSchedulable is how long to wait for all nodes to be schedulable.
   106  	NodeSchedulable time.Duration
   107  
   108  	// SystemDaemonsetStartup is how long to wait for all system daemonsets to be ready.
   109  	SystemDaemonsetStartup time.Duration
   110  
   111  	// NodeNotReady is how long to wait for a node to be not ready.
   112  	NodeNotReady time.Duration
   113  }
   114  
   115  // NewTimeoutContext returns a TimeoutContext with all values set either to
   116  // hard-coded defaults or a value that was configured when running the E2E
   117  // suite. Should be called after command line parsing.
   118  func NewTimeoutContext() *TimeoutContext {
   119  	// Make a copy, otherwise the caller would have the ability to modify
   120  	// the original values.
   121  	copy := TestContext.timeouts
   122  	return &copy
   123  }
   124  
   125  // PollInterval defines how long to wait between API server queries while
   126  // waiting for some condition.
   127  //
   128  // This value is the default for gomega.Eventually and gomega.Consistently.
   129  func PollInterval() time.Duration {
   130  	return TestContext.timeouts.Poll
   131  }