Skip to content

Commit

Permalink
[e2e] Ignore LiveMigrate warning
Browse files Browse the repository at this point in the history
EvictionStrategy can be set at cluster level.
When it is `LiveMigrate` and a vmi which is not live migratable is started,
a warning event is emitted. This warning can cause the failure of the test
because the utility function that wait for the vmi to start, generally,
does not tolerate any warning.
Set the specific warning in the warning ignore list when we detect that
the cluster level eviction strategy is `LiveMigrate`.

Signed-off-by: fossedihelm <[email protected]>
  • Loading branch information
fossedihelm committed Jun 21, 2023
1 parent f7e7f60 commit f6853e4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/libwait/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_library(
"//staging/src/kubevirt.io/client-go/kubecli:go_default_library",
"//tests/console:go_default_library",
"//tests/framework/matcher:go_default_library",
"//tests/testsuite:go_default_library",
"//tests/watcher:go_default_library",
"//vendor/github.com/onsi/ginkgo/v2:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
Expand Down
3 changes: 3 additions & 0 deletions tests/libwait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"fmt"
"time"

"kubevirt.io/kubevirt/tests/testsuite"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

Expand Down Expand Up @@ -69,6 +71,7 @@ func WaitForVMIPhase(vmi *v1.VirtualMachineInstance, phases []v1.VirtualMachineI
waiting.ctx = ctx
}

WithWarningsIgnoreList(testsuite.TestRunConfiguration.WarningToIgnoreList)(&waiting)
return waiting.watchVMIForPhase(vmi)
}

Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go_library(
"kubevirtresource.go",
"manifest.go",
"namespace.go",
"runconfiguration.go",
"serviceaccount.go",
],
importpath = "kubevirt.io/kubevirt/tests/testsuite",
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func SynchronizedBeforeTestSetup() []byte {
EnsureKVMPresent()
AdjustKubeVirtResource()
EnsureKubevirtReady()
InitRunConfiguration()

return nil
}
Expand Down
23 changes: 23 additions & 0 deletions tests/testsuite/runconfiguration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package testsuite

import (
v1 "kubevirt.io/api/core/v1"
)

var (
TestRunConfiguration RunConfiguration
)

type RunConfiguration struct {
WarningToIgnoreList []string
}

func InitRunConfiguration() {
runConfig := RunConfiguration{}
if KubeVirtDefaultConfig.EvictionStrategy != nil &&
*KubeVirtDefaultConfig.EvictionStrategy == v1.EvictionStrategyLiveMigrate {
runConfig.WarningToIgnoreList = append(runConfig.WarningToIgnoreList, "EvictionStrategy is set but vmi is not migratable")
}

TestRunConfiguration = runConfig
}
12 changes: 1 addition & 11 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,10 @@ func RunVMI(vmi *v1.VirtualMachineInstance, timeout int) *v1.VirtualMachineInsta

func RunVMIAndExpectLaunch(vmi *v1.VirtualMachineInstance, timeout int) *v1.VirtualMachineInstance {
vmi = RunVMI(vmi, timeout)
virtCli := kubevirt.Client()
kv := util2.GetCurrentKv(virtCli)
By(WaitingVMInstanceStart)
opts := []libwait.Option{
libwait.WithTimeout(timeout),
}
if kv.Spec.Configuration.EvictionStrategy != nil &&
*kv.Spec.Configuration.EvictionStrategy == v1.EvictionStrategyLiveMigrate {
opts = append(opts, libwait.WithWarningsIgnoreList([]string{"EvictionStrategy is set but vmi is not migratable"}))
}

return libwait.WaitForVMIPhase(vmi,
[]v1.VirtualMachineInstancePhase{v1.Running},
opts...,
libwait.WithTimeout(timeout),
)
}

Expand Down

0 comments on commit f6853e4

Please sign in to comment.