Skip to content

Commit

Permalink
fix hardcoded node names - issue kubevirt#2048
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqalayan committed Mar 3, 2019
1 parent 6f1f653 commit 5b9e049
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ func CreateHostPathPvWithSize(osName string, hostPath string, size string) {
hostPathType := k8sv1.HostPathDirectoryOrCreate

name := fmt.Sprintf("%s-disk-for-tests", osName)

nodes := GetAllSchedulableNodes(virtCli)
Expect(len(nodes.Items) > 0).To(BeTrue())
nodeName := nodes.Items[0].Name

pv := &k8sv1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down Expand Up @@ -620,7 +625,7 @@ func CreateHostPathPvWithSize(osName string, hostPath string, size string) {
{
Key: "kubernetes.io/hostname",
Operator: k8sv1.NodeSelectorOpIn,
Values: []string{"node01"},
Values: []string{nodeName},
},
},
},
Expand Down Expand Up @@ -1550,6 +1555,12 @@ func newBlockVolumePV(name string, labelSelector map[string]string, size string)
storageClass := StorageClassBlockVolume
volumeMode := k8sv1.PersistentVolumeBlock

virtCli, err := kubecli.GetKubevirtClient()
PanicOnError(err)

nodes := GetAllSchedulableNodes(virtCli)
Expect(len(nodes.Items) > 0).To(BeTrue())
nodeName := nodes.Items[0].Name
// Note: the path depends on kubevirtci!
// It's configured to have a device backed by a cirros image at exactly that place on node01
// And the local storage provider also has access to it
Expand Down Expand Up @@ -1578,7 +1589,7 @@ func newBlockVolumePV(name string, labelSelector map[string]string, size string)
{
Key: "kubernetes.io/hostname",
Operator: k8sv1.NodeSelectorOpIn,
Values: []string{"node01"},
Values: []string{nodeName},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions tests/vmi_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ var _ = Describe("Configurations", func() {
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(cpuVmi)
Expect(err).ToNot(HaveOccurred())
node := tests.WaitForSuccessfulVMIStart(cpuVmi)
// what should i do here it will always pass for us (false positve)
Expect(node).NotTo(ContainSubstring("node01"))

By("Checking that the pod QOS is guaranteed")
Expand Down Expand Up @@ -1234,6 +1235,7 @@ var _ = Describe("Configurations", func() {
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(cpuVmi)
Expect(err).ToNot(HaveOccurred())
node := tests.WaitForSuccessfulVMIStart(cpuVmi)
// what should i do here it will always pass for us (false positve)
Expect(node).NotTo(ContainSubstring("node01"))

By("Expecting the VirtualMachineInstance console")
Expand Down Expand Up @@ -1328,6 +1330,7 @@ var _ = Describe("Configurations", func() {
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(Vmi)
Expect(err).ToNot(HaveOccurred())
node1 := tests.WaitForSuccessfulVMIStart(Vmi)
// what should i do here it will always fail for us
Expect(node1).To(ContainSubstring("node02"))
})
})
Expand Down

0 comments on commit 5b9e049

Please sign in to comment.