From 27e2e32b0083b573557770fb42b893584ffa0dc6 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Mon, 16 Apr 2018 16:32:48 +0800 Subject: [PATCH] Use shorter timeout if possible. - Add PodStartShortTimeout and ClaimProvisionShortTimeout constants. - Change framework.PodStartTimeout to framework.PodStartShortTimeout in persistent_volumes-local.go. Busybox image is very small, no need to wait for a long time. --- test/e2e/framework/pv_util.go | 4 ++-- test/e2e/framework/util.go | 9 +++++++++ test/e2e/storage/persistent_volumes-local.go | 7 +++---- test/e2e/storage/volume_provisioning.go | 14 ++++++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/test/e2e/framework/pv_util.go b/test/e2e/framework/pv_util.go index c636dd11dd5..82a9d83aee5 100644 --- a/test/e2e/framework/pv_util.go +++ b/test/e2e/framework/pv_util.go @@ -1000,14 +1000,14 @@ func CreateNginxPod(client clientset.Interface, namespace string, nodeSelector m } // create security pod with given claims -func CreateSecPod(client clientset.Interface, namespace string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string, hostIPC bool, hostPID bool, seLinuxLabel *v1.SELinuxOptions, fsGroup *int64) (*v1.Pod, error) { +func CreateSecPod(client clientset.Interface, namespace string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string, hostIPC bool, hostPID bool, seLinuxLabel *v1.SELinuxOptions, fsGroup *int64, timeout time.Duration) (*v1.Pod, error) { pod := MakeSecPod(namespace, pvclaims, isPrivileged, command, hostIPC, hostPID, seLinuxLabel, fsGroup) pod, err := client.CoreV1().Pods(namespace).Create(pod) if err != nil { return nil, fmt.Errorf("pod Create API error: %v", err) } // Waiting for pod to be running - err = WaitForPodNameRunningInNamespace(client, pod.Name, namespace) + err = WaitTimeoutForPodRunningInNamespace(client, pod.Name, namespace, timeout) if err != nil { return pod, fmt.Errorf("pod %q is not Running: %v", pod.Name, err) } diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 45b0e716913..6bc58864890 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -113,6 +113,11 @@ const ( // TODO: Make this 30 seconds once #4566 is resolved. PodStartTimeout = 5 * time.Minute + // Same as `PodStartTimeout` to wait for the pod to be started, but shorter. + // Use it case by case when we are sure pod start will not be delayed + // minutes by slow docker pulls or something else. + PodStartShortTimeout = 1 * time.Minute + // If there are any orphaned namespaces to clean up, this test is running // on a long lived cluster. A long wait here is preferably to spurious test // failures caused by leaked resources from a previous test run. @@ -156,6 +161,10 @@ const ( // How long claims have to become dynamically provisioned ClaimProvisionTimeout = 5 * time.Minute + // Same as `ClaimProvisionTimeout` to wait for claim to be dynamically provisioned, but shorter. + // Use it case by case when we are sure this timeout is enough. + ClaimProvisionShortTimeout = 1 * time.Minute + // How long claims have to become bound ClaimBindingTimeout = 3 * time.Minute diff --git a/test/e2e/storage/persistent_volumes-local.go b/test/e2e/storage/persistent_volumes-local.go index 612fe7f5bdf..f49a6fa7f3d 100644 --- a/test/e2e/storage/persistent_volumes-local.go +++ b/test/e2e/storage/persistent_volumes-local.go @@ -328,7 +328,6 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { Context("Local volume that cannot be mounted [Slow]", func() { // TODO: - // - make the pod create timeout shorter // - check for these errors in unit tests intead It("should fail due to non-existent path", func() { ep := &eventPatterns{ @@ -368,7 +367,7 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { pod, err := config.client.CoreV1().Pods(config.ns).Create(pod) Expect(err).NotTo(HaveOccurred()) - err = framework.WaitForPodNameRunningInNamespace(config.client, pod.Name, pod.Namespace) + err = framework.WaitTimeoutForPodRunningInNamespace(config.client, pod.Name, pod.Namespace, framework.PodStartShortTimeout) Expect(err).To(HaveOccurred()) checkPodEvents(config, pod.Name, ep) @@ -1113,7 +1112,7 @@ func makeLocalPodWithNodeName(config *localTestConfig, volume *localTestVolume, // createSecPod should be used when Pod requires non default SELinux labels func createSecPod(config *localTestConfig, volume *localTestVolume, hostIPC bool, hostPID bool, seLinuxLabel *v1.SELinuxOptions) (*v1.Pod, error) { - pod, err := framework.CreateSecPod(config.client, config.ns, []*v1.PersistentVolumeClaim{volume.pvc}, false, "", hostIPC, hostPID, seLinuxLabel, nil) + pod, err := framework.CreateSecPod(config.client, config.ns, []*v1.PersistentVolumeClaim{volume.pvc}, false, "", hostIPC, hostPID, seLinuxLabel, nil, framework.PodStartShortTimeout) podNodeName, podNodeNameErr := podNodeName(config, pod) Expect(podNodeNameErr).NotTo(HaveOccurred()) framework.Logf("Security Context POD %q created on Node %q", pod.Name, podNodeName) @@ -1123,7 +1122,7 @@ func createSecPod(config *localTestConfig, volume *localTestVolume, hostIPC bool func createLocalPod(config *localTestConfig, volume *localTestVolume, fsGroup *int64) (*v1.Pod, error) { By("Creating a pod") - return framework.CreateSecPod(config.client, config.ns, []*v1.PersistentVolumeClaim{volume.pvc}, false, "", false, false, selinuxLabel, fsGroup) + return framework.CreateSecPod(config.client, config.ns, []*v1.PersistentVolumeClaim{volume.pvc}, false, "", false, false, selinuxLabel, fsGroup, framework.PodStartShortTimeout) } func createAndMountTmpfsLocalVolume(config *localTestConfig, dir string, node *v1.Node) { diff --git a/test/e2e/storage/volume_provisioning.go b/test/e2e/storage/volume_provisioning.go index 17111d696e2..f7a68bc6c84 100644 --- a/test/e2e/storage/volume_provisioning.go +++ b/test/e2e/storage/volume_provisioning.go @@ -483,9 +483,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { testDynamicProvisioning(test, c, claim, class) }) - // NOTE: Slow! The test will wait up to 5 minutes (framework.ClaimProvisionTimeout) - // when there is no regression. - It("should not provision a volume in an unmanaged GCE zone. [Slow]", func() { + It("should not provision a volume in an unmanaged GCE zone.", func() { framework.SkipUnlessProviderIs("gce", "gke") var suffix string = "unmananged" @@ -538,7 +536,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { }() // The claim should timeout phase:Pending - err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, pvc.Name, 2*time.Second, framework.ClaimProvisionTimeout) + err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, pvc.Name, 2*time.Second, framework.ClaimProvisionShortTimeout) Expect(err).To(HaveOccurred()) framework.Logf(err.Error()) }) @@ -722,7 +720,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { }) // Modifying the default storage class can be disruptive to other tests that depend on it - It("should be disabled by changing the default annotation[Slow] [Serial] [Disruptive]", func() { + It("should be disabled by changing the default annotation [Serial] [Disruptive]", func() { framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke", "vsphere", "azure") scName := getDefaultStorageClassName(c) test := storageClassTest{ @@ -744,7 +742,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { }() // The claim should timeout phase:Pending - err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, claim.Name, 2*time.Second, framework.ClaimProvisionTimeout) + err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, claim.Name, 2*time.Second, framework.ClaimProvisionShortTimeout) Expect(err).To(HaveOccurred()) framework.Logf(err.Error()) claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{}) @@ -753,7 +751,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { }) // Modifying the default storage class can be disruptive to other tests that depend on it - It("should be disabled by removing the default annotation[Slow] [Serial] [Disruptive]", func() { + It("should be disabled by removing the default annotation [Serial] [Disruptive]", func() { framework.SkipUnlessProviderIs("openstack", "gce", "aws", "gke", "vsphere", "azure") scName := getDefaultStorageClassName(c) test := storageClassTest{ @@ -775,7 +773,7 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { }() // The claim should timeout phase:Pending - err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, claim.Name, 2*time.Second, framework.ClaimProvisionTimeout) + err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, c, ns, claim.Name, 2*time.Second, framework.ClaimProvisionShortTimeout) Expect(err).To(HaveOccurred()) framework.Logf(err.Error()) claim, err = c.CoreV1().PersistentVolumeClaims(ns).Get(claim.Name, metav1.GetOptions{})