Skip to content

Commit

Permalink
Select a schedulable node in local PV test (#1088)
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Rolland <frolland@redhat.com>

Co-authored-by: Fred Rolland <frolland@redhat.com>
  • Loading branch information
2 people authored and awels committed Jan 22, 2020
1 parent b3495b3 commit 0205928
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/local_volume_test.go
Expand Up @@ -33,7 +33,10 @@ var _ = Describe("[rfe_id:1125][crit:high][vendor:cnv-qe@redhat.com][level:compo
BeforeEach(func() {
nodes, err := f.K8sClient.CoreV1().Nodes().List(metav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
node = nodes.Items[0].Name

nodeRef := utils.GetSchedulableNode(nodes)
Expect(nodeRef).ToNot(BeNil())
node = *nodeRef

By("Creating PV with NodeAffinity and Binding label")
pv, err = f.CreatePVFromDefinition(utils.NewPVDefinition("local-volume", "1G", storageClassName, node, map[string]string{"node": node}))
Expand Down
20 changes: 20 additions & 0 deletions tests/utils/pod.go
Expand Up @@ -235,3 +235,23 @@ func isExpectedNode(clientSet *kubernetes.Clientset, nodeName, podName, namespac
return false, nil
}
}

// GetSchedulableNode return a schedulable node from a nodes list
func GetSchedulableNode(nodes *v1.NodeList) *string {
for _, node := range nodes.Items {
if node.Spec.Taints == nil {
return &node.Name
}
schedulableNode := true
for _, taint := range node.Spec.Taints {
if taint.Effect == "NoSchedule" {
schedulableNode = false
break
}
}
if schedulableNode {
return &node.Name
}
}
return nil
}

0 comments on commit 0205928

Please sign in to comment.