Skip to content

Commit ef3732c

Browse files
committed
test(vminstance): cover VMDisk clones from an image and from a disk
Only source.http had e2e coverage, so a regression in either clone path would ship unnoticed. The suite now clones a VMDisk from a golden image in cozy-public and then clones that disk again, checking that each DataVolume points at the expected PVC and becomes Ready, and that each VMDisk reports WorkloadsReady. vm-default-images is opt-in and the e2e cluster does not enable it, so the suite creates its own small golden image under an e2e name rather than relying on the package. The second clone reuses the first disk, so the Alpine image is the only download. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 9809b22 commit ef3732c

4 files changed

Lines changed: 149 additions & 4 deletions

File tree

‎hack/e2e-chainsaw/vminstance/chainsaw-test.yaml‎

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Chainsaw port of hack/e2e-apps/vminstance.bats. Scenarios: a standalone
2-
# VMDisk, a VMDisk whose import can never finish, and a VMInstance booting from
3-
# its own VMDisk. The first and the last download the Ubuntu noble cloud image,
4-
# so the readiness timeouts are generous. Chainsaw deletes the VMDisk/VMInstance
5-
# CRs it applied at cleanup.
2+
# VMDisk, a VMDisk whose import can never finish, VMDisks cloned from a golden
3+
# image and from another disk, and a VMInstance booting from its own VMDisk. The
4+
# first and the last download the Ubuntu noble cloud image, so the readiness
5+
# timeouts are generous. Chainsaw deletes the CRs it applied at cleanup.
66
apiVersion: chainsaw.kyverno.io/v1alpha1
77
kind: Test
88
metadata:
@@ -92,6 +92,109 @@ spec:
9292
- status: "False"
9393
reason: DataVolumeNotReady
9494
---
95+
# VMDisk clone paths: source.image clones a golden image from cozy-public, and
96+
# source.disk clones that disk in turn, so only the golden image downloads.
97+
apiVersion: chainsaw.kyverno.io/v1alpha1
98+
kind: Test
99+
metadata:
100+
name: vmdisk-clone
101+
spec:
102+
catch:
103+
- events: {}
104+
- events:
105+
namespace: cozy-public
106+
- describe:
107+
apiVersion: cdi.kubevirt.io/v1beta1
108+
kind: DataVolume
109+
- describe:
110+
apiVersion: cdi.kubevirt.io/v1beta1
111+
kind: DataVolume
112+
namespace: cozy-public
113+
name: vm-default-images-e2e-alpine-3.21
114+
- describe:
115+
apiVersion: helm.toolkit.fluxcd.io/v2
116+
kind: HelmRelease
117+
steps:
118+
- name: create-golden-image
119+
try:
120+
- apply:
121+
file: golden-image.yaml
122+
- assert:
123+
timeout: 10m
124+
resource:
125+
apiVersion: cdi.kubevirt.io/v1beta1
126+
kind: DataVolume
127+
metadata:
128+
name: vm-default-images-e2e-alpine-3.21
129+
namespace: cozy-public
130+
status:
131+
(conditions[?type == 'Ready']):
132+
- status: "True"
133+
- name: clone-from-image
134+
try:
135+
- apply:
136+
file: vmdisk-image-clone.yaml
137+
# The vm-disk release goes Ready as soon as the DataVolume exists, so this
138+
# assert is the one that waits for the clone itself.
139+
- assert:
140+
timeout: 10m
141+
resource:
142+
apiVersion: cdi.kubevirt.io/v1beta1
143+
kind: DataVolume
144+
metadata:
145+
name: vm-disk-image-clone
146+
spec:
147+
source:
148+
pvc:
149+
name: vm-default-images-e2e-alpine-3.21
150+
namespace: cozy-public
151+
status:
152+
(conditions[?type == 'Ready']):
153+
- status: "True"
154+
- assert:
155+
timeout: 2m
156+
resource:
157+
apiVersion: apps.cozystack.io/v1alpha1
158+
kind: VMDisk
159+
metadata:
160+
name: image-clone
161+
status:
162+
(conditions[?type == 'Ready']):
163+
- status: "True"
164+
(conditions[?type == 'WorkloadsReady']):
165+
- status: "True"
166+
- name: clone-from-disk
167+
try:
168+
- apply:
169+
file: vmdisk-disk-clone.yaml
170+
- assert:
171+
timeout: 10m
172+
resource:
173+
apiVersion: cdi.kubevirt.io/v1beta1
174+
kind: DataVolume
175+
metadata:
176+
name: vm-disk-disk-clone
177+
spec:
178+
source:
179+
pvc:
180+
name: vm-disk-image-clone
181+
namespace: ($namespace)
182+
status:
183+
(conditions[?type == 'Ready']):
184+
- status: "True"
185+
- assert:
186+
timeout: 2m
187+
resource:
188+
apiVersion: apps.cozystack.io/v1alpha1
189+
kind: VMDisk
190+
metadata:
191+
name: disk-clone
192+
status:
193+
(conditions[?type == 'Ready']):
194+
- status: "True"
195+
(conditions[?type == 'WorkloadsReady']):
196+
- status: "True"
197+
---
95198
apiVersion: chainsaw.kyverno.io/v1alpha1
96199
kind: Test
97200
metadata:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# vm-default-images is opt-in and not installed on the e2e cluster, so the suite
2+
# provides the golden image that VMDisk source.image clones from. The e2e prefix
3+
# keeps it clear of any image the package itself owns in cozy-public.
4+
apiVersion: cdi.kubevirt.io/v1beta1
5+
kind: DataVolume
6+
metadata:
7+
name: vm-default-images-e2e-alpine-3.21
8+
namespace: cozy-public
9+
annotations:
10+
cdi.kubevirt.io/storage.bind.immediate.requested: "true"
11+
spec:
12+
contentType: kubevirt
13+
source:
14+
http:
15+
url: https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/cloud/nocloud_alpine-3.21.7-x86_64-bios-cloudinit-r0.qcow2
16+
storage:
17+
resources:
18+
requests:
19+
storage: 1Gi
20+
storageClassName: ($values.storageClass)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: apps.cozystack.io/v1alpha1
2+
kind: VMDisk
3+
metadata:
4+
name: disk-clone
5+
spec:
6+
source:
7+
disk:
8+
name: image-clone
9+
optical: false
10+
storage: 1Gi
11+
storageClass: ($values.storageClass)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: apps.cozystack.io/v1alpha1
2+
kind: VMDisk
3+
metadata:
4+
name: image-clone
5+
spec:
6+
source:
7+
image:
8+
name: e2e-alpine-3.21
9+
optical: false
10+
storage: 1Gi
11+
storageClass: ($values.storageClass)

0 commit comments

Comments
 (0)