Skip to content

Commit

Permalink
Istio, e2e test containers complete in source virt-launcher pod
Browse files Browse the repository at this point in the history
Add an e2e test that checks that after LiveMigration is finished,
all containers get to completed state in the source virt-launcher
pod.

This is currently broken, hence the XFail.

Signed-off-by: Radim Hrazdil <[email protected]>
  • Loading branch information
Radim Hrazdil committed Jun 15, 2021
1 parent 9147f1c commit 8187c61
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/network/vmi_istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,50 @@ var _ = SIGDescribe("[Serial] Istio", func() {
By("Waiting for VMI to be ready")
tests.WaitUntilVMIReady(vmi, console.LoginToCirros)
})
Describe("Live Migration", func() {
var (
sourcePodName string
)
migrationCompleted := func(migration *v1.VirtualMachineInstanceMigration) error {
migration, err := virtClient.VirtualMachineInstanceMigration(migration.Namespace).Get(migration.Name, &metav1.GetOptions{})
if err != nil {
return err
}
if migration.Status.Phase == v1.MigrationSucceeded {
return nil
}
return fmt.Errorf("migration is in phase %s", migration.Status.Phase)
}
allContainersCompleted := func(podName string) error {
pod, err := virtClient.CoreV1().Pods(vmi.Namespace).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
return err
}
for _, containerStatus := range pod.Status.ContainerStatuses {
if containerStatus.State.Terminated == nil {
return fmt.Errorf("container %s is not terminated, state: %s", containerStatus.Name, containerStatus.State.String())
}
}
return nil
}
BeforeEach(func() {
tests.SkipIfMigrationIsNotPossible()
})
JustBeforeEach(func() {
sourcePodName = tests.GetVmPodName(virtClient, vmi)
migration := tests.NewRandomMigration(vmi.Name, vmi.Namespace)
migration, err = virtClient.VirtualMachineInstanceMigration(migration.Namespace).Create(migration)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
return migrationCompleted(migration)
}, tests.MigrationWaitTime, time.Second).Should(Succeed(), fmt.Sprintf(" migration should succeed"))
})
PIt("All containers should complete in source virt-launcher pod after migration", func() {
Eventually(func() error {
return allContainersCompleted(sourcePodName)
}, tests.ContainerCompletionWaitTime, time.Second).Should(Succeed(), fmt.Sprintf("all containers should complete in source virt-launcher pod"))
})
})
Describe("Inbound traffic", func() {
checkVMIReachability := func(vmi *v1.VirtualMachineInstance, targetPort int) error {
job, err := createJobCheckingVMIReachability(vmi, targetPort)
Expand Down
1 change: 1 addition & 0 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const (
)

const MigrationWaitTime = 240
const ContainerCompletionWaitTime = 60

type ProcessFunc func(event *k8sv1.Event) (done bool)

Expand Down

0 comments on commit 8187c61

Please sign in to comment.