Commit eebbda78 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Ilias Tsitsimpis
Browse files

burnin: Wait for the sshd service to come up

Retry '_check_file_through_ssh' if ssh connection fails with
'ECONNREFUSED' (probably because the sshd service has not come up yet).
parent 2ac203c0
...@@ -22,6 +22,7 @@ had grown too much. ...@@ -22,6 +22,7 @@ had grown too much.
import time import time
import IPy import IPy
import errno
import base64 import base64
import socket import socket
import random import random
...@@ -470,17 +471,27 @@ class CycladesTests(BurninTests): ...@@ -470,17 +471,27 @@ class CycladesTests(BurninTests):
def _check_file_through_ssh(self, hostip, username, password, def _check_file_through_ssh(self, hostip, username, password,
remotepath, content): remotepath, content):
"""Fetch file from server and compare contents""" """Fetch file from server and compare contents"""
self.info("Fetching file %s from remote server", remotepath) def check_fun():
transport = paramiko.Transport((hostip, 22)) """Fetch file"""
transport.connect(username=username, password=password) try:
with tempfile.NamedTemporaryFile() as ftmp: transport = paramiko.Transport((hostip, 22))
sftp = paramiko.SFTPClient.from_transport(transport) transport.connect(username=username, password=password)
sftp.get(remotepath, ftmp.name) with tempfile.NamedTemporaryFile() as ftmp:
sftp.close() sftp = paramiko.SFTPClient.from_transport(transport)
transport.close() sftp.get(remotepath, ftmp.name)
self.info("Comparing file contents") sftp.close()
remote_content = base64.b64encode(ftmp.read()) transport.close()
self.assertEqual(content, remote_content) self.info("Comparing file contents")
remote_content = base64.b64encode(ftmp.read())
self.assertEqual(content, remote_content)
except socket.error as (err_no, err_str):
if err_no == errno.ECONNREFUSED:
raise Retry()
else:
raise
opmsg = "Fetching file %s from remote server" % remotepath
self.info(opmsg)
self._try_until_timeout_expires(opmsg, check_fun)
# ---------------------------------- # ----------------------------------
# Networks # Networks
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
This is the burnin class that tests the Snapshots functionality This is the burnin class that tests the Snapshots functionality
""" """
import random
import stat import stat
import base64 import base64
import random
from synnefo_tools.burnin.common import Proper, QPITHOS, QADD, QREMOVE, GB from synnefo_tools.burnin.common import Proper, QPITHOS, QADD, QREMOVE, GB
from synnefo_tools.burnin.cyclades_common import CycladesTests from synnefo_tools.burnin.cyclades_common import CycladesTests
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment