Skip to content

Commit

Permalink
Updating functional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vishesh Tanksale <[email protected]>
  • Loading branch information
visheshtanksale committed Sep 12, 2019
1 parent 6eb546b commit deab3b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 4 additions & 2 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ elif [[ $TARGET =~ multus.* ]]; then
elif [[ $TARGET =~ genie.* ]]; then
ginko_params="$ginko_params --ginkgo.focus=Genie|Networking|VMIlifecycle|Expose"
elif [[ $TARGET =~ sriov.* ]]; then
ginko_params="$ginko_params --ginkgo.focus=SRIOV"
ginko_params="$ginko_params --ginkgo.focus=SRIOV"
elif [[ $TARGET =~ gpu.* ]]; then
ginko_params="$ginko_params --ginkgo.focus=GPU"
else
ginko_params="$ginko_params --ginkgo.skip=Multus|Genie|SRIOV"
ginko_params="$ginko_params --ginkgo.skip=Multus|Genie|SRIOV|GPU"
fi

# Prepare RHEL PV for Template testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,6 @@ var _ = Describe("Validating VMICreate Admitter", func() {
},
}

//disableFeatureGates()

causes := ValidateVirtualMachineInstanceSpec(k8sfield.NewPath("fake"), &vmi.Spec, config)
Expect(len(causes)).To(Equal(1))
Expect(causes[0].Field).To(Equal("fake.gpus"))
Expand Down
7 changes: 0 additions & 7 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2725,13 +2725,6 @@ func SkipIfNotUseNetworkPolicy(virtClient kubecli.KubevirtClient) {
}
}

func SkipIfNoGpuDevicePlugin(virtClient kubecli.KubevirtClient) {
_, err := virtClient.ExtensionsV1beta1().DaemonSets("kube-system").Get("nvidia-kubevirt-gpu-dp-daemonset", metav1.GetOptions{})
if err != nil {
Skip("Skipping tests which need GPU")
}
}

func GetK8sCmdClient() string {
// use oc if it exists, otherwise use kubectl
if KubeVirtOcPath != "" {
Expand Down
24 changes: 18 additions & 6 deletions tests/vmi_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/xml"
"strings"

expect "github.com/google/goexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
k8sv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -33,18 +34,27 @@ func parseDeviceAddress(addrString string) []string {
return addrs
}

var _ = Describe("GPU VirtualMachineInstance", func() {
func checkGPUDevice(vmi *v1.VirtualMachineInstance, gpuName, prompt string) {
cmdCheck := "lspci"
err := tests.CheckForTextExpecter(vmi, []expect.Batcher{
&expect.BSnd{S: "\n"},
&expect.BExp{R: prompt},
&expect.BSnd{S: cmdCheck},
&expect.BExp{R: prompt},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: "0"},
}, 15)
Expect(err).ToNot(HaveOccurred(), "Interface %q was not found in the VMI %s within the given timeout", gpuName, vmi.Name)
}

var _ = Describe("GPU", func() {
tests.FlagParse()

virtClient, err := kubecli.GetKubevirtClient()
tests.PanicOnError(err)

tests.BeforeAll(func() {
tests.SkipIfNoGpuDevicePlugin(virtClient)
})

Context("with ephemeral disk", func() {
It("Should create a valid VMI but pod should not got to running state", func() {
It("Should create a valid VMI but pod should not go to running state", func() {
gpuName := "random.com/gpu"
randomVMI := tests.NewRandomVMIWithEphemeralDisk(tests.ContainerDiskFor(tests.ContainerDiskCirros))
gpus := []v1.Gpu{
Expand Down Expand Up @@ -117,6 +127,8 @@ var _ = Describe("GPU VirtualMachineInstance", func() {
Expect(domSpec.Devices.HostDevices[n].Source.Address.Slot).To(Equal("0x" + dbsfFields[2]))
Expect(domSpec.Devices.HostDevices[n].Source.Address.Function).To(Equal("0x" + dbsfFields[3]))
}

checkGPUDevice(randomVMI, "*10de*", "$")
})
})
})

0 comments on commit deab3b6

Please sign in to comment.