Skip to content

Commit 334cde5

Browse files
committed
Add LookForStringInPodExecToContainer that takes container name parameter, modify LookForStringInPodExec to call the new function.
1 parent 18f8c14 commit 334cde5

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

test/e2e/framework/util.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,15 @@ func RandomSuffix() string {
503503
}
504504

505505
// LookForStringInPodExec looks for the given string in the output of a command
506-
// executed in specified pod container, or the first container if not specified.
506+
// executed in the first container of specified pod.
507507
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
508-
func LookForStringInPodExec(ns, podName, containerName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
508+
func LookForStringInPodExec(ns, podName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
509+
return LookForStringInPodExecToContainer(ns, podName, "", command, expectedString, timeout)
510+
}
511+
512+
// LookForStringInPodExecToContainer looks for the given string in the output of a
513+
// command executed in specified pod container, or first container if not specified.
514+
func LookForStringInPodExecToContainer(ns, podName, containerName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
509515
return lookForString(expectedString, timeout, func() string {
510516
args := []string{"exec", podName, fmt.Sprintf("--namespace=%v", ns)}
511517
if len(containerName) > 0 {

test/e2e/framework/volume/fixtures.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy
458458
// Block: check content
459459
deviceName := fmt.Sprintf("/opt/%d", i)
460460
commands := generateReadBlockCmd(deviceName, len(test.ExpectedContent))
461-
_, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, "", commands, test.ExpectedContent, time.Minute)
461+
_, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, commands, test.ExpectedContent, time.Minute)
462462
framework.ExpectNoError(err, "failed: finding the contents of the block device %s.", deviceName)
463463

464464
// Check that it's a real block device
@@ -467,7 +467,7 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy
467467
// Filesystem: check content
468468
fileName := fmt.Sprintf("/opt/%d/%s", i, test.File)
469469
commands := generateReadFileCmd(fileName)
470-
_, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, "", commands, test.ExpectedContent, time.Minute)
470+
_, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, commands, test.ExpectedContent, time.Minute)
471471
framework.ExpectNoError(err, "failed: finding the contents of the mounted file %s.", fileName)
472472

473473
// Check that a directory has been mounted
@@ -478,14 +478,14 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy
478478
// Filesystem: check fsgroup
479479
if fsGroup != nil {
480480
ginkgo.By("Checking fsGroup is correct.")
481-
_, err = framework.LookForStringInPodExec(pod.Namespace, pod.Name, "", []string{"ls", "-ld", dirName}, strconv.Itoa(int(*fsGroup)), time.Minute)
481+
_, err = framework.LookForStringInPodExec(pod.Namespace, pod.Name, []string{"ls", "-ld", dirName}, strconv.Itoa(int(*fsGroup)), time.Minute)
482482
framework.ExpectNoError(err, "failed: getting the right privileges in the file %v", int(*fsGroup))
483483
}
484484

485485
// Filesystem: check fsType
486486
if fsType != "" {
487487
ginkgo.By("Checking fsType is correct.")
488-
_, err = framework.LookForStringInPodExec(pod.Namespace, pod.Name, "", []string{"grep", " " + dirName + " ", "/proc/mounts"}, fsType, time.Minute)
488+
_, err = framework.LookForStringInPodExec(pod.Namespace, pod.Name, []string{"grep", " " + dirName + " ", "/proc/mounts"}, fsType, time.Minute)
489489
framework.ExpectNoError(err, "failed: getting the right fsType %s", fsType)
490490
}
491491
}

test/e2e/network/example_cluster_dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var _ = SIGDescribe("ClusterDns [Feature:Example]", func() {
140140
podName := pods.Items[0].Name
141141

142142
queryDNS := fmt.Sprintf(queryDNSPythonTemplate, backendSvcName+"."+namespaces[0].Name)
143-
_, err = framework.LookForStringInPodExec(namespaces[0].Name, podName, "", []string{"python", "-c", queryDNS}, "ok", dnsReadyTimeout)
143+
_, err = framework.LookForStringInPodExec(namespaces[0].Name, podName, []string{"python", "-c", queryDNS}, "ok", dnsReadyTimeout)
144144
framework.ExpectNoError(err, "waiting for output from pod exec")
145145

146146
updatedPodYaml := prepareResourceWithReplacedString(frontendPodYaml, fmt.Sprintf("dns-backend.development.svc.%s", framework.TestContext.ClusterDNSDomain), fmt.Sprintf("dns-backend.%s.svc.%s", namespaces[0].Name, framework.TestContext.ClusterDNSDomain))

test/e2e/storage/persistent_volumes-local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ func twoPodsReadWriteSerialTest(f *framework.Framework, config *localTestConfig,
791791
func createPodWithFsGroupTest(config *localTestConfig, testVol *localTestVolume, fsGroup int64, expectedFsGroup int64) *v1.Pod {
792792
pod, err := createLocalPod(config, testVol, &fsGroup)
793793
framework.ExpectNoError(err)
794-
_, err = framework.LookForStringInPodExec(config.ns, pod.Name, "", []string{"stat", "-c", "%g", volumeDir}, strconv.FormatInt(expectedFsGroup, 10), time.Second*3)
794+
_, err = framework.LookForStringInPodExec(config.ns, pod.Name, []string{"stat", "-c", "%g", volumeDir}, strconv.FormatInt(expectedFsGroup, 10), time.Second*3)
795795
framework.ExpectNoError(err, "failed to get expected fsGroup %d on directory %s in pod %s", fsGroup, volumeDir, pod.Name)
796796
return pod
797797
}

test/e2e/storage/vsphere/vsphere_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func verifyVSphereVolumesAccessible(c clientset.Interface, pod *v1.Pod, persiste
381381
framework.ExpectEqual(isAttached, true, fmt.Sprintf("disk %v is not attached with the node", pv.Spec.VsphereVolume.VolumePath))
382382
// Verify Volumes are accessible
383383
filepath := filepath.Join("/mnt/", fmt.Sprintf("volume%v", index+1), "/emptyFile.txt")
384-
_, err = framework.LookForStringInPodExec(namespace, pod.Name, "", []string{"/bin/touch", filepath}, "", time.Minute)
384+
_, err = framework.LookForStringInPodExec(namespace, pod.Name, []string{"/bin/touch", filepath}, "", time.Minute)
385385
framework.ExpectNoError(err)
386386
}
387387
}

test/e2e/storage/vsphere/vsphere_volume_fstype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func invokeTestForFstype(f *framework.Framework, client clientset.Interface, nam
107107

108108
// Create Pod and verify the persistent volume is accessible
109109
pod := createPodAndVerifyVolumeAccessible(client, namespace, pvclaim, persistentvolumes)
110-
_, err := framework.LookForStringInPodExec(namespace, pod.Name, "", []string{"/bin/cat", "/mnt/volume1/fstype"}, expectedContent, time.Minute)
110+
_, err := framework.LookForStringInPodExec(namespace, pod.Name, []string{"/bin/cat", "/mnt/volume1/fstype"}, expectedContent, time.Minute)
111111
framework.ExpectNoError(err)
112112

113113
// Detach and delete volume

0 commit comments

Comments
 (0)