You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Mingjiang Shi <ms...@pivotal.io> on 2014/11/12 07:10:52 UTC

Cannot run ambari-agent unittests

Hi There,
I am running the ambari-agent unit tests using the following command under
ambari-agent folder:

mvn clean test

​

I got the following error message:

Traceback (most recent call last):
File “unitTests.py”, line 119, in
main()
File “unitTests.py”, line 86, in main
suite = all





*testssuite() File “unitTests.py”, line 77, in all_tests_suite suite =
unittest.TestLoader().loadTestsFromNames(tests_list) File
“/usr/lib64/python2.6/unittest.py”, line 612, in loadTestsFromNames suites
= [self.loadTestsFromName(name, module) for name in names] File
“/usr/lib64/python2.6/unittest.py”, line 575, in loadTestsFromName module =
__import*(‘.’.join(parts_copy))
File
“/mnt/hgfs/mjshi/workspace/ambari/ambari-agent/src/test/python/resource_management/TestFileSystem.py”,
line 23, in
from resource_management.libraries.functions import file_system
ImportError: cannot import name file_system

After some investigation, I found the env var PYTHONPATH is set in the
file: ambari-common/src/main/unix/ambari-python-wrap as below:

export PYTHONPATH=/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_commons:$PYTHONPATH

If the above line is removed or move the '/usr/lib/....' to the end and all
the tests can run successfully. I suspect the problem is the PYTHONPATH set
in ambari-python-wrap takes precedence than the one set in the pom.xml

So the question is why did the PYTHONPATH was set in this way? Have anyone
see this issue before and how it was resolved? Thanks!
-- 
Cheers
-MJ