Skip to content

Commit

Permalink
Merge pull request #253 from ksimon1/increase-timeout
Browse files Browse the repository at this point in the history
chore: Add flag for setting timeout for creating windows vms
  • Loading branch information
kubevirt-bot authored Oct 4, 2024
2 parents ae67eac + c6ffcb4 commit 30aa54a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/functests/instancetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (
)

const (
vmReadyTimeout = 300 * time.Second
sshPort = 22
sshPort = 22
)

type testFn func(kubecli.KubevirtClient, string)
Expand Down Expand Up @@ -157,7 +156,7 @@ var _ = Describe("Common instance types func tests", func() {
addCloudInitWithAuthorizedKey(vm, privKey)
vm, err = virtClient.VirtualMachine(testNamespace).Create(context.Background(), vm, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
expectVMToBeReady(virtClient, vm.Name)
expectVMToBeReady(virtClient, vm.Name, defaultVMReadyTimeout)
for _, testFn := range testFns {
testFn(virtClient, vm.Name)
}
Expand Down Expand Up @@ -197,7 +196,7 @@ var _ = Describe("Common instance types func tests", func() {
addContainerDisk(vm, containerDisk)
vm, err = virtClient.VirtualMachine(testNamespace).Create(context.Background(), vm, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
expectVMToBeReady(virtClient, vm.Name)
expectVMToBeReady(virtClient, vm.Name, windowsReadyTimeout)
for _, testFn := range testFns {
testFn(virtClient, vm.Name)
}
Expand Down Expand Up @@ -326,7 +325,7 @@ func addCloudInitWithAuthorizedKey(vm *v1.VirtualMachine, privKey ed25519.Privat
vm.Spec.Template.Spec.Volumes = append(vm.Spec.Template.Spec.Volumes, vol)
}

func expectVMToBeReady(virtClient kubecli.KubevirtClient, vmName string) {
func expectVMToBeReady(virtClient kubecli.KubevirtClient, vmName string, vmReadyTimeout time.Duration) {
Eventually(func(g Gomega) {
vm, err := virtClient.VirtualMachine(testNamespace).Get(context.Background(), vmName, metav1.GetOptions{})
g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -338,7 +337,7 @@ func expectGuestAgentToBeConnected(virtClient kubecli.KubevirtClient, vmName str
Eventually(func(g Gomega) {
_, err := virtClient.VirtualMachineInstance(testNamespace).GuestOsInfo(context.Background(), vmName)
g.Expect(err).ToNot(HaveOccurred())
}, vmReadyTimeout, 10*time.Second).Should(Succeed())
}, defaultVMReadyTimeout, 10*time.Second).Should(Succeed())
}

func expectSSHToRunCommandOnWindows(virtClient kubecli.KubevirtClient, vmName string) {
Expand Down Expand Up @@ -367,5 +366,5 @@ func expectSSHToRunCommand(virtClient kubecli.KubevirtClient, vmName, username s

err = session.Run("echo hello")
g.Expect(err).ToNot(HaveOccurred())
}, vmReadyTimeout, 10*time.Second).Should(Succeed())
}, defaultVMReadyTimeout, 10*time.Second).Should(Succeed())
}
7 changes: 7 additions & 0 deletions tests/functests/test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"os"
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
ginkgo_reporters "github.com/onsi/ginkgo/v2/reporters"
Expand Down Expand Up @@ -42,6 +43,8 @@ const (
defaultWindows2k19ContainerDisk = "registry:5000/windows2k19-container-disk:latest"
defaultWindows2k22ContainerDisk = "registry:5000/windows2k22-container-disk:latest"
defaultWindows2k25ContainerDisk = "registry:5000/windows2k25-container-disk:latest"

defaultVMReadyTimeout = 300 * time.Second
)

var (
Expand All @@ -68,6 +71,8 @@ var (
openSUSETumbleweedContainerDisk string
openSUSELeap15ContainerDisk string
sles15ContainerDisk string

windowsReadyTimeout time.Duration
)

//nolint:gochecknoinits
Expand Down Expand Up @@ -114,6 +119,8 @@ func init() {
defaultWindows2k22ContainerDisk, "Windows Server 2022 container disk used by functional tests")
flag.StringVar(&windows2k25ContainerDisk, "windows-2k25-container-disk",
defaultWindows2k25ContainerDisk, "Windows Server 2025 container disk used by functional tests")
flag.DurationVar(&windowsReadyTimeout, "windows-ready-timeout",
defaultVMReadyTimeout, "Duration after Windows VM will timeout")
}

func checkDeployedResources() {
Expand Down

0 comments on commit 30aa54a

Please sign in to comment.