Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions images/virtualization-artifact/pkg/builder/vm/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,12 @@ func WithProvisioningUserData(cloudInit string) Option {
UserData: cloudInit,
})
}

func WithRestartApprovalMode(restartApprovalMode v1alpha2.RestartApprovalMode) Option {
return func(vm *v1alpha2.VirtualMachine) {
if vm.Spec.Disruptions == nil {
vm.Spec.Disruptions = &v1alpha2.Disruptions{}
}
vm.Spec.Disruptions.RestartApprovalMode = restartApprovalMode
}
}
1 change: 0 additions & 1 deletion test/e2e/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ type TestData struct {
DiskResizing string `yaml:"diskResizing"`
SizingPolicy string `yaml:"sizingPolicy"`
ImageHotplug string `yaml:"imageHotplug"`
VMConfiguration string `yaml:"vmConfiguration"`
VMLabelAnnotation string `yaml:"vmLabelAnnotation"`
VMMigration string `yaml:"vmMigration"`
VMMigrationCancel string `yaml:"vmMigrationCancel"`
Expand Down
38 changes: 38 additions & 0 deletions test/e2e/internal/util/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,41 @@ func StopVirtualMachineFromOS(f *framework.Framework, vm *v1alpha2.VirtualMachin
}
return err
}

func RebootVirtualMachineBySSH(f *framework.Framework, vm *v1alpha2.VirtualMachine) {
GinkgoHelper()

_, err := f.SSHCommand(vm.Name, vm.Namespace, "sudo reboot")
Expect(err).NotTo(HaveOccurred())
}

func RebootVirtualMachineByVMOP(f *framework.Framework, vm *v1alpha2.VirtualMachine) {
GinkgoHelper()

vmop := vmopbuilder.New(
vmopbuilder.WithGenerateName("vmop-e2e-reboot-"),
vmopbuilder.WithNamespace(vm.Namespace),
vmopbuilder.WithType(v1alpha2.VMOPTypeRestart),
vmopbuilder.WithVirtualMachine(vm.Name),
)
err := f.CreateWithDeferredDeletion(context.Background(), vmop)
Expect(err).NotTo(HaveOccurred())
}

func UntilVirtualMachineRebooted(key client.ObjectKey, previousRunningTime time.Time, timeout time.Duration) {
Eventually(func() error {
vm := &v1alpha2.VirtualMachine{}
err := framework.GetClients().GenericClient().Get(context.Background(), key, vm)
if err != nil {
return fmt.Errorf("failed to get virtual machine: %w", err)
}

runningCondition, _ := conditions.GetCondition(vmcondition.TypeRunning, vm.Status.Conditions)

if runningCondition.LastTransitionTime.Time.After(previousRunningTime) && vm.Status.Phase == v1alpha2.MachineRunning {
return nil
}

return fmt.Errorf("virtual machine %s is not rebooted", key.Name)
}, timeout, time.Second).Should(Succeed())
}

This file was deleted.

This file was deleted.

54 changes: 0 additions & 54 deletions test/e2e/legacy/testdata/vm-configuration/base/transformer.yaml

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions test/e2e/legacy/testdata/vm-configuration/base/vd-root.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions test/e2e/legacy/testdata/vm-configuration/base/vm.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions test/e2e/legacy/testdata/vm-configuration/kustomization.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions test/e2e/legacy/testdata/vm-configuration/ns.yaml

This file was deleted.

This file was deleted.

This file was deleted.

52 changes: 0 additions & 52 deletions test/e2e/legacy/testdata/vm-configuration/transformer.yaml

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions test/e2e/legacy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,19 @@ func CheckExternalConnection(host, httpCode, vmNamespace string, vmNames ...stri
CheckResultSSHCommand(vmNamespace, vmName, cmd, httpCode)
}
}

func ExecSSHCommand(vmNamespace, vmName, cmd string) {
GinkgoHelper()

Eventually(func() error {
res := framework.GetClients().D8Virtualization().SSHCommand(vmName, cmd, d8.SSHOptions{
Namespace: vmNamespace,
Username: conf.TestData.SSHUser,
IdentityFile: conf.TestData.Sshkey,
})
if res.Error() != nil {
return fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr())
}
return nil
}).WithTimeout(Timeout).WithPolling(Interval).ShouldNot(HaveOccurred())
}
Loading
Loading