Skip to content

Commit

Permalink
tests, utils: Remove NotDeletedVMs()
Browse files Browse the repository at this point in the history
Signed-off-by: assafad <aadmi@redhat.com>
  • Loading branch information
assafad committed May 5, 2024
1 parent cf355c2 commit 8f0d968
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
19 changes: 10 additions & 9 deletions tests/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
poolv1 "kubevirt.io/api/pool/v1alpha1"
"kubevirt.io/client-go/kubecli"

"kubevirt.io/kubevirt/tests"
cd "kubevirt.io/kubevirt/tests/containerdisk"
)

Expand Down Expand Up @@ -109,7 +108,7 @@ var _ = Describe("[sig-compute]VirtualMachinePool", decorators.SigCompute, func(

vms, err := virtClient.VirtualMachine(util.NamespaceTestDefault).List(context.Background(), v12.ListOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(notDeletedVMs(pool.Name, vms)).To(HaveLen(int(scale)))
Expect(filterPoolNotDeletedVMs(pool.Name, vms)).To(HaveLen(int(scale)))
}
createVirtualMachinePool := func(pool *poolv1.VirtualMachinePool) *poolv1.VirtualMachinePool {
pool, err = virtClient.VirtualMachinePool(util.NamespaceTestDefault).Create(context.Background(), pool, metav1.CreateOptions{})
Expand Down Expand Up @@ -623,14 +622,16 @@ func newPoolFromVMI(vmi *v1.VirtualMachineInstance) *poolv1.VirtualMachinePool {
return pool
}

func notDeletedVMs(poolName string, vms *v1.VirtualMachineList) (notDeleted []v1.VirtualMachine) {
nonDeletedVms := tests.NotDeletedVMs(vms)
for _, vm := range nonDeletedVms {
for _, ref := range vm.OwnerReferences {
if ref.Name == poolName {
notDeleted = append(notDeleted, vm)
func filterPoolNotDeletedVMs(poolName string, vms *v1.VirtualMachineList) []v1.VirtualMachine {
var notDeleted []v1.VirtualMachine
for _, vm := range vms.Items {
if vm.DeletionTimestamp == nil {
for _, ref := range vm.OwnerReferences {
if ref.Name == poolName {
notDeleted = append(notDeleted, vm)
}
}
}
}
return
return notDeleted
}
9 changes: 0 additions & 9 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,6 @@ func GenerateVMJson(vm *v1.VirtualMachine, generateDirectory string) (string, er
return jsonFile, nil
}

func NotDeletedVMs(vms *v1.VirtualMachineList) (notDeleted []v1.VirtualMachine) {
for _, vm := range vms.Items {
if vm.DeletionTimestamp == nil {
notDeleted = append(notDeleted, vm)
}
}
return
}

func UnfinishedVMIPodSelector(vmi *v1.VirtualMachineInstance) metav1.ListOptions {
virtClient := kubevirt.Client()

Expand Down

0 comments on commit 8f0d968

Please sign in to comment.