Add polarion test case ids regarding PDB test cases
Add tests for checking pod disruption budget exists into functional
tests. Refactor component check out of pod eviction to save time.
@@ -45,9 +45,6 @@ const (
var _ = Describe("KubeVirt control plane resilience", func() {
- var nodeNames []string
- var selectedNodeName string
-
RegisterFailHandler(Fail)
virtCli, err := kubecli.GetKubevirtClient()
@@ -56,6 +53,11 @@ var _ = Describe("KubeVirt control plane resilience", func() {
controlPlaneDeploymentNames := []string{"virt-api", "virt-controller"}
+ Context("pod eviction", func() {
+
+ var nodeNames []string
+ var selectedNodeName string
+
tests.FlagParse()
getRunningReadyPods := func(podList *v1.PodList, podNames []string, nodeNames ...string) (pods []*v1.Pod) {
@@ -260,7 +262,7 @@ var _ = Describe("KubeVirt control plane resilience", func() {
eventuallyWithTimeout(waitForDeploymentsToStabilize)
})
- When("evicting pods of control plane, last eviction should fail", func() {
+ When("[ref_id:2717]evicting pods of control plane", func() {
test := func(podName string) {
By(fmt.Sprintf("Try to evict all pods %s from node %s\n", podName, selectedNodeName))
@@ -276,8 +278,57 @@ var _ = Describe("KubeVirt control plane resilience", func() {
Expect(err).To(HaveOccurred(), "no error occurred on evict of last pod")
}
- It("for virt-controller pods", func() { test("virt-controller") })
- It("for virt-api pods", func() { test("virt-api") })
+ It("[test_id:2830]last eviction should fail for virt-controller pods", func() { test("virt-controller") })
+ It("[test_id:2799]last eviction should fail for virt-api pods", func() { test("virt-api") })
+
+ })
+
+ })
+
+ Context("control plane components check", func() {
+
+ When("[ref_id:2717]control plane pods are running", func() {
+
+ It("[test_id:2806]virt-controller and virt-api pods have a pod disruption budget", func() {
+
+ By("check deployments")
+ deployments, err := deploymentsClient.List(metav1.ListOptions{})
+ Expect(err).ToNot(HaveOccurred())
+ expectedDeployments := []string{"cdi-http-import-server", "virt-operator", "virt-api", "virt-controller"}
+ for _, expectedDeployment := range expectedDeployments {
+ found := false
+ for _, deployment := range deployments.Items {
+ if deployment.Name != expectedDeployment {
+ continue
+ }
+ found = true
+ break
+ }
+ if !found {
+ Fail(fmt.Sprintf("deployment %s not found", expectedDeployment))
+ }
+ }
+
+ By("check pod disruption budgets exist")
+ podDisruptionBudgetList, err := virtCli.PolicyV1beta1().PodDisruptionBudgets(tests.KubeVirtInstallNamespace).List(metav1.ListOptions{})
+ Expect(err).ToNot(HaveOccurred())
+ for _, controlPlaneDeploymentName := range controlPlaneDeploymentNames {
+ pdbName := controlPlaneDeploymentName + "-pdb"
+ found := false
+ for _, pdb := range podDisruptionBudgetList.Items {
+ if pdb.Name != pdbName {
+ continue
+ }
+ found = true
+ break
+ }
+ if !found {
+ Fail(fmt.Sprintf("pod disruption budget %s not found for control plane pod %s", pdbName, controlPlaneDeploymentName))
+ }
+ }
+ })
+
+ })
})
