forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vmi_ignition_test: use libvmi and RunVMIAndExpectLaunch
Make the test shorter and clearer by using libvmi to define a VM and by reusing RunVMIAndExpectLaunch instead of reimplementing it. Signed-off-by: Dan Kenigsberg <[email protected]>
- Loading branch information
1 parent
7ae6751
commit 1c08b84
Showing
1 changed file
with
4 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,60 +20,35 @@ | |
package tests_test | ||
|
||
import ( | ||
"context" | ||
|
||
expect "github.com/google/goexpect" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"kubevirt.io/kubevirt/tests/framework/checks" | ||
"kubevirt.io/kubevirt/tests/util" | ||
|
||
v1 "kubevirt.io/api/core/v1" | ||
"kubevirt.io/client-go/kubecli" | ||
|
||
"kubevirt.io/kubevirt/tests" | ||
"kubevirt.io/kubevirt/tests/console" | ||
cd "kubevirt.io/kubevirt/tests/containerdisk" | ||
"kubevirt.io/kubevirt/tests/libvmi" | ||
) | ||
|
||
var _ = Describe("[rfe_id:151][crit:high][vendor:[email protected]][level:component][sig-compute]IgnitionData", func() { | ||
|
||
var err error | ||
var virtClient kubecli.KubevirtClient | ||
|
||
var LaunchVMI func(*v1.VirtualMachineInstance) | ||
|
||
BeforeEach(func() { | ||
virtClient, err = kubecli.GetKubevirtClient() | ||
util.PanicOnError(err) | ||
|
||
if !checks.HasFeature("ExperimentalIgnitionSupport") { | ||
Skip("ExperimentalIgnitionSupport feature gate is not enabled in kubevirt-config") | ||
} | ||
}) | ||
|
||
LaunchVMI = func(vmi *v1.VirtualMachineInstance) { | ||
By("Starting a VirtualMachineInstance") | ||
obj, err := virtClient.RestClient().Post().Resource("virtualmachineinstances").Namespace(util.NamespaceTestDefault).Body(vmi).Do(context.Background()).Get() | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Waiting the VirtualMachineInstance start") | ||
_, ok := obj.(*v1.VirtualMachineInstance) | ||
Expect(ok).To(BeTrue(), "Object is not of type *v1.VirtualMachineInstance") | ||
Expect(tests.WaitForSuccessfulVMIStart(obj).Status.NodeName).ToNot(BeEmpty()) | ||
} | ||
|
||
Describe("[rfe_id:151][crit:medium][vendor:[email protected]][level:component]A new VirtualMachineInstance", func() { | ||
Context("with IgnitionData annotation", func() { | ||
Context("with injected data", func() { | ||
It("[test_id:1616]should have injected data under firmware directory", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskHighMemory(cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling)) | ||
|
||
ignitionData := "ignition injected" | ||
vmi.Annotations = map[string]string{v1.IgnitionAnnotation: ignitionData} | ||
|
||
LaunchVMI(vmi) | ||
vmi := tests.RunVMIAndExpectLaunch( | ||
libvmi.NewFedora(libvmi.WithAnnotation(v1.IgnitionAnnotation, ignitionData)), | ||
240) | ||
|
||
Expect(console.SafeExpectBatch(vmi, []expect.Batcher{ | ||
&expect.BSnd{S: "\n"}, | ||
|