Fix tox.ini to run unit tests on CI
Change-Id: I64a998b04e432397dcb34f70e7a0167374147eef
diff --git a/tcp_tests/managers/k8smanager.py b/tcp_tests/managers/k8smanager.py
index 12dd2dc..6394141 100644
--- a/tcp_tests/managers/k8smanager.py
+++ b/tcp_tests/managers/k8smanager.py
@@ -289,15 +289,17 @@
ns = self.api.namespaces.get(name=name)
LOG.info("Namespace '{0}' is already exists".format(ns.name))
except ApiException as e:
- if hasattr(e,"status") and 404 == e.status:
- LOG.info("Creating Namespace in k8s cluster")
- ns = self.api.namespaces.create(body={'metadata': {'name': name}})
- LOG.info("Namespace '{0}' is created".format(ns.name))
- # wait 10 seconds until a token for new service account is created
- time.sleep(10)
- ns = self.api.namespaces.get(name=ns.name)
- else:
- raise
+ if hasattr(e, "status") and 404 == e.status:
+ LOG.info("Creating Namespace in k8s cluster")
+ ns = self.api.namespaces.create(
+ body={'metadata': {'name': name}})
+ LOG.info("Namespace '{0}' is created".format(ns.name))
+ # wait 10 seconds until a token for new service account
+ # is created
+ time.sleep(10)
+ ns = self.api.namespaces.get(name=ns.name)
+ else:
+ raise
return ns
def create_objects(self, path):
@@ -409,7 +411,6 @@
cmd = "apt install jq -y"
return self.__underlay.check_call(cmd, node_name=self.ctl_host)
-
def git_clone(self, project, target):
cmd = "git clone {0} {1}".format(project, target)
return self.__underlay.check_call(cmd, node_name=self.ctl_host)
@@ -494,4 +495,4 @@
cmd = ("~/virtlet/examples/virsh.sh domblklist {} | "
"tail -n +3 | awk {{'print $2'}}".format(domain_id))
result = self.__underlay.check_call(cmd, node_name=self.ctl_host)
- return result['stdout'].strip()
\ No newline at end of file
+ return result['stdout'].strip()
diff --git a/tcp_tests/managers/sl_manager.py b/tcp_tests/managers/sl_manager.py
index 2f76306..d66ee67 100644
--- a/tcp_tests/managers/sl_manager.py
+++ b/tcp_tests/managers/sl_manager.py
@@ -90,7 +90,7 @@
cmd = ("cd {0}; "
"export VOLUME_STATUS='available'; "
"pytest -k 'not {1}' {2}".format(
- tests_path, skip_tests, test_to_run))
+ tests_path, skip_tests, test_to_run))
else:
cmd = ("cd {0}; "
"export VOLUME_STATUS='available'; "
@@ -112,12 +112,12 @@
cmd = ("cd {0}; "
"export VOLUME_STATUS='available'; "
"pytest --json=report.json -k 'not {1}' {2}".format(
- tests_path, skip_tests, test_to_run))
+ tests_path, skip_tests, test_to_run))
else:
cmd = ("cd {0}; "
"export VOLUME_STATUS='available'; "
"pytest --json=report.json -k {1}".format(
- tests_path, test_to_run))
+ tests_path, test_to_run))
with self.__underlay.remote(node_name=target_node_name[0]) \
as node_remote:
LOG.debug("Run {0} on the node {1}".format(
@@ -165,7 +165,7 @@
prometheus_client = self.api
try:
current_targets = prometheus_client.get_targets()
- except:
+ except Exception:
LOG.info('Restarting keepalived service on mon nodes...')
for node in nodes:
self._salt.local(tgt=node, fun='cmd.run',
diff --git a/tcp_tests/managers/underlay_ssh_manager.py b/tcp_tests/managers/underlay_ssh_manager.py
index ad3e4ad..8b3da06 100644
--- a/tcp_tests/managers/underlay_ssh_manager.py
+++ b/tcp_tests/managers/underlay_ssh_manager.py
@@ -418,27 +418,28 @@
tar_cmd = ('tar --absolute-names'
' --warning=no-file-changed '
'-czf {t} {d}'.format(
- t='{0}_log.tar.gz'.format(artifact_name), d='/var/log'))
+ t='{0}_log.tar.gz'.format(artifact_name), d='/var/log'))
minion_nodes = [ssh for ssh in self.config_ssh
if node_role not in ssh['roles']]
for node in minion_nodes:
try:
with self.remote(host=node['host']) as r_node:
- r_node.check_call(('tar '
- '--absolute-names '
- '--warning=no-file-changed '
- '-czf {t} {d}'.format(
- t='{0}.tar.gz'.format(node['node_name']),
- d='/var/log')),
- verbose=True, raise_on_err=False)
- except:
+ r_node.check_call((
+ 'tar '
+ '--absolute-names '
+ '--warning=no-file-changed '
+ '-czf {t} {d}'.format(
+ t='{0}.tar.gz'.format(node['node_name']),
+ d='/var/log')),
+ verbose=True, raise_on_err=False)
+ except Exception:
LOG.info("Can not ssh for node {}".format(node))
with self.remote(master_node['node_name']) as r:
for node in minion_nodes:
packages_minion_cmd = ("salt '{0}*' cmd.run "
"'dpkg -l' > /var/log/"
"{0}_packages.output".format(
- node['node_name']))
+ node['node_name']))
r.check_call(packages_minion_cmd)
r.check_call("rsync {0}:/root/*.tar.gz "
"/var/log/".format(node['node_name']),