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

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.
import time
import IPy
import errno
import base64
import socket
import random
......@@ -470,17 +471,27 @@ class CycladesTests(BurninTests):
def _check_file_through_ssh(self, hostip, username, password,
remotepath, content):
"""Fetch file from server and compare contents"""
self.info("Fetching file %s from remote server", remotepath)
transport = paramiko.Transport((hostip, 22))
transport.connect(username=username, password=password)
with tempfile.NamedTemporaryFile() as ftmp:
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.get(remotepath, ftmp.name)
sftp.close()
transport.close()
self.info("Comparing file contents")
remote_content = base64.b64encode(ftmp.read())
self.assertEqual(content, remote_content)
def check_fun():
"""Fetch file"""
try:
transport = paramiko.Transport((hostip, 22))
transport.connect(username=username, password=password)
with tempfile.NamedTemporaryFile() as ftmp:
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.get(remotepath, ftmp.name)
sftp.close()
transport.close()
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
......
......@@ -17,9 +17,9 @@
This is the burnin class that tests the Snapshots functionality
"""
import random
import stat
import base64
import random
from synnefo_tools.burnin.common import Proper, QPITHOS, QADD, QREMOVE, GB
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