Skip to content

Commit b291fa6

Browse files
[tests] Address review feedback for vm-disk E2E tests
- Add teardown() function for reliable cleanup after each test - Increase HelmRelease wait timeout from 5s to 30s - Switch base disk in source.disk test from source.http to source.image - Remove inline cleanup in favor of teardown Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 521f8a4 commit b291fa6

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎hack/e2e-apps/vm-disk.bats‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Tests for vm-disk source types: source.image and source.disk.
44
# Existing source.http coverage lives in vminstance.bats.
55

6+
teardown() {
7+
kubectl -n tenant-test delete vmdisks.apps.cozystack.io test-image-src test-disk-clone test-disk-base --ignore-not-found --timeout=2m || true
8+
}
9+
610
@test "Create a VM Disk from source.image (golden image clone)" {
711
name='test-image-src'
812
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $name --ignore-not-found --timeout=2m || true
@@ -21,10 +25,9 @@ spec:
2125
storageClass: replicated
2226
EOF
2327
sleep 5
24-
kubectl -n tenant-test wait hr vm-disk-$name --timeout=5s --for=condition=ready
28+
kubectl -n tenant-test wait hr vm-disk-$name --timeout=30s --for=condition=ready
2529
kubectl -n tenant-test wait dv vm-disk-$name --timeout=250s --for=condition=ready
2630
kubectl -n tenant-test wait pvc vm-disk-$name --timeout=200s --for=jsonpath='{.status.phase}'=Bound
27-
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $name
2831
}
2932

3033
@test "Create a VM Disk from source.disk (PVC clone)" {
@@ -35,8 +38,8 @@ EOF
3538
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $clone --ignore-not-found --timeout=2m || true
3639
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $base --ignore-not-found --timeout=2m || true
3740

38-
# Create the base disk via source.http. Alpine is ~50MB vs Ubuntu noble's ~600MB,
39-
# which keeps this test fast; the assertion here is the clone step, not the HTTP import.
41+
# Create the base disk from a golden image. The assertion here is the clone
42+
# step (source.disk), not the base provisioning method.
4043
kubectl apply -f - <<EOF
4144
apiVersion: apps.cozystack.io/v1alpha1
4245
kind: VMDisk
@@ -45,14 +48,14 @@ metadata:
4548
namespace: tenant-test
4649
spec:
4750
source:
48-
http:
49-
url: https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/cloud/nocloud_alpine-3.21.6-x86_64-bios-cloudinit-r0.qcow2
51+
image:
52+
name: alpine-3.21
5053
optical: false
5154
storage: 5Gi
5255
storageClass: replicated
5356
EOF
5457
sleep 5
55-
kubectl -n tenant-test wait hr vm-disk-$base --timeout=5s --for=condition=ready
58+
kubectl -n tenant-test wait hr vm-disk-$base --timeout=30s --for=condition=ready
5659
kubectl -n tenant-test wait dv vm-disk-$base --timeout=250s --for=condition=ready
5760
kubectl -n tenant-test wait pvc vm-disk-$base --timeout=200s --for=jsonpath='{.status.phase}'=Bound
5861

@@ -72,11 +75,7 @@ spec:
7275
storageClass: replicated
7376
EOF
7477
sleep 5
75-
kubectl -n tenant-test wait hr vm-disk-$clone --timeout=5s --for=condition=ready
78+
kubectl -n tenant-test wait hr vm-disk-$clone --timeout=30s --for=condition=ready
7679
kubectl -n tenant-test wait dv vm-disk-$clone --timeout=250s --for=condition=ready
7780
kubectl -n tenant-test wait pvc vm-disk-$clone --timeout=200s --for=jsonpath='{.status.phase}'=Bound
78-
79-
# Cleanup both
80-
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $clone
81-
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $base
8281
}

0 commit comments

Comments
 (0)