@@ -17,6 +17,7 @@ limitations under the License.
1717package e2e
1818
1919import (
20+ "context"
2021 "errors"
2122 "fmt"
2223 "strings"
@@ -28,9 +29,11 @@ import (
2829 . "github.com/onsi/gomega"
2930 storagev1 "k8s.io/api/storage/v1"
3031 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32+ "k8s.io/utils/ptr"
3133
3234 sdsrepvolv1 "github.com/deckhouse/sds-replicated-volume/api/v1alpha1"
3335
36+ "github.com/deckhouse/virtualization-controller/pkg/controller/conditions"
3437 virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2"
3538 "github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition"
3639 "github.com/deckhouse/virtualization/tests/e2e/config"
@@ -384,8 +387,47 @@ var _ = Describe("Virtual disk snapshots", ginkgoutil.CommonE2ETestDecorators(),
384387
385388 Context (fmt .Sprintf ("When virtual machines in %s phase" , PhaseRunning ), func () {
386389 It ("creates snapshots with `requiredConsistency` of attached VDs" , func () {
390+ vms , err := virtClient .VirtualMachines (conf .Namespace ).List (context .Background (), v1.ListOptions {})
391+ Expect (err ).NotTo (HaveOccurred ())
392+ vmsFrozenDict := make (map [string ]bool )
393+
394+ for _ , vm := range vms .Items {
395+ frozenCondition , _ := conditions .GetCondition (vmcondition .TypeFilesystemFrozen , vm .Status .Conditions )
396+ vmsFrozenDict [vm .Name ] = frozenCondition .Status == v1 .ConditionTrue
397+ }
398+
399+ watcher , err := virtClient .VirtualMachines (conf .Namespace ).Watch (context .Background (), v1.ListOptions {TimeoutSeconds : ptr .To (int64 (filesystemReadyTimeout .Seconds ()))})
400+ Expect (err ).NotTo (HaveOccurred ())
401+ var hasFrozen bool
402+ for {
403+ hasFrozen = false
404+ for _ , frozen := range vmsFrozenDict {
405+ hasFrozen = hasFrozen || frozen
406+ }
407+
408+ if ! hasFrozen {
409+ watcher .Stop ()
410+ break
411+ }
412+
413+ event , ok := <- watcher .ResultChan ()
414+ if ! ok {
415+ break
416+ }
417+
418+ vm , ok := event .Object .(* virtv2.VirtualMachine )
419+ if ! ok {
420+ continue
421+ }
422+
423+ frozenCondition , _ := conditions .GetCondition (vmcondition .TypeFilesystemFrozen , vm .Status .Conditions )
424+ vmsFrozenDict [vm .Name ] = frozenCondition .Status == v1 .ConditionTrue
425+ }
426+ // TODO: It is a known issue that VM filesystems after snapshot not unfreezing. To prevent this error from causing noise during testing, we disabled this check. It will need to be re-enabled once this issue is fixed.
427+ // Expect(hasFrozen).To(BeFalse())
428+
387429 vmObjects := virtv2.VirtualMachineList {}
388- err : = GetObjects (kc .ResourceVM , & vmObjects , kc.GetOptions {Namespace : conf .Namespace })
430+ err = GetObjects (kc .ResourceVM , & vmObjects , kc.GetOptions {Namespace : conf .Namespace })
389431 Expect (err ).NotTo (HaveOccurred (), "cannot get virtual machines\n stderr: %s" , err )
390432
391433 for _ , vm := range vmObjects .Items {
0 commit comments