mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-26 08:10:20 +00:00
e2e: add listPods()
listPods returns slice of pods matching given ListOptions and namespace. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
parent
e6a0049c0b
commit
915437b314
19
e2e/pod.go
19
e2e/pod.go
@ -107,19 +107,15 @@ func waitForDeploymentComplete(name, ns string, c kubernetes.Interface, t int) e
|
|||||||
|
|
||||||
func getCommandInPodOpts(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (framework.ExecOptions, error) {
|
func getCommandInPodOpts(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (framework.ExecOptions, error) {
|
||||||
cmd := []string{"/bin/sh", "-c", c}
|
cmd := []string{"/bin/sh", "-c", c}
|
||||||
podList, err := f.PodClientNS(ns).List(context.TODO(), *opt)
|
pods, err := listPods(f, ns, opt)
|
||||||
framework.ExpectNoError(err)
|
|
||||||
if len(podList.Items) == 0 {
|
|
||||||
return framework.ExecOptions{}, errors.New("podlist is empty")
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return framework.ExecOptions{}, err
|
return framework.ExecOptions{}, err
|
||||||
}
|
}
|
||||||
return framework.ExecOptions{
|
return framework.ExecOptions{
|
||||||
Command: cmd,
|
Command: cmd,
|
||||||
PodName: podList.Items[0].Name,
|
PodName: pods[0].Name,
|
||||||
Namespace: ns,
|
Namespace: ns,
|
||||||
ContainerName: podList.Items[0].Spec.Containers[0].Name,
|
ContainerName: pods[0].Spec.Containers[0].Name,
|
||||||
Stdin: nil,
|
Stdin: nil,
|
||||||
CaptureStdout: true,
|
CaptureStdout: true,
|
||||||
CaptureStderr: true,
|
CaptureStderr: true,
|
||||||
@ -127,6 +123,15 @@ func getCommandInPodOpts(f *framework.Framework, c, ns string, opt *metav1.ListO
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// listPods returns slice of pods matching given ListOptions and namespace.
|
||||||
|
func listPods(f *framework.Framework, ns string, opt *metav1.ListOptions) ([]v1.Pod, error) {
|
||||||
|
podList, err := f.PodClientNS(ns).List(context.TODO(), *opt)
|
||||||
|
if len(podList.Items) == 0 {
|
||||||
|
return podList.Items, fmt.Errorf("podlist for label '%s' in namespace %s is empty", opt.LabelSelector, ns)
|
||||||
|
}
|
||||||
|
return podList.Items, err
|
||||||
|
}
|
||||||
|
|
||||||
func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string, error) {
|
func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string, error) {
|
||||||
podOpt, err := getCommandInPodOpts(f, c, ns, opt)
|
podOpt, err := getCommandInPodOpts(f, c, ns, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user