Skip to content

Commit

Permalink
file check fix
Browse files Browse the repository at this point in the history
Signed-off-by: Dhruv-J <[email protected]>
  • Loading branch information
Dhruv-J committed Jul 13, 2023
1 parent cf0495d commit 420664b
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -1614,11 +1614,8 @@ func (data *TestData) copyNodeFiles(nodeName, fileName, covDir, covPrefix string
fileName = "/var/log/" + covPrefix + "-coverage/" + fileName
cmd := fmt.Sprintf("cat %s", fileName)
fmt.Println("_______________ copyNodeFiles: cat command set")
rc, stdout, stderr, err := data.RunCommandOnNode(nodeName, cmd)
rc, stdout, _, err := data.RunCommandOnNode(nodeName, cmd)
if err != nil || rc != 0 {
if !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("cannot retrieve content of file '%s' from Node '%s', stderr: <%v>, err: <%v>", fileName, controlPlaneNodeName(), stderr, err)
}
fmt.Println("_______________ copyNodeFiles: no such file or directory returned nil")
return nil
}
Expand Down Expand Up @@ -1648,21 +1645,25 @@ func (data *TestData) killProcessesAndCollectCovFiles(namespace, podName, contai
log.Infof("Copying coverage files from worker nodes kind-worker and kind-worker2")
cmd := "/bin/sh -c find / -name 'covmeta.*' -exec basename {} ';'"
rc, stdout, stderr, err := data.RunCommandOnNode("kind-worker", cmd)
var files []string;
if err != nil || rc != 0 {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker, stderr: <%v>, err: <%v>", cmd, stderr, err)
if !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker, stderr: <%v>, err: <%v>", cmd, stderr, err)
}
stdout = strings.TrimSpace(stdout)
files = strings.Split(stdout, "\n")
}
stdout = strings.TrimSpace(stdout)
files := strings.Split(stdout, "\n")
cmd = "/bin/sh -c find / -name 'covcounters.*' -exec basename {} ';'"
rc, stdout, stderr, err = data.RunCommandOnNode("kind-worker", cmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker, stderr: <%v>, err: <%v>", cmd, stderr, err)
if !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker, stderr: <%v>, err: <%v>", cmd, stderr, err)
}
stdout = strings.TrimSpace(stdout)
files = append(files, strings.Split(stdout, "\n")...)
}
stdout = strings.TrimSpace(stdout)
files = append(files, strings.Split(stdout, "\n")...)
fmt.Println("-------- length of kind-worker files: " + fmt.Sprint(len(files)))
for i, file := range files {
fmt.Println("copyNodeFiles iteration " + fmt.Sprint(i))
for _, file := range files {
if len(file) == 0 {
fmt.Println("file " + file + " was empty")
continue
Expand All @@ -1675,20 +1676,23 @@ func (data *TestData) killProcessesAndCollectCovFiles(namespace, podName, contai
cmd = "/bin/sh -c find / -name 'covmeta.*' -exec basename {} ';'"
rc, stdout, stderr, err = data.RunCommandOnNode("kind-worker2", cmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker2, stderr: <%v>, err: <%v>", cmd, stderr, err)
if !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker2, stderr: <%v>, err: <%v>", cmd, stderr, err)
}
stdout = strings.TrimSpace(stdout)
files = strings.Split(stdout, "\n")
}
stdout = strings.TrimSpace(stdout)
files = strings.Split(stdout, "\n")
cmd = "/bin/sh -c find / -name 'covcounters.*' -exec basename {} ';'"
rc, stdout, stderr, err = data.RunCommandOnNode("kind-worker2", cmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker2, stderr: <%v>, err: <%v>", cmd, stderr, err)
if !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("error when running this find command (for coverage file) '%s' on Node kind-worker2, stderr: <%v>, err: <%v>", cmd, stderr, err)
}
stdout = strings.TrimSpace(stdout)
files = append(files, strings.Split(stdout, "\n")...)
}
stdout = strings.TrimSpace(stdout)
files = append(files, strings.Split(stdout, "\n")...)
fmt.Println("-------- length of kind-worker2 files: " + fmt.Sprint(len(files)))
for i, file := range files {
fmt.Println("copyNodeFiles iteration " + fmt.Sprint(i))
for _, file := range files {
if len(file) == 0 {
fmt.Println("file " + file + " was empty")
continue
Expand Down

0 comments on commit 420664b

Please sign in to comment.