-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27980 from qinqon/kubevirt-live-migration
kubevirt: Add live migration tests
- Loading branch information
Showing
3 changed files
with
213 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package kubevirt | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
e2e "k8s.io/kubernetes/test/e2e/framework" | ||
admissionapi "k8s.io/pod-security-admission/api" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
) | ||
|
||
var _ = Describe("[sig-kubevirt] migration", func() { | ||
oc := exutil.NewCLIWithPodSecurityLevel("ns-global", admissionapi.LevelBaseline) | ||
InKubeVirtClusterContext(oc, func() { | ||
mgmtFramework := e2e.NewDefaultFramework("mgmt-framework") | ||
mgmtFramework.SkipNamespaceCreation = true | ||
|
||
f1 := e2e.NewDefaultFramework("server-framework") | ||
f1.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged | ||
var ( | ||
numberOfReadyNodes = func() (int, error) { | ||
nodeList, err := f1.ClientSet.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) | ||
if err != nil { | ||
return 0, err | ||
} | ||
numberOfReadyNodes := 0 | ||
for _, node := range nodeList.Items { | ||
for _, condition := range node.Status.Conditions { | ||
if condition.Type == corev1.NodeReady && condition.Status == corev1.ConditionTrue { | ||
numberOfReadyNodes += 1 | ||
} | ||
} | ||
} | ||
return numberOfReadyNodes, nil | ||
} | ||
) | ||
AfterLiveMigrateWorkersContext(mgmtFramework, func() { | ||
It("should maintain node readiness", func() { | ||
nodeList, err := f1.ClientSet.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
numberOfNodes := len(nodeList.Items) | ||
|
||
By("Check node readiness is as expected") | ||
isAWS, err := mgmtClusterIsAWS(mgmtFramework) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
if isAWS { | ||
// At aws live-migration tcp connections are broken so Node | ||
// readiness is broken too, we have wait for it to reach | ||
// not ready and then check if eventually and consistently it's | ||
// ready again | ||
Eventually(numberOfReadyNodes). | ||
WithTimeout(2*time.Minute). | ||
WithPolling(5*time.Second). | ||
ShouldNot(Equal(numberOfNodes), "nodes should reach not ready state") | ||
} | ||
Eventually(numberOfReadyNodes). | ||
WithTimeout(2*time.Minute). | ||
WithPolling(5*time.Second). | ||
Should(Equal(numberOfNodes), "nodes should reach ready state") | ||
Consistently(numberOfReadyNodes). | ||
WithTimeout(2*time.Minute). | ||
WithPolling(5*time.Second). | ||
Should(Equal(numberOfNodes), "nodes should maintain ready state") | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/extended/util/annotate/generated/zz_generated.annotations.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.