← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1585149] [NEW] Do not inherit test case classes from regular Neutron classes

 

Public bug reported:

It's a bad practice itself and it may lead to errors during tests
initialization.

Test case classes are initialized during test loading stage by testing
framework. Some neutron classes may not be ready to be created at this
stage, for example those requiring rpc messaging system to be
initialized first. I faced this bug after I added an rpc notifier to
AgentDBMixin: unit tests started failing with:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/obondarev/Neutron/neutron/.tox/py27/lib/python2.7/site-packages/subunit/run.py", line 149, in <module>
    main()
  File "/home/obondarev/Neutron/neutron/.tox/py27/lib/python2.7/site-packages/subunit/run.py", line 145, in main
    stdout=stdout, exit=False)
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/testtools/run.py", line 171, in __init__
    self.parseArgs(argv)
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/main.py", line 113, in parseArgs
    self._do_discovery(argv[2:])
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/testtools/run.py", line 211, in _do_discovery
    super(TestProgram, self)._do_discovery(argv, Loader=Loader)
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/main.py", line 223, in _do_discovery
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 374, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 440, in _find_tests
    for test in path_tests:
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 440, in _find_tests
    for test in path_tests:
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 431, in _find_tests
    full_path, pattern, namespace)
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 487, in _find_test_path
    return self.loadTestsFromModule(module, pattern=pattern), False
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 148, in loadTestsFromModule
    tests.append(self.loadTestsFromTestCase(obj))
  File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 112, in loadTestsFromTestCase
    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
  File "neutron/db/agents_db.py", line 190, in __init__
    resources_rpc.ResourcesPushToServersRpcApi())
  File "neutron/api/rpc/handlers/resources_rpc.py", line 135, in __init__
    self.client = n_rpc.get_client(target)
  File "neutron/common/rpc.py", line 174, in get_client
    assert TRANSPORT is not None
AssertionError

** Affects: neutron
     Importance: Low
     Assignee: Oleg Bondarev (obondarev)
         Status: Confirmed


** Tags: unittest

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1585149

Title:
  Do not inherit test case classes from regular Neutron classes

Status in neutron:
  Confirmed

Bug description:
  It's a bad practice itself and it may lead to errors during tests
  initialization.

  Test case classes are initialized during test loading stage by testing
  framework. Some neutron classes may not be ready to be created at this
  stage, for example those requiring rpc messaging system to be
  initialized first. I faced this bug after I added an rpc notifier to
  AgentDBMixin: unit tests started failing with:

  Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
      "__main__", fname, loader, pkg_name)
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
      exec code in run_globals
    File "/home/obondarev/Neutron/neutron/.tox/py27/lib/python2.7/site-packages/subunit/run.py", line 149, in <module>
      main()
    File "/home/obondarev/Neutron/neutron/.tox/py27/lib/python2.7/site-packages/subunit/run.py", line 145, in main
      stdout=stdout, exit=False)
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/testtools/run.py", line 171, in __init__
      self.parseArgs(argv)
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/main.py", line 113, in parseArgs
      self._do_discovery(argv[2:])
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/testtools/run.py", line 211, in _do_discovery
      super(TestProgram, self)._do_discovery(argv, Loader=Loader)
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/main.py", line 223, in _do_discovery
      self.test = loader.discover(self.start, self.pattern, self.top)
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 374, in discover
      tests = list(self._find_tests(start_dir, pattern))
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 440, in _find_tests
      for test in path_tests:
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 440, in _find_tests
      for test in path_tests:
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 431, in _find_tests
      full_path, pattern, namespace)
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 487, in _find_test_path
      return self.loadTestsFromModule(module, pattern=pattern), False
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 148, in loadTestsFromModule
      tests.append(self.loadTestsFromTestCase(obj))
    File "/home/obondarev/Neutron/neutron/.tox/py27/local/lib/python2.7/site-packages/unittest2/loader.py", line 112, in loadTestsFromTestCase
      loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
    File "neutron/db/agents_db.py", line 190, in __init__
      resources_rpc.ResourcesPushToServersRpcApi())
    File "neutron/api/rpc/handlers/resources_rpc.py", line 135, in __init__
      self.client = n_rpc.get_client(target)
    File "neutron/common/rpc.py", line 174, in get_client
      assert TRANSPORT is not None
  AssertionError

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1585149/+subscriptions


Follow ups