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.
cleanup in tests/expose_test#waitForJobToCompleteWithStatus
Signed-off-by: Arik Hadas <[email protected]>
- Loading branch information
Showing
1 changed file
with
13 additions
and
19 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 |
---|---|---|
|
@@ -35,18 +35,12 @@ func newLabeledVMI(label string, virtClient kubecli.KubevirtClient, createVMI bo | |
return | ||
} | ||
|
||
func waitForJobToCompleteWithStatus(virtClient *kubecli.KubevirtClient, jobPod *k8sv1.Pod, expectedResult string, timeoutSec int) { | ||
jobPodPhase := k8sv1.PodFailed | ||
|
||
if expectedResult == "success" { | ||
jobPodPhase = k8sv1.PodSucceeded | ||
} | ||
|
||
func waitForJobToCompleteWithStatus(virtClient *kubecli.KubevirtClient, jobPod *k8sv1.Pod, expectedResult k8sv1.PodPhase, timeoutSec time.Duration) { | ||
EventuallyWithOffset(1, func() k8sv1.PodPhase { | ||
pod, err := (*virtClient).CoreV1().Pods(jobPod.Namespace).Get(jobPod.Name, k8smetav1.GetOptions{}) | ||
ExpectWithOffset(1, err).ToNot(HaveOccurred()) | ||
return pod.Status.Phase | ||
}, time.Duration(timeoutSec)*time.Second, 1*time.Second).Should(Equal(jobPodPhase)) | ||
}, timeoutSec*time.Second, 1*time.Second).Should(Equal(expectedResult)) | ||
} | ||
|
||
var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:component]Expose", func() { | ||
|
@@ -86,7 +80,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
}) | ||
}) | ||
|
||
|
@@ -176,7 +170,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
} | ||
}) | ||
}) | ||
|
@@ -213,7 +207,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
}) | ||
}) | ||
|
||
|
@@ -255,7 +249,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
} | ||
}) | ||
}) | ||
|
@@ -317,7 +311,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
}) | ||
}) | ||
}) | ||
|
@@ -381,15 +375,15 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
|
||
By("Starting a pod which tries to reach the VMI again via the same ClusterIP, this time over HTTP.") | ||
job = tests.NewHelloWorldJobHttp(serviceIP, servicePort) | ||
job, err = virtClient.CoreV1().Pods(vm.Namespace).Create(job) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the HTTP job pod to report a successful connection attempt.") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
}) | ||
|
||
It("[test_id:345]Should verify the exposed service is functional before and after VM restart.", func() { | ||
|
@@ -406,7 +400,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt.") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
|
||
// Retrieve the current VMI UID, to be compared with the new UID after restart. | ||
var vmi *v1.VirtualMachineInstance | ||
|
@@ -441,7 +435,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt.") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
}) | ||
|
||
It("[test_id:343]Should Verify an exposed service of a VM is not functional after VM deletion.", func() { | ||
|
@@ -456,7 +450,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a successful connection attempt") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "success", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodSucceeded, 120) | ||
|
||
By("Comparing the service's endpoints IP address to the VM pod IP address.") | ||
// Get the IP address of the VM pod. | ||
|
@@ -494,7 +488,7 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting for the pod to report a failed connection attempt.") | ||
waitForJobToCompleteWithStatus(&virtClient, job, "failure", 120) | ||
waitForJobToCompleteWithStatus(&virtClient, job, k8sv1.PodFailed, 120) | ||
}) | ||
}) | ||
}) | ||
|