mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
Update framework imports and its functions.
Signed-off-by: Cedric Hauber <hauber.c@gmail.com>
This commit is contained in:
parent
7c96c5c567
commit
2d0ed298e3
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
27
e2e/utils.go
27
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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user