Replace "oslo_utils.importutils" with standard library "importlib" 35/50835/1
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Fri, 19 Jan 2018 11:36:25 +0000 (11:36 +0000)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Fri, 19 Jan 2018 11:41:01 +0000 (11:41 +0000)
commitb0258314501d8df54bfaaf841be8c8326b018601
tree96620ec32bdb326dbfe7b0309576f9d82d276bcb
parentd2c7cc4e9768ed003257a95c92cdb278d516761b
Replace "oslo_utils.importutils" with standard library "importlib"

The current implementation of dynamic library importation is prone
to failure [1]:
- "sys.modules" is modified manually, which is something not
  recommended [2].
- When a module is imported is added to "sys.modules"; that means
  there is no need to manually create an entry in this object.
- "importlib" library is part of the standard library and is now
  available in PY3 and PY2 (backported). This library contains a
  function called "import_module" to import a module in runtime.

[1]https://github.com/opnfv/yardstick/blob/d2c7cc4e9768ed003257a95c92cdb278d516761b/yardstick/common/utils.py#L72-L93
[2]http://justus.science/blog/2015/04/19/sys.modules-is-dangerous.html

JIRA: YARDSTICK-949

Change-Id: Ide3b74f98858d06fa275fb6c9b78ceeaa64feed5
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
yardstick/common/utils.py
yardstick/tests/functional/common/__init__.py [new file with mode: 0644]
yardstick/tests/functional/common/fake_module/__init__.py [new file with mode: 0644]
yardstick/tests/functional/common/fake_module/fake_library.py [new file with mode: 0644]
yardstick/tests/functional/common/test_utils.py [new file with mode: 0644]
yardstick/tests/unit/common/test_utils.py