forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replacing the command that extract libvirtd's pid
`ps -x` -> `pidof <LIBVIRTD_PID>` Signed-off-by: Barak Mordehai <[email protected]>
- Loading branch information
Showing
1 changed file
with
9 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,32 +318,14 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve | |
} | ||
|
||
getLibvirtdPid := func(pod *k8sv1.Pod) string { | ||
stdout, stderr, errPsCmd := tests.ExecuteCommandOnPodV2(virtClient, pod, "compute", | ||
stdout, stderr, err := tests.ExecuteCommandOnPodV2(virtClient, pod, "compute", | ||
[]string{ | ||
"ps", | ||
"-x", | ||
"pidof", | ||
"libvirtd", | ||
}) | ||
errorMassageFormat := "faild after running `ps -x` with stdout:\n %v \n stderr:\n %v \n err: \n %v \n extracted pid of libvirtd: `%v` should have been numeric\n" | ||
|
||
pid := "" | ||
for _, str := range strings.Split(stdout, "\n") { | ||
if !strings.Contains(str, "libvirtd") { | ||
continue | ||
} | ||
words := strings.Fields(str) | ||
|
||
Expect(len(words)).To(Equal(7), fmt.Sprintf("Found %s", words)) | ||
|
||
// verify it is numeric | ||
_, err = strconv.Atoi(words[0]) | ||
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf(errorMassageFormat, stdout, stderr, errPsCmd, pid)) | ||
pid = words[0] | ||
|
||
break | ||
|
||
} | ||
Expect(pid).ToNot(BeEmpty(), fmt.Sprintf(errorMassageFormat, stdout, stderr, errPsCmd, pid)) | ||
|
||
errorMassageFormat := "faild after running `pidof libvirtd` with stdout:\n %v \n stderr:\n %v \n err: \n %v \n" | ||
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf(errorMassageFormat, stdout, stderr, err)) | ||
pid := strings.TrimSuffix(stdout, "\n") | ||
return pid | ||
} | ||
|
||
|
@@ -680,13 +662,14 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:[email protected]][leve | |
|
||
// kill libvirtd | ||
By(fmt.Sprintf("Killing libvirtd with pid %s", pid)) | ||
_, _, err = tests.ExecuteCommandOnPodV2(virtClient, &pods.Items[0], "compute", | ||
stdout, stderr, err := tests.ExecuteCommandOnPodV2(virtClient, &pods.Items[0], "compute", | ||
[]string{ | ||
"kill", | ||
"-9", | ||
pid, | ||
}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
errorMassageFormat := "faild after running `kill -9 %v` with stdout:\n %v \n stderr:\n %v \n err: \n %v \n" | ||
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf(errorMassageFormat, pid, stdout, stderr, err)) | ||
|
||
// wait for both libvirt to respawn and all connections to re-establish | ||
time.Sleep(30 * time.Second) | ||
|