Skip to content

Commit

Permalink
node_placement e2e test: make sure all virt-hanlers are working
Browse files Browse the repository at this point in the history
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa committed Aug 15, 2024
1 parent d6d5036 commit 36a06e0
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions tests/func-tests/node_placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,30 @@ var _ = Describe("[rfe_id:4356][crit:medium][vendor:[email protected]][level:sys
originalWorkloadSpec hcov1beta1.HyperConvergedConfig
cli client.Client
cliSet *kubernetes.Clientset
workerNodes *v1.NodeList
)

BeforeAll(func(ctx context.Context) {
cli = tests.GetControllerRuntimeClient()
cliSet = tests.GetK8sClientSet()

nodes := listNodesByLabels(ctx, cliSet, "node-role.kubernetes.io/control-plane!=")
tests.FailIfSingleNode(len(nodes.Items) < 2)
workerNodes = listNodesByLabels(ctx, cliSet, "node-role.kubernetes.io/worker")
//workerNodes = listNodesByLabels(ctx, cliSet, "node-role.kubernetes.io/control-plane!=")
tests.FailIfSingleNode(len(workerNodes.Items) < 2)

// Label all but first node with "node.kubernetes.io/hco-test-node-type=infra"
// We are doing this to remove dependency of this Describe block on a shell script that
// labels the nodes this way
Eventually(func(g Gomega, ctx context.Context) {
for _, node := range nodes.Items[:len(nodes.Items)-1] {
for _, node := range workerNodes.Items[:len(workerNodes.Items)-1] {
done, err := setHcoNodeTypeLabel(ctx, cliSet, &node, infra)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(done).To(BeTrue())
}
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).WithContext(ctx).Should(Succeed())
// Label the last node with "node.kubernetes.io/hco-test-node-type=workloads"
Eventually(func(g Gomega, ctx context.Context) {
done, err := setHcoNodeTypeLabel(ctx, cliSet, &nodes.Items[len(nodes.Items)-1], workloads)
done, err := setHcoNodeTypeLabel(ctx, cliSet, &workerNodes.Items[len(workerNodes.Items)-1], workloads)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(done).To(BeTrue())
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).WithContext(ctx).Should(Succeed())
Expand Down Expand Up @@ -85,7 +87,8 @@ var _ = Describe("[rfe_id:4356][crit:medium][vendor:[email protected]][level:sys

tests.UpdateHCORetry(ctx, cli, hco)

workloadsNodes := listNodesByLabels(ctx, cliSet, "node.kubernetes.io/hco-test-node-type==workloads")
const hcoSelector = hcoLabel + "==workloads"
workloadsNodes := listNodesByLabels(ctx, cliSet, hcoSelector)
Expect(workloadsNodes.Items).To(HaveLen(1))

workloadsNode = &workloadsNodes.Items[0]
Expand Down Expand Up @@ -121,6 +124,26 @@ var _ = Describe("[rfe_id:4356][crit:medium][vendor:[email protected]][level:sys
g.Expect(err).ToNot(HaveOccurred())
}
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).WithContext(ctx).Should(Succeed())

Eventually(func(g Gomega, ctx context.Context) {
labelSelector := "kubevirt.io=virt-handler"
pods, err := cliSet.CoreV1().Pods(tests.InstallNamespace).List(ctx, k8smetav1.ListOptions{LabelSelector: labelSelector})
g.Expect(err).ToNot(HaveOccurred())
g.Expect(pods.Items).To(HaveLen(len(workerNodes.Items)))

for _, pod := range pods.Items {
podReady := false
for _, cond := range pod.Status.Conditions {
if cond.Type == v1.PodReady {
g.Expect(cond.Status).To(Equal(v1.ConditionTrue))
podReady = true
break
}
}

g.Expect(podReady).To(BeTrue())
}
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).WithContext(ctx).Should(Succeed())
})

BeforeEach(func(ctx context.Context) {
Expand Down

0 comments on commit 36a06e0

Please sign in to comment.