From 6ffa59c881ea737c3fae658a2fc982d43e769078 Mon Sep 17 00:00:00 2001 From: Mitsuhiko Yamazaki Date: Thu, 11 Apr 2013 13:37:07 +0900 Subject: [PATCH] Add logging configuration The tempest log can help developers analyze tests but there is no option in run_tests.sh to enable logging output now. This adds a logging configuration file and options in run_test.sh and enables developers to get the tempest log more easily. Implements: blueprint add-logging-configuration Change-Id: Iee68a34f5771f1bff88110d95538a5b43103ced9 --- etc/logging.conf.sample | 30 ++++++++++++++++++++++++++++++ run_tests.sh | 16 +++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 etc/logging.conf.sample diff --git a/etc/logging.conf.sample b/etc/logging.conf.sample new file mode 100644 index 0000000000..5c1ea5f66c --- /dev/null +++ b/etc/logging.conf.sample @@ -0,0 +1,30 @@ +[loggers] +keys=root + +[formatters] +keys=normal,debug + +[handlers] +keys=file,devel + +[logger_root] +level=NOTSET +handlers=file + +[handler_file] +class=FileHandler +level=DEBUG +formatter=normal +args=('tempest.log', 'w') + +[handler_devel] +class=StreamHandler +level=DEBUG +formatter=debug +args=(sys.stdout,) + +[formatter_normal] +format=%(asctime)s %(levelname)s %(message)s + +[formatter_debug] +format=%(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s diff --git a/run_tests.sh b/run_tests.sh index 25b9729978..6fcdd9069c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -17,6 +17,8 @@ function usage { echo " -h, --help Print this usage message" echo " -d, --debug Debug this script -- set -o xtrace" echo " -S, --stdout Don't capture stdout" + echo " -l, --logging Enable logging" + echo " -L, --logging-config Logging config file location. Default is etc/logging.conf" echo " -- [NOSEOPTIONS] After the first '--' you can pass arbitrary arguments to nosetests " } @@ -32,8 +34,10 @@ wrapper="" nova_coverage=0 config_file="" update=0 +logging=0 +logging_config=etc/logging.conf -if ! options=$(getopt -o VNnfuswcphdSC: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,whitebox,nova-coverage,pep8,help,debug,stdout,config: -- "$@") +if ! options=$(getopt -o VNnfuswcphdSC:lL: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,whitebox,nova-coverage,pep8,help,debug,stdout,config:,logging,logging-config: -- "$@") then # parse error usage @@ -57,6 +61,8 @@ while [ $# -gt 0 ]; do -s|--smoke) noseargs="$noseargs --attr=type=smoke";; -w|--whitebox) noseargs="$noseargs --attr=type=whitebox";; -S|--stdout) noseargs="$noseargs -s";; + -l|--logging) logging=1;; + -L|--logging-config) logging_config=$2; shift;; --) [ "yes" == "$first_uu" ] || noseargs="$noseargs $1"; first_uu=no ;; *) noseargs="$noseargs $1" esac @@ -78,6 +84,14 @@ export NOSE_OPENSTACK_YELLOW=3.00 export NOSE_OPENSTACK_SHOW_ELAPSED=1 export NOSE_OPENSTACK_STDOUT=1 +if [ $logging -eq 1 ]; then + if [ ! -f "$logging_config" ]; then + echo "No such logging config file: $logging_config" + exit + fi + noseargs="$noseargs --logging-config=$logging_config" +fi + if [ $no_site_packages -eq 1 ]; then installvenvopts="--no-site-packages" fi