]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Retain logs for functional test cases
authorarmando-migliaccio <armamig@gmail.com>
Thu, 3 Sep 2015 00:23:56 +0000 (17:23 -0700)
committerAssaf Muller <amuller@redhat.com>
Thu, 3 Sep 2015 14:50:38 +0000 (10:50 -0400)
This helps greatly the debugging process in face of race conditions.

Change-Id: I74235307183cbb15a7179b18b417b38ffb1d2cc9

neutron/tests/base.py
neutron/tests/contrib/post_test_hook.sh
neutron/tests/fullstack/resources/process.py
neutron/tests/functional/agent/linux/test_ip_lib.py
neutron/tests/functional/agent/test_l3_agent.py
neutron/tests/functional/base.py

index cb5fb3ee66f9077f3b31044ed57ac2612277688f..86f08544f9cdd51f54b81154fd4ef6776c4b756b 100644 (file)
@@ -103,6 +103,11 @@ def get_test_timeout(default=0):
     return int(os.environ.get('OS_TEST_TIMEOUT', 0))
 
 
+def sanitize_log_path(path):
+    # Sanitize the string so that it's log path is shell friendly
+    return path.replace(' ', '-').replace('(', '_').replace(')', '_')
+
+
 class AttributeDict(dict):
 
     """
index efac0d6243f27a063bc73302b6eb7af3c92451bb..c42649b70a091c8acc754a9a7c2d7f15e1d71202 100644 (file)
@@ -8,6 +8,19 @@ SCRIPTS_DIR="/usr/os-testr-env/bin/"
 
 venv=${1:-"dsvm-functional"}
 
+function generate_test_logs {
+    local path="$1"
+    # Compress all $path/*.txt files and move the directories holding those
+    # files to /opt/stack/logs. Files with .log suffix have their
+    # suffix changed to .txt (so browsers will know to open the compressed
+    # files and not download them).
+    if [ -d "$path" ]
+    then
+        sudo find $path -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
+        sudo mv $path/* /opt/stack/logs/
+    fi
+}
+
 function generate_testr_results {
     # Give job user rights to access tox logs
     sudo -H -u $owner chmod o+rw .
@@ -20,13 +33,9 @@ function generate_testr_results {
         sudo mv ./*.gz /opt/stack/logs/
     fi
 
-    # Compress all /tmp/fullstack-*/*.txt files and move the directories
-    # holding those files to /opt/stack/logs. Files with .log suffix have their
-    # suffix changed to .txt (so browsers will know to open the compressed
-    # files and not download them).
-    if [ "$venv" == "dsvm-fullstack" ] && [ -d /tmp/fullstack-logs/ ]; then
-        sudo find /tmp/fullstack-logs -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
-        sudo mv /tmp/fullstack-logs/* /opt/stack/logs/
+    if [ "$venv" == "dsvm-functional" ] || [ "$venv" == "dsvm-fullstack" ]
+    then
+        generate_test_logs "/tmp/${venv}-logs"
     fi
 }
 
index 4414102e21214b9f18111491dd6af6036b6a0cb3..0d6a8bd73f008cc2b71f2883dc3bf90612c57f22 100644 (file)
@@ -29,8 +29,8 @@ from neutron.tests.common import net_helpers
 
 LOG = logging.getLogger(__name__)
 
-# This should correspond the directory from which infra retrieves log files
-DEFAULT_LOG_DIR = '/tmp/fullstack-logs/'
+# This is the directory from which infra fetches log files for fullstack tests
+DEFAULT_LOG_DIR = '/tmp/dsvm-fullstack-logs/'
 
 
 class ProcessFixture(fixtures.Fixture):
index b166b0ec5cc0115a6482fc1df43d15edb7e36876..27e00ef2936cdbd6f3cbb75dac01957f5dee7516 100644 (file)
@@ -42,7 +42,6 @@ class IpLibTestFramework(functional_base.BaseSudoTestCase):
         self._configure()
 
     def _configure(self):
-        config.setup_logging()
         config.register_interface_driver_opts_helper(cfg.CONF)
         cfg.CONF.set_override(
             'interface_driver',
index 8c86a22ac0d46bc33ec2903185b92d80bd1373d2..17b0ee00e9e1456a7da48f6973dda83763141d65 100644 (file)
@@ -81,8 +81,6 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
     def _configure_agent(self, host):
         conf = self._get_config_opts()
         l3_agent_main.register_opts(conf)
-        cfg.CONF.set_override('debug', False)
-        agent_config.setup_logging()
         conf.set_override(
             'interface_driver',
             'neutron.agent.linux.interface.OVSInterfaceDriver')
index ea4997f6f09e37cef95a8e7fae5615aa41866c09..2a489a397f3cc18a84b286a67bb6e626e434e7ac 100644 (file)
@@ -19,11 +19,15 @@ from oslo_config import cfg
 
 from neutron.agent.common import config
 from neutron.agent.linux import utils
+from neutron.common import utils as common_utils
 from neutron.tests import base
 from neutron.tests.common import base as common_base
 
 SUDO_CMD = 'sudo -n'
 
+# This is the directory from which infra fetches log files for functional tests
+DEFAULT_LOG_DIR = '/tmp/dsvm-functional-logs/'
+
 
 class BaseSudoTestCase(base.BaseTestCase):
     """
@@ -48,10 +52,17 @@ class BaseSudoTestCase(base.BaseTestCase):
 
     def setUp(self):
         super(BaseSudoTestCase, self).setUp()
-
         if not base.bool_from_env('OS_SUDO_TESTING'):
             self.skipTest('Testing with sudo is not enabled')
 
+        # Have each test log into its own log file
+        cfg.CONF.set_override('debug', True)
+        common_utils.ensure_dir(DEFAULT_LOG_DIR)
+        log_file = base.sanitize_log_path(
+            os.path.join(DEFAULT_LOG_DIR, "%s.log" % self.id()))
+        cfg.CONF.set_override('log_file', log_file)
+        config.setup_logging()
+
         config.register_root_helper(cfg.CONF)
         self.config(group='AGENT',
                     root_helper=os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD))