From ade9afb08e034ccaa2230797abca3ac2c2dd132e Mon Sep 17 00:00:00 2001 From: Barak Mordehai Date: Thu, 4 Nov 2021 10:39:47 +0200 Subject: [PATCH] verifing that the pid is numeric instead of checking the exit code. The test run 'ps -x' from virtluncher in order to extract libvirtd pid and for unclear reasons sometimes 'ps -x' generate the expected output with exit code 1. Instead of checking the exit code i modifed the test to check if the pid extracted is in the right format and printed all the information needed in case of an error. Signed-off-by: Barak Mordehai --- tests/migration_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/migration_test.go b/tests/migration_test.go index db901c87a56c..b614ad30998a 100644 --- a/tests/migration_test.go +++ b/tests/migration_test.go @@ -318,12 +318,12 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:cnv-qe@redhat.com][leve } getLibvirtdPid := func(pod *k8sv1.Pod) string { - stdout, stderr, err := tests.ExecuteCommandOnPodV2(virtClient, pod, "compute", + stdout, stderr, errPsCmd := tests.ExecuteCommandOnPodV2(virtClient, pod, "compute", []string{ "ps", "-x", }) - Expect(err).ToNot(HaveOccurred(), `"ps -x" failed with stdout="`+stdout+`" and stderr="`+stderr+`"`) + 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") { @@ -336,14 +336,14 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:cnv-qe@redhat.com][leve // verify it is numeric _, err = strconv.Atoi(words[0]) - Expect(err).ToNot(HaveOccurred(), "should have found pid for libvirtd that is numeric") - + 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)) - Expect(pid).ToNot(Equal(""), "libvirtd pid not found") return pid } @@ -711,6 +711,7 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:cnv-qe@redhat.com][leve tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 240) }) + It("[test_id:6972]should migrate to a persistent (non-transient) libvirt domain.", func() { vmi := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskCirros)) tests.AddUserData(vmi, "cloud-init", "#!/bin/bash\necho 'hello'\n")