1 /* 2 Copyright 2019 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 deployment 18 19 import ( 20 "time" 21 22 appsv1 "k8s.io/api/apps/v1" 23 clientset "k8s.io/client-go/kubernetes" 24 "k8s.io/kubernetes/test/e2e/framework" 25 testutils "k8s.io/kubernetes/test/utils" 26 ) 27 28 const ( 29 // poll is how often to poll pods, nodes and claims. 30 poll = 2 * time.Second 31 pollShortTimeout = 1 * time.Minute 32 pollLongTimeout = 5 * time.Minute 33 ) 34 35 // WaitForDeploymentRevisionAndImage waits for the deployment's and its new RS's revision and container image to match the given revision and image. 36 // Note that deployment revision and its new RS revision should be updated shortly most of the time, but an overwhelmed RS controller 37 // may result in taking longer to relabel a RS. 38 func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName string, revision, image string) error { 39 return testutils.WaitForDeploymentRevisionAndImage(c, ns, deploymentName, revision, image, framework.Logf, poll, pollLongTimeout) 40 } 41 42 // WaitForDeploymentComplete waits for the deployment to complete, and don't check if rolling update strategy is broken. 43 // Rolling update strategy is used only during a rolling update, and can be violated in other situations, 44 // such as shortly after a scaling event or the deployment is just created. 45 func WaitForDeploymentComplete(c clientset.Interface, d *appsv1.Deployment) error { 46 return testutils.WaitForDeploymentComplete(c, d, framework.Logf, poll, pollLongTimeout) 47 } 48