Functional: Add prefix when copy logs on failure
It's hard to indentify which node is master and which is slave now, add prefix `master` or `node` to logs directory on functional testing failure. Change-Id: Ida739845d5276d53b037ac32dcb1b72bc717936f
This commit is contained in:
parent
309095c6e3
commit
114c18a9f7
|
@ -101,8 +101,8 @@ class BayTest(base.BaseMagnumTest):
|
||||||
self.bay_uuid = model.uuid
|
self.bay_uuid = model.uuid
|
||||||
self.addOnException(self.copy_logs_handler(
|
self.addOnException(self.copy_logs_handler(
|
||||||
lambda: list(
|
lambda: list(
|
||||||
self._get_bay_by_id(self.bay_uuid)[1].node_addresses +
|
[self._get_bay_by_id(self.bay_uuid)[1].master_addresses,
|
||||||
self._get_bay_by_id(self.bay_uuid)[1].master_addresses),
|
self._get_bay_by_id(self.bay_uuid)[1].node_addresses]),
|
||||||
self.baymodel.coe,
|
self.baymodel.coe,
|
||||||
self.keypair))
|
self.keypair))
|
||||||
self.bay_client.wait_for_created_bay(model.uuid, delete_on_error=False)
|
self.bay_client.wait_for_created_bay(model.uuid, delete_on_error=False)
|
||||||
|
|
|
@ -23,6 +23,9 @@ from magnum.tests.functional.common import config
|
||||||
from magnum.tests.functional.common import manager
|
from magnum.tests.functional.common import manager
|
||||||
|
|
||||||
|
|
||||||
|
COPY_LOG_HELPER = "magnum/tests/contrib/copy_instance_logs.sh"
|
||||||
|
|
||||||
|
|
||||||
class BaseMagnumTest(base.BaseTestCase):
|
class BaseMagnumTest(base.BaseTestCase):
|
||||||
"""Sets up configuration required for functional tests"""
|
"""Sets up configuration required for functional tests"""
|
||||||
|
|
||||||
|
@ -172,7 +175,8 @@ class BaseMagnumTest(base.BaseTestCase):
|
||||||
and copy addresses from there locally.
|
and copy addresses from there locally.
|
||||||
|
|
||||||
:param get_nodes_fn: function that takes no parameters and returns
|
:param get_nodes_fn: function that takes no parameters and returns
|
||||||
a list of node IPs to get logs from
|
a list of node IPs which are in such form:
|
||||||
|
[[master_nodes], [slave_nodes]].
|
||||||
:param coe: the COE type of the nodes
|
:param coe: the COE type of the nodes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -187,28 +191,35 @@ class BaseMagnumTest(base.BaseTestCase):
|
||||||
msg = "Failed to copy logs for bay"
|
msg = "Failed to copy logs for bay"
|
||||||
nodes_addresses = get_nodes_fn()
|
nodes_addresses = get_nodes_fn()
|
||||||
|
|
||||||
for node_address in nodes_addresses:
|
master_nodes = nodes_addresses[0]
|
||||||
log_name = "node-" + func_name
|
slave_nodes = nodes_addresses[1]
|
||||||
try:
|
|
||||||
base_path = os.path.split(os.path.dirname(
|
base_path = os.path.split(os.path.dirname(
|
||||||
os.path.abspath(magnum.__file__)))[0]
|
os.path.abspath(magnum.__file__)))[0]
|
||||||
script = "magnum/tests/contrib/copy_instance_logs.sh"
|
full_location = os.path.join(base_path, COPY_LOG_HELPER)
|
||||||
full_location = os.path.join(base_path, script)
|
|
||||||
cls.LOG.debug("running %s" % full_location)
|
def do_copy_logs(prefix, nodes_address):
|
||||||
cls.LOG.debug("keypair: %s" % keypair)
|
log_name = prefix + "-" + func_name
|
||||||
subprocess.check_call([
|
for node_address in nodes_address:
|
||||||
full_location,
|
try:
|
||||||
node_address,
|
cls.LOG.debug("running %s" % full_location)
|
||||||
coe,
|
cls.LOG.debug("keypair: %s" % keypair)
|
||||||
log_name,
|
subprocess.check_call([
|
||||||
str(keypair)
|
full_location,
|
||||||
])
|
node_address,
|
||||||
except Exception:
|
coe,
|
||||||
cls.LOG.exception(msg)
|
log_name,
|
||||||
cls.LOG.exception("failed to copy from %s to %s%s-%s" %
|
str(keypair)
|
||||||
(node_address,
|
])
|
||||||
"/opt/stack/logs/bay-nodes/",
|
except Exception:
|
||||||
log_name, node_address))
|
cls.LOG.exception(msg)
|
||||||
|
cls.LOG.exception(
|
||||||
|
"failed to copy from %s to %s%s-%s" %
|
||||||
|
(node_address, "/opt/stack/logs/bay-nodes/",
|
||||||
|
log_name, node_address))
|
||||||
|
|
||||||
|
do_copy_logs('master', master_nodes)
|
||||||
|
do_copy_logs('node', slave_nodes)
|
||||||
except Exception:
|
except Exception:
|
||||||
cls.LOG.exception(msg)
|
cls.LOG.exception(msg)
|
||||||
|
|
||||||
|
|
|
@ -248,8 +248,8 @@ extendedKeyUsage = clientAuth
|
||||||
|
|
||||||
self.addOnException(
|
self.addOnException(
|
||||||
self.copy_logs_handler(
|
self.copy_logs_handler(
|
||||||
lambda: list(self.cs.bays.get(self.bay.uuid).node_addresses +
|
lambda: list([self.cs.bays.get(self.bay.uuid).master_addresses,
|
||||||
self.cs.bays.get(self.bay.uuid).master_addresses),
|
self.cs.bays.get(self.bay.uuid).node_addresses]),
|
||||||
self.baymodel.coe,
|
self.baymodel.coe,
|
||||||
'default'))
|
'default'))
|
||||||
self._wait_for_bay_complete(self.bay)
|
self._wait_for_bay_complete(self.bay)
|
||||||
|
|
Loading…
Reference in New Issue