Skip to content

Commit e43706d

Browse files
authored
test(vm): add SSHD service status check (#1853)
Virtual Machine Live Migration TCP Session case: to prevent error in the starting of the iPerf client. Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
1 parent 96a7671 commit e43706d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/e2e/vm/live_migration_tcp_session.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ var _ = Describe("VirtualMachineLiveMigrationTCPSession", func() {
101101
})
102102

103103
By("Run the iPerf client", func() {
104+
Expect(isAlpineSSHDStarted(f, iperfClient.Name, iperfClient.Namespace)).To(BeTrue(), "the SSHD service status should be `started`")
105+
104106
iperfServer, err := f.Clients.VirtClient().VirtualMachines(f.Namespace().Name).Get(context.Background(), iperfServer.Name, metav1.GetOptions{})
105107
Expect(err).NotTo(HaveOccurred())
108+
106109
cmd := fmt.Sprintf("nohup iperf3 --client %s --time 0 --json > ~/%s 2>&1 < /dev/null &", iperfServer.Status.IPAddress, reportName)
107110
_, err = f.SSHCommand(iperfClient.Name, iperfClient.Namespace, cmd)
108111
Expect(err).NotTo(HaveOccurred(), "failed to run iperf3 client")
@@ -279,3 +282,24 @@ func newVirtualMachine(name, namespace string, disk *v1alpha2.VirtualDisk) *v1al
279282
}),
280283
)
281284
}
285+
286+
func isAlpineSSHDStarted(f *framework.Framework, vmName, vmNamespace string) bool {
287+
GinkgoHelper()
288+
289+
var isStarted bool
290+
291+
cmd := "rc-service sshd status --nocolor"
292+
Eventually(func() error {
293+
stdout, err := f.SSHCommand(vmName, vmNamespace, cmd)
294+
if err != nil {
295+
return fmt.Errorf("cmd: %s\nstderr: %w", cmd, err)
296+
}
297+
if strings.Contains(stdout, "status: started") {
298+
isStarted = true
299+
return nil
300+
}
301+
return fmt.Errorf("the result does not contain the required status(it must contain the `started` status): %s", stdout)
302+
}).WithTimeout(framework.MiddleTimeout).WithPolling(framework.PollingInterval).ShouldNot(HaveOccurred())
303+
304+
return isStarted
305+
}

0 commit comments

Comments
 (0)