Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Myasnikov Daniil
25537cadd6
[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 <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-04-27 21:05:52 +05:00
Myasnikov Daniil
f7c7044602
[tests] Use Alpine for source.disk base instead of Ubuntu noble
The clone step is what this test exercises, not the HTTP import. Ubuntu
noble is ~600MB; Alpine is ~50MB, which cuts CI time without losing
coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-04-27 21:05:52 +05:00
Myasnikov Daniil
d8b195c3e7
[tests] Add BATS E2E coverage for vm-disk source.disk and source.image
Follow-up to PR #2258: adds two new @test cases in hack/e2e-apps/vm-disk.bats
covering the new vm-disk clone paths — source.image (golden image from
cozy-public) and source.disk (PVC clone within tenant namespace). Existing
source.http coverage in vminstance.bats is not touched.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-04-27 21:05:52 +05:00

View file

@ -0,0 +1,81 @@
#!/usr/bin/env bats
# Tests for vm-disk source types: source.image and source.disk.
# Existing source.http coverage lives in vminstance.bats.
teardown() {
kubectl -n tenant-test delete vmdisks.apps.cozystack.io test-image-src test-disk-clone test-disk-base --ignore-not-found --timeout=2m || true
}
@test "Create a VM Disk from source.image (golden image clone)" {
name='test-image-src'
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $name --ignore-not-found --timeout=2m || true
kubectl apply -f - <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: VMDisk
metadata:
name: $name
namespace: tenant-test
spec:
source:
image:
name: alpine-3.21
optical: false
storage: 5Gi
storageClass: replicated
EOF
sleep 5
kubectl -n tenant-test wait hr vm-disk-$name --timeout=30s --for=condition=ready
kubectl -n tenant-test wait dv vm-disk-$name --timeout=250s --for=condition=ready
kubectl -n tenant-test wait pvc vm-disk-$name --timeout=200s --for=jsonpath='{.status.phase}'=Bound
}
@test "Create a VM Disk from source.disk (PVC clone)" {
base='test-disk-base'
clone='test-disk-clone'
# Ensure both resources are absent before starting
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $clone --ignore-not-found --timeout=2m || true
kubectl -n tenant-test delete vmdisks.apps.cozystack.io $base --ignore-not-found --timeout=2m || true
# Create the base disk from a golden image. The assertion here is the clone
# step (source.disk), not the base provisioning method.
kubectl apply -f - <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: VMDisk
metadata:
name: $base
namespace: tenant-test
spec:
source:
image:
name: alpine-3.21
optical: false
storage: 5Gi
storageClass: replicated
EOF
sleep 5
kubectl -n tenant-test wait hr vm-disk-$base --timeout=30s --for=condition=ready
kubectl -n tenant-test wait dv vm-disk-$base --timeout=250s --for=condition=ready
kubectl -n tenant-test wait pvc vm-disk-$base --timeout=200s --for=jsonpath='{.status.phase}'=Bound
# Now clone the base disk using source.disk
kubectl apply -f - <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: VMDisk
metadata:
name: $clone
namespace: tenant-test
spec:
source:
disk:
name: $base
optical: false
storage: 5Gi
storageClass: replicated
EOF
sleep 5
kubectl -n tenant-test wait hr vm-disk-$clone --timeout=30s --for=condition=ready
kubectl -n tenant-test wait dv vm-disk-$clone --timeout=250s --for=condition=ready
kubectl -n tenant-test wait pvc vm-disk-$clone --timeout=200s --for=jsonpath='{.status.phase}'=Bound
}