Yoav Kleinberger has uploaded a new change for review.
Change subject: incorporate stop/start logic to functional tests ......................................................................
incorporate stop/start logic to functional tests
Change-Id: I55b86578a681de2b09ac5ee01ca2e3b9443ed13a Signed-off-by: Yoav Kleinberger ykleinbe@redhat.com --- M tests/functional/new/basicLocalFSStorageDomainTest.py A tests/functional/new/controlvdsm.py 2 files changed, 65 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/29423/1
diff --git a/tests/functional/new/basicLocalFSStorageDomainTest.py b/tests/functional/new/basicLocalFSStorageDomainTest.py index a590886..3280e16 100644 --- a/tests/functional/new/basicLocalFSStorageDomainTest.py +++ b/tests/functional/new/basicLocalFSStorageDomainTest.py @@ -6,10 +6,22 @@ import uuid import storage.volume import storage.image +import logging +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s TEST %(levelname)s: %(message)s') from . import testlib +from . import controlvdsm
class TestBasicLocalFSStorageDomain: - def notest_flow_connect_create_storage_domain_format_disconnect(self): + def setup(self): + control_vdsm = controlvdsm.ControlVDSM() + control_vdsm.cleanup() + + @classmethod + def teardown_class(cls): + control_vdsm = controlvdsm.ControlVDSM() + control_vdsm.cleanup() + + def test_flow_connect_create_storage_domain_format_disconnect(self): with testlib.TemporaryDirectory() as directory:
with testlib.VDSMTestTools() as (vdsm, verify): diff --git a/tests/functional/new/controlvdsm.py b/tests/functional/new/controlvdsm.py new file mode 100644 index 0000000..a7e8e79 --- /dev/null +++ b/tests/functional/new/controlvdsm.py @@ -0,0 +1,52 @@ +import subprocess +import logging +import vdsm.vdscli +import socket +import vdsm.config +import time + +class ControlVDSM: + def cleanup(self): + self._stop_service() + assert not self._service_running() + self._brutally_clean_files() +# self._restart_service() + return self._check_connection() + + def _check_connection(self): + useSSL = vdsm.config.config.getboolean('vars', 'ssl') + vdsmClient = vdsm.vdscli.connect(useSSL=useSSL) + RETRIES = 5 + for _ in range(RETRIES): + try: + vdsmClient.getStorageDomainsList() + logging.info('VDSM ready for testing') + except socket.error as e: + logging.warning('could not talk to VDSM: %s' % e) + time.sleep(1) + + raise Exception('could not connect to VDSM') + + def _stop_service(self): + self._run("sudo service vdsmd stop") + + def _service_running(self): + return_code = subprocess.call('sudo service vdsmd status', shell=True, stdout=open('/dev/null','w'), stderr=open('/dev/null','w')) + logging.info('vdsm running: %s' % (return_code == 0)) + return return_code == 0 + + def _restart_service(self): + self._run("sudo vdsm-tool configure --force") + self._run("sudo service vdsmd start") + + def _run(self, command): + logging.info('running: %s' % command) + return_code = subprocess.call(command, shell=True, close_fds=True, stdout=open('/dev/null','w'), stderr=open('/dev/null','w')) + if return_code != 0: + logging.warning('failure! command was: %s' % command) + else: + logging.info('finished.') + + def _brutally_clean_files(self): + logging.warning('removing /rhev/data-center without asking too many questions') + self._run('sudo rm -fr /rhev/data-center/*')