Functional: only copy logs on exception

This patch adds a copy_logs as the handler with unittest's addOnException,
by doing this, we can get logs for all failed cases instead of copy them
before teardown.

If without any failed case, don't copy logs for saving time.

Partially implements: blueprint swarm-functional-testing
Change-Id: I47725d0d16735f650adf325adcf4194eb70c384d
This commit is contained in:
Eli Qiao 2015-12-01 21:32:49 +08:00
parent f3c776b823
commit 229233340e
1 changed files with 5 additions and 1 deletions

View File

@ -47,9 +47,11 @@ if [[ "$COE" == "kubernetes" ]]; then
remote_exec $SSH_USER "sudo journalctl -u kube-controller-manager --no-pager" kube-controller-manager.log
remote_exec $SSH_USER "sudo journalctl -u docker --no-pager" docker.log
remote_exec $SSH_USER "sudo journalctl -u flanneld --no-pager" flanneld.log
remote_exec $SSH_USER "sudo ip a" ipa.log
remote_exec $SSH_USER "sudo netstat -an" netstat.log
elif [[ "$COE" == "swarm" ]]; then
SSH_USER=fedora
remote_exec $SSH_USER "sudo systemctl list-units" systemctl_list_units.log
remote_exec $SSH_USER "sudo systemctl --full list-units" systemctl_list_units.log
remote_exec $SSH_USER "sudo journalctl -u cloud-config --no-pager" cloud-config.log
remote_exec $SSH_USER "sudo journalctl -u cloud-final --no-pager" cloud-final.log
remote_exec $SSH_USER "sudo journalctl -u cloud-init-local --no-pager" cloud-init-local.log
@ -59,6 +61,8 @@ elif [[ "$COE" == "swarm" ]]; then
remote_exec $SSH_USER "sudo journalctl -u swarm-agent --no-pager" swarm-agent.log
remote_exec $SSH_USER "sudo journalctl -u docker --no-pager" docker.log
remote_exec $SSH_USER "sudo journalctl -u flanneld --no-pager" flanneld.log
remote_exec $SSH_USER "sudo ip a" ipa.log
remote_exec $SSH_USER "sudo netstat -an" netstat.log
else
echo "ERROR: Unknown COE '${COE}'"
EXIT_CODE=1