Skip to content

Commit

Permalink
Create a function to check wffc possible phases
Browse files Browse the repository at this point in the history
Signed-off-by: Shelly Kagan <[email protected]>
  • Loading branch information
ShellyKa13 committed Mar 17, 2024
1 parent 54fd12d commit 19ede44
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
4 changes: 4 additions & 0 deletions tests/framework/matcher/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func PendingPopulation() types.GomegaMatcher {
}
}

func WaitForFirstConsumer() types.GomegaMatcher {
return Or(BeInPhase("WaitForFirstConsumer"), PendingPopulation())
}

func BeInPhase(phase interface{}) types.GomegaMatcher {
return phaseMatcher{
expectedPhase: phase,
Expand Down
4 changes: 2 additions & 2 deletions tests/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ var _ = SIGMigrationDescribe("VM Live Migration", func() {

dv, err = virtClient.CdiClient().CdiV1beta1().DataVolumes(testsuite.GetTestNamespace(dv)).Create(context.Background(), dv, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
libstorage.EventuallyDV(dv, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer), BeInPhase(cdiv1.PendingPopulation)))
libstorage.EventuallyDV(dv, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))
vmi := libvmi.New(
libvmi.WithInterface(libvmi.InterfaceDeviceWithMasqueradeBinding()),
libvmi.WithNetwork(v1.DefaultPodNetwork()),
Expand Down Expand Up @@ -1082,7 +1082,7 @@ var _ = SIGMigrationDescribe("VM Live Migration", func() {
dataVolume, err = virtClient.CdiClient().CdiV1beta1().DataVolumes(testsuite.GetTestNamespace(nil)).Create(context.Background(), dataVolume, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))

vmi = tests.RunVMIAndExpectLaunch(vmi, 240)

Expand Down
4 changes: 2 additions & 2 deletions tests/storage/datavolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ var _ = SIGDescribe("DataVolume Integration", func() {

// This will only work on storage with binding mode WaitForFirstConsumer,
if libstorage.IsStorageClassBindingModeWaitForFirstConsumer(libstorage.Config.StorageRWOFileSystem) {
Eventually(ThisDV(dataVolume), 40).Should(Or(BeInPhase(cdiv1.WaitForFirstConsumer), BeInPhase(cdiv1.PendingPopulation)))
Eventually(ThisDV(dataVolume), 40).Should(WaitForFirstConsumer())
}
num := 2
By("Starting and stopping the VirtualMachineInstance a number of times")
Expand Down Expand Up @@ -349,7 +349,7 @@ var _ = SIGDescribe("DataVolume Integration", func() {
Expect(err).ToNot(HaveOccurred())
// This will only work on storage with binding mode WaitForFirstConsumer,
if libstorage.IsStorageClassBindingModeWaitForFirstConsumer(libstorage.Config.StorageRWOFileSystem) {
Eventually(ThisDV(dataVolume), 40).Should(Or(BeInPhase(cdiv1.WaitForFirstConsumer), BeInPhase(cdiv1.PendingPopulation)))
Eventually(ThisDV(dataVolume), 40).Should(WaitForFirstConsumer())
}
// with WFFC the run actually starts the import and then runs VM, so the timeout has to include both
// import and start
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ var _ = SIGDescribe("Storage", func() {
Skip("Skip test when Block storage is not present")
}

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), PendingPopulation(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))
})

AfterEach(func() {
Expand Down Expand Up @@ -1072,7 +1072,7 @@ var _ = SIGDescribe("Storage", func() {
Skip("Skip test when Block storage is not present")
}

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), PendingPopulation(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))
vmi = nil
})

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func NewRandomVirtualMachineInstanceWithDisk(imageUrl, namespace, sc string, acc
var err error
dv, err = virtCli.CdiClient().CdiV1beta1().DataVolumes(namespace).Create(context.Background(), dv, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
libstorage.EventuallyDV(dv, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer), BeInPhase(cdiv1.PendingPopulation)))
libstorage.EventuallyDV(dv, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))
return libvmi.New(
libvmi.WithInterface(libvmi.InterfaceDeviceWithMasqueradeBinding()),
libvmi.WithNetwork(v1.DefaultPodNetwork()),
Expand Down
1 change: 0 additions & 1 deletion tests/virtiofs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ go_library(
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1:go_default_library",
],
)
3 changes: 1 addition & 2 deletions tests/virtiofs/datavolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
v1 "kubevirt.io/api/core/v1"
virtv1 "kubevirt.io/api/core/v1"
"kubevirt.io/client-go/kubecli"
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"

virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
"kubevirt.io/kubevirt/tests"
Expand Down Expand Up @@ -313,7 +312,7 @@ var _ = Describe("[sig-storage] virtiofs", decorators.SigStorage, func() {
Expect(err).ToNot(HaveOccurred())
By("Waiting until the DataVolume is ready")
if libstorage.IsStorageClassBindingModeWaitForFirstConsumer(libstorage.Config.StorageRWOFileSystem) {
Eventually(ThisDV(dataVolume), 30).Should(Or(BeInPhase(cdiv1.WaitForFirstConsumer), BeInPhase(cdiv1.PendingPopulation)))
Eventually(ThisDV(dataVolume), 30).Should(WaitForFirstConsumer())
}

virtiofsMountPath := fmt.Sprintf("/mnt/virtiofs_%s", dataVolume.Name)
Expand Down
6 changes: 3 additions & 3 deletions tests/vmi_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,7 @@ var _ = Describe("[sig-compute]Configurations", decorators.SigCompute, func() {
Skip("Skip test when Block storage is not present")
}

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))
})

AfterEach(func() {
Expand Down Expand Up @@ -2279,7 +2279,7 @@ var _ = Describe("[sig-compute]Configurations", decorators.SigCompute, func() {
Skip("Skip test when Block storage is not present")
}

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))

vmi := libvmi.New(
libvmi.WithInterface(libvmi.InterfaceDeviceWithMasqueradeBinding()),
Expand Down Expand Up @@ -2322,7 +2322,7 @@ var _ = Describe("[sig-compute]Configurations", decorators.SigCompute, func() {
Skip("Skip test when Block storage is not present")
}

libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), BeInPhase(cdiv1.WaitForFirstConsumer)))
libstorage.EventuallyDV(dataVolume, 240, Or(HaveSucceeded(), WaitForFirstConsumer()))

vmi := libvmi.New(
libvmi.WithInterface(libvmi.InterfaceDeviceWithMasqueradeBinding()),
Expand Down

0 comments on commit 19ede44

Please sign in to comment.