Skip to content

Commit 634e6ee

Browse files
authored
test(vdsnapshot): add test labels for vdsnapshots (#1433)
Added vd snapshots and kubevirt resources to the artifacts in case the e2e test fails Signed-off-by: Isteb4k <[email protected]>
1 parent dab9b7e commit 634e6ee

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

images/virtualization-artifact/pkg/controller/vm/internal/filesystem.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func (h *FilesystemHandler) Handle(ctx context.Context, s state.VirtualMachineSt
6969

7070
agentReady, _ := conditions.GetCondition(vmcondition.TypeAgentReady, changed.Status.Conditions)
7171
if agentReady.Status != metav1.ConditionTrue {
72-
cb.Status(metav1.ConditionUnknown).Reason(conditions.ReasonUnknown)
7372
return reconcile.Result{}, nil
7473
}
7574

tests/e2e/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ func SaveTestResources(labels map[string]string, additional string) {
748748

749749
str := fmt.Sprintf("/tmp/e2e_failed__%s__%s.yaml", labels["testcase"], additional)
750750

751-
cmdr := kubectl.Get("virtualization -A", kc.GetOptions{Output: "yaml", Labels: labels})
751+
cmdr := kubectl.Get("virtualization,intvirt -A", kc.GetOptions{Output: "yaml", Labels: labels})
752752
Expect(cmdr.Error()).NotTo(HaveOccurred(), "cmd: %s\nstderr: %s", cmdr.GetCmd(), cmdr.StdErr())
753753

754754
err := os.WriteFile(str, cmdr.StdOutBytes(), 0o644)

tests/e2e/vd_snapshots_test.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e
1919
import (
2020
"errors"
2121
"fmt"
22+
"maps"
2223
"strings"
2324
"sync"
2425
"time"
@@ -147,7 +148,10 @@ var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), f
147148

148149
for _, vdName := range vds {
149150
By(fmt.Sprintf("Create snapshot for %q", vdName))
150-
err := CreateVirtualDiskSnapshot(vdName, vdName, ns, true, hasNoConsumerLabel)
151+
labels := make(map[string]string)
152+
maps.Copy(labels, hasNoConsumerLabel)
153+
maps.Copy(labels, testCaseLabel)
154+
err := CreateVirtualDiskSnapshot(vdName, vdName, ns, true, labels)
151155
Expect(err).NotTo(HaveOccurred(), "%s", err)
152156
}
153157
})
@@ -195,7 +199,10 @@ var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), f
195199
for _, blockDevice := range blockDevices {
196200
if blockDevice.Kind == virtv2.VirtualDiskKind {
197201
By(fmt.Sprintf("Create snapshot for %q", blockDevice.Name))
198-
err := CreateVirtualDiskSnapshot(blockDevice.Name, blockDevice.Name, ns, true, attachedVirtualDiskLabel)
202+
labels := make(map[string]string)
203+
maps.Copy(labels, attachedVirtualDiskLabel)
204+
maps.Copy(labels, testCaseLabel)
205+
err := CreateVirtualDiskSnapshot(blockDevice.Name, blockDevice.Name, ns, true, labels)
199206
Expect(err).NotTo(HaveOccurred(), "%s", err)
200207

201208
Eventually(func() error {
@@ -246,7 +253,11 @@ var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), f
246253
go func(index int) {
247254
defer wg.Done()
248255
snapshotName := fmt.Sprintf("%s-%d", blockDevice.Name, index)
249-
err := CreateVirtualDiskSnapshot(blockDevice.Name, snapshotName, ns, true, attachedVirtualDiskLabel)
256+
257+
labels := make(map[string]string)
258+
maps.Copy(labels, attachedVirtualDiskLabel)
259+
maps.Copy(labels, testCaseLabel)
260+
err := CreateVirtualDiskSnapshot(blockDevice.Name, snapshotName, ns, true, labels)
250261
if err != nil {
251262
errs = append(errs, err)
252263
}
@@ -303,12 +314,12 @@ var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), f
303314

304315
for _, vm := range vmObjects.Items {
305316
Eventually(func() error {
306-
frozen, err := CheckFileSystemFrozen(vm.Name, ns)
317+
frozen, err := CheckFileSystemFrozen(vm.Name, vm.Namespace)
307318
if err != nil {
308319
return nil
309320
}
310321
if frozen {
311-
return errors.New("Filesystem of the Virtual Machine is frozen")
322+
return fmt.Errorf("the filesystem of the virtual machine %s/%s is frozen", vm.Namespace, vm.Name)
312323
}
313324
return nil
314325
}).WithTimeout(

0 commit comments

Comments
 (0)