forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmi_controller_test.go
50 lines (41 loc) · 1.35 KB
/
vmi_controller_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package tests_test
import (
"encoding/xml"
"kubevirt.io/kubevirt/tests/decorators"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"kubevirt.io/client-go/kubecli"
"kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api"
"kubevirt.io/kubevirt/tests"
"kubevirt.io/kubevirt/tests/framework/kubevirt"
"kubevirt.io/kubevirt/tests/libvmi"
)
var _ = Describe("[sig-compute]Controller devices", decorators.SigCompute, func() {
var virtClient kubecli.KubevirtClient
BeforeEach(func() {
virtClient = kubevirt.Client()
})
Context("with ephemeral disk", func() {
DescribeTable("a scsi controller", func(enabled bool) {
vmi := libvmi.NewCirros()
vmi.Spec.Domain.Devices.DisableHotplug = !enabled
vmi = tests.RunVMIAndExpectLaunch(vmi, 30)
domain, err := tests.GetRunningVirtualMachineInstanceDomainXML(virtClient, vmi)
Expect(err).ToNot(HaveOccurred())
domSpec := &api.DomainSpec{}
Expect(xml.Unmarshal([]byte(domain), domSpec)).To(Succeed())
found := false
for _, controller := range domSpec.Devices.Controllers {
if controller.Type == "scsi" {
found = true
Expect(controller.Index).To(Equal("0"))
Expect(controller.Model).To(Equal("virtio-non-transitional"))
}
}
Expect(found).To(Equal(enabled))
},
Entry("should appear if enabled", true),
Entry("should NOT appear if disabled", false),
)
})
})