Skip to content

Commit 0410a90

Browse files
author
Roman Sysoev
committed
test(e2e): add vm version test using new framework
Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
1 parent c372fd0 commit 0410a90

2 files changed

Lines changed: 82 additions & 114 deletions

File tree

test/e2e/legacy/vm_version.go

Lines changed: 0 additions & 114 deletions
This file was deleted.

test/e2e/vm/version.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Copyright 2026 Flant JSC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package vm
18+
19+
import (
20+
"context"
21+
22+
. "github.com/onsi/ginkgo/v2"
23+
. "github.com/onsi/gomega"
24+
25+
"k8s.io/apimachinery/pkg/api/resource"
26+
"k8s.io/utils/ptr"
27+
crclient "sigs.k8s.io/controller-runtime/pkg/client"
28+
29+
vdbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vd"
30+
vmbuilder "github.com/deckhouse/virtualization-controller/pkg/builder/vm"
31+
"github.com/deckhouse/virtualization/api/core/v1alpha2"
32+
"github.com/deckhouse/virtualization/test/e2e/internal/framework"
33+
"github.com/deckhouse/virtualization/test/e2e/internal/object"
34+
"github.com/deckhouse/virtualization/test/e2e/internal/util"
35+
)
36+
37+
var _ = Describe("VirtualMachineVersions", func() {
38+
var f *framework.Framework
39+
40+
BeforeEach(func() {
41+
f = framework.NewFramework("vm-versions")
42+
DeferCleanup(f.After)
43+
f.Before()
44+
})
45+
46+
It("should expose qemu and libvirt versions in VM status", func() {
47+
By("Creating VirtualDisk from precreated ClusterVirtualImage")
48+
vdRoot := object.NewVDFromCVI("vd-root", f.Namespace().Name, object.PrecreatedCVIAlpineUEFI,
49+
vdbuilder.WithSize(ptr.To(resource.MustParse("512Mi"))),
50+
)
51+
52+
By("Creating VirtualMachine")
53+
vm := object.NewMinimalVM("vm-", f.Namespace().Name,
54+
vmbuilder.WithBootloader(v1alpha2.EFI),
55+
vmbuilder.WithCPU(1, ptr.To("50%")),
56+
vmbuilder.WithMemory(resource.MustParse("256Mi")),
57+
vmbuilder.WithRestartApprovalMode(v1alpha2.Manual),
58+
vmbuilder.WithBlockDeviceRefs(
59+
v1alpha2.BlockDeviceSpecRef{
60+
Kind: v1alpha2.DiskDevice,
61+
Name: vdRoot.Name,
62+
},
63+
),
64+
)
65+
66+
By("Creating resources")
67+
err := f.CreateWithDeferredDeletion(context.Background(), vdRoot, vm)
68+
Expect(err).NotTo(HaveOccurred())
69+
70+
By("Waiting for VirtualMachine to be Running")
71+
util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.LongTimeout, vm)
72+
73+
By("Checking VM status has qemu and libvirt versions")
74+
Eventually(func(g Gomega) {
75+
err := f.GenericClient().Get(context.Background(), crclient.ObjectKeyFromObject(vm), vm)
76+
g.Expect(err).NotTo(HaveOccurred())
77+
g.Expect(vm.Status.Versions).NotTo(BeNil())
78+
g.Expect(vm.Status.Versions.Qemu).NotTo(BeEmpty())
79+
g.Expect(vm.Status.Versions.Libvirt).NotTo(BeEmpty())
80+
}).WithTimeout(framework.LongTimeout).WithPolling(framework.PollingInterval).Should(Succeed())
81+
})
82+
})

0 commit comments

Comments
 (0)