diff --git a/e2e/cephfs.go b/e2e/cephfs.go index 51a64053f..29b136514 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -93,7 +93,7 @@ var _ = Describe("cephfs", func() { var err error sts := deployProvAsSTS(f.ClientSet) if sts { - err = framework.WaitForStatefulSetReplicasReady(cephfsDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout) + err = waitForStatefulSetReplicasReady(cephfsDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout) } else { err = waitForDeploymentComplete(cephfsDeploymentName, namespace, f.ClientSet, deployTimeout) } diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 67de17fae..adc2b12a2 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -25,7 +25,7 @@ func init() { setDefaultKubeconfig() // Register framework flags, then handle flags - framework.HandleFlags() + handleFlags() framework.AfterReadingAllFlags(&framework.TestContext) fmt.Println("timeout for deploytimeout ", deployTimeout) diff --git a/e2e/log.go b/e2e/log.go index c16f39f0a..ca4b7961c 100644 --- a/e2e/log.go +++ b/e2e/log.go @@ -20,8 +20,8 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" - "k8s.io/kubernetes/test/e2e/framework" e2elog "k8s.io/kubernetes/test/e2e/framework/log" + frameworkPod "k8s.io/kubernetes/test/e2e/framework/pod" ) func logsCSIPods(label string, c clientset.Interface) { @@ -44,7 +44,7 @@ func logsCSIPods(label string, c clientset.Interface) { func kubectlLogPod(c clientset.Interface, pod *v1.Pod) { container := pod.Spec.Containers for i := range container { - logs, err := framework.GetPodLogs(c, pod.Namespace, pod.Name, container[i].Name) + logs, err := frameworkPod.GetPodLogs(c, pod.Namespace, pod.Name, container[i].Name) if err != nil { logs, err = getPreviousPodLogs(c, pod.Namespace, pod.Name, container[i].Name) if err != nil { diff --git a/e2e/rbd.go b/e2e/rbd.go index cc7de69e1..82079c571 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -103,7 +103,7 @@ var _ = Describe("RBD", func() { var err error sts := deployProvAsSTS(f.ClientSet) if sts { - err = framework.WaitForStatefulSetReplicasReady(rbdDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout) + err = waitForStatefulSetReplicasReady(rbdDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout) } else { err = waitForDeploymentComplete(rbdDeploymentName, namespace, f.ClientSet, deployTimeout) } diff --git a/e2e/utils.go b/e2e/utils.go index 726fe9d5e..94fdf13de 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -28,6 +28,7 @@ import ( "k8s.io/kubernetes/pkg/client/conditions" "k8s.io/kubernetes/test/e2e/framework" e2elog "k8s.io/kubernetes/test/e2e/framework/log" + e2epv "k8s.io/kubernetes/test/e2e/framework/pv" testutils "k8s.io/kubernetes/test/utils" ) @@ -134,6 +135,23 @@ func waitForDeploymentComplete(name, ns string, c clientset.Interface, t int) er return nil } +func waitForStatefulSetReplicasReady(statefulSetName, ns string, c clientset.Interface, Poll, timeout time.Duration) error { + framework.Logf("Waiting up to %v for StatefulSet %s to have all replicas ready", timeout, statefulSetName) + for start := time.Now(); time.Since(start) < timeout; time.Sleep(Poll) { + sts, err := c.AppsV1().StatefulSets(ns).Get(statefulSetName, metav1.GetOptions{}) + if err != nil { + framework.Logf("Get StatefulSet %s failed, ignoring for %v: %v", statefulSetName, Poll, err) + continue + } + if sts.Status.ReadyReplicas == *sts.Spec.Replicas { + framework.Logf("All %d replicas of StatefulSet %s are ready. (%v)", sts.Status.ReadyReplicas, statefulSetName, time.Since(start)) + return nil + } + framework.Logf("StatefulSet %s found but there are %d ready replicas and %d total replicas.", statefulSetName, sts.Status.ReadyReplicas, *sts.Spec.Replicas) + } + return fmt.Errorf("StatefulSet %s still has unready pods within %v", statefulSetName, timeout) +} + func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string) { cmd := []string{"/bin/sh", "-c", c} podList, err := f.PodClientNS(ns).List(*opt) @@ -393,7 +411,7 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai if apierrs.IsNotFound(err) { return false, nil } - err = framework.WaitOnPVandPVC(c, pvc.Namespace, pv, pvc) + err = e2epv.WaitOnPVandPVC(c, pvc.Namespace, pv, pvc) if err != nil { return false, nil } @@ -877,3 +895,10 @@ func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error { err = deletePVCAndApp("", f, pvc, app) return err } + +func handleFlags() { + config.CopyFlags(config.Flags, flag.CommandLine) + framework.RegisterCommonFlags(flag.CommandLine) + framework.RegisterClusterFlags(flag.CommandLine) + flag.Parse() +} \ No newline at end of file