Skip to content

Commit db48236

Browse files
authored
test: migrate VirtualMachineEvacuation e2e test to new framework (#2323)
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
1 parent 01505b2 commit db48236

21 files changed

Lines changed: 206 additions & 441 deletions

test/e2e/default_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ testData:
2424
vmConfiguration: "/tmp/testdata/vm-configuration"
2525
vmMigration: "/tmp/testdata/vm-migration"
2626
vmMigrationCancel: "/tmp/testdata/vm-migration-cancel"
27-
vmEvacuation: "/tmp/testdata/vm-evacuation"
2827
vdSnapshots: "/tmp/testdata/vd-snapshots"
2928
sshKey: "/tmp/testdata/sshkeys/id_ed"
3029
sshUser: "cloud"

test/e2e/internal/config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ type TestData struct {
9292
ImageHotplug string `yaml:"imageHotplug"`
9393
VMMigration string `yaml:"vmMigration"`
9494
VMMigrationCancel string `yaml:"vmMigrationCancel"`
95-
VMEvacuation string `yaml:"vmEvacuation"`
9695
VdSnapshots string `yaml:"vdSnapshots"`
9796
Sshkey string `yaml:"sshKey"`
9897
SSHUser string `yaml:"sshUser"`

test/e2e/internal/util/vm.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func RebootVirtualMachineByVMOP(f *framework.Framework, vm *v1alpha2.VirtualMach
308308
func RebootVirtualMachineByPodDeletion(f *framework.Framework, vm *v1alpha2.VirtualMachine) {
309309
GinkgoHelper()
310310

311-
activePodName, err := getActivePodName(vm)
311+
activePodName, err := GetActivePodName(vm)
312312
Expect(err).NotTo(HaveOccurred())
313313
Expect(activePodName).NotTo(BeEmpty())
314314

@@ -323,14 +323,41 @@ func RebootVirtualMachineByPodDeletion(f *framework.Framework, vm *v1alpha2.Virt
323323
Expect(err).NotTo(HaveOccurred())
324324
}
325325

326-
func getActivePodName(vm *v1alpha2.VirtualMachine) (string, error) {
326+
func GetVirtualMachineAndActivePod(ctx context.Context, f *framework.Framework, vm *v1alpha2.VirtualMachine) (*v1alpha2.VirtualMachine, *corev1.Pod, error) {
327+
var currentVM v1alpha2.VirtualMachine
328+
err := f.GenericClient().Get(ctx, client.ObjectKey{
329+
Namespace: vm.Namespace,
330+
Name: vm.Name,
331+
}, &currentVM)
332+
if err != nil {
333+
return nil, nil, err
334+
}
335+
336+
activePodName, err := GetActivePodName(&currentVM)
337+
if err != nil {
338+
return nil, nil, err
339+
}
340+
341+
var activePod corev1.Pod
342+
err = f.GenericClient().Get(ctx, client.ObjectKey{
343+
Namespace: vm.Namespace,
344+
Name: activePodName,
345+
}, &activePod)
346+
if err != nil {
347+
return nil, nil, err
348+
}
349+
350+
return &currentVM, &activePod, nil
351+
}
352+
353+
func GetActivePodName(vm *v1alpha2.VirtualMachine) (string, error) {
327354
for _, pod := range vm.Status.VirtualMachinePods {
328355
if pod.Active {
329356
return pod.Name, nil
330357
}
331358
}
332359

333-
return "", fmt.Errorf("no active pod found for virtual machine %s", vm.Name)
360+
return "", fmt.Errorf("no active pod found for virtual machine %s/%s", vm.Namespace, vm.Name)
334361
}
335362

336363
func UntilVirtualMachineRebooted(key client.ObjectKey, previousRunningTime time.Time, timeout time.Duration) {

test/e2e/legacy/testdata/vm-evacuation/kustomization.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/ns.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/transformer.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/vm/base/cfg/cloudinit.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/vm/base/kustomization.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/vm/base/transformer.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

test/e2e/legacy/testdata/vm-evacuation/vm/base/vd-blank.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)