From b95ff2a98e94498f7aef5cc87360d3e9e7cef648 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 13 Jul 2026 16:44:45 +0300 Subject: [PATCH] fix(test): wait for iperf server migration before continuity checks verifyIPerfContinuityAfterUpgrade fetched the iperf-server VM immediately, but the post-upgrade workload migration is asynchronous and may start several minutes after the module becomes Ready. Status.MigrationState was still nil, so getIPerfClientReport panicked dereferencing it. Wait for the live migration to succeed before reading MigrationState, and guard the dereference so a future regression fails with a clear message. Signed-off-by: Maksim Fedotov --- test/e2e/release/current_release_smoke.go | 4 +++- test/e2e/release/iperf.go | 29 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/e2e/release/current_release_smoke.go b/test/e2e/release/current_release_smoke.go index 6700134f25..91f785476a 100644 --- a/test/e2e/release/current_release_smoke.go +++ b/test/e2e/release/current_release_smoke.go @@ -202,8 +202,10 @@ func (t *currentReleaseSmokeTest) verifyIPerfContinuityAfterUpgrade() { By("Stopping the long-running iperf client after upgrade") stopIPerfClient(t.framework, t.iperfClient.vm) + By("Waiting for the iperf server to be live-migrated by the upgrade") + iperfServer := waitForIPerfServerMigration(t.framework, t.iperfServer.vm.Namespace, t.iperfServer.vm.Name) + By("Validating the iperf report spans the module upgrade") - iperfServer := t.getVirtualMachine(t.iperfServer.vm.Name, t.iperfServer.vm.Namespace) report := getIPerfClientReport(t.framework, t.iperfClient.vm, releaseIPerfReportPath, iperfServer) Expect(isExpectedIPerfReportError(report.Error)).To(BeTrue(), "iperf3 report contains an unexpected error: %q", report.Error) diff --git a/test/e2e/release/iperf.go b/test/e2e/release/iperf.go index bfa9e0c3f5..3af082f14f 100644 --- a/test/e2e/release/iperf.go +++ b/test/e2e/release/iperf.go @@ -17,6 +17,7 @@ limitations under the License. package release import ( + "context" "encoding/json" "fmt" "strings" @@ -24,6 +25,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/test/e2e/internal/framework" @@ -117,6 +119,31 @@ func stopIPerfClient(f *framework.Framework, vm *v1alpha2.VirtualMachine) { }).WithTimeout(framework.MiddleTimeout).WithPolling(framework.PollingInterval).Should(Succeed()) } +func waitForIPerfServerMigration(f *framework.Framework, namespace, name string) *v1alpha2.VirtualMachine { + GinkgoHelper() + + var iperfServer *v1alpha2.VirtualMachine + Eventually(func() error { + vm, err := f.Clients.VirtClient().VirtualMachines(namespace).Get(context.Background(), name, metav1.GetOptions{}) + if err != nil { + return err + } + if vm.Status.MigrationState == nil { + return fmt.Errorf("virtual machine %s/%s has not been migrated yet", namespace, name) + } + if vm.Status.MigrationState.Result != v1alpha2.MigrationResultSucceeded { + return fmt.Errorf("virtual machine %s/%s migration is not succeeded yet: %q", namespace, name, vm.Status.MigrationState.Result) + } + if vm.Status.MigrationState.StartTimestamp.IsZero() || vm.Status.MigrationState.EndTimestamp.IsZero() { + return fmt.Errorf("virtual machine %s/%s migration timestamps are not set yet", namespace, name) + } + iperfServer = vm + return nil + }).WithTimeout(framework.MaxTimeout).WithPolling(framework.PollingInterval).Should(Succeed()) + + return iperfServer +} + func getIPerfClientReport(f *framework.Framework, vm *v1alpha2.VirtualMachine, reportPath string, iperfServer *v1alpha2.VirtualMachine) *iperfReport { GinkgoHelper() @@ -140,6 +167,8 @@ func getIPerfClientReport(f *framework.Framework, vm *v1alpha2.VirtualMachine, r Expect(result).NotTo(BeNil()) + Expect(iperfServer.Status.MigrationState).NotTo(BeNil(), "iperf server VM was not migrated during the upgrade") + iPerfClientStartTime, err := time.Parse(time.RFC1123, result.Start.Timestamp.Time) Expect(err).NotTo(HaveOccurred()) Expect(iPerfClientStartTime.Before(iperfServer.Status.MigrationState.StartTimestamp.Time)).To(BeTrue(), "the iPerfClient connection test should start before the virtual machine is migrated")