Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Is there way to run a single Ambari python unit test using mvn test command?

avatar
Contributor

e.g. mvn -Dtest=TestHDP23StackAdvisor test

1 ACCEPTED SOLUTION

avatar
Master Mentor
5 REPLIES 5

avatar
Master Mentor

is there a specific unit test you're referring to? Ambari unit tests are written in Java using JUnit, so you'd use mvn, just like your example. Here's the development guide, https://cwiki.apache.org/confluence/display/AMBARI... and here's latest build reports https://builds.apache.org/job/Ambari-trunk-Commit/... For general python unit testing and running single tests, you can do so by referring to Python docs:

The unittest module can be used from the command line to run tests from modules, classes or even individual test methods:

python -m unittest test_module1 test_module2
python -m unittest test_module.TestClass
python -m unittest test_module.TestClass.test_method

avatar
Contributor

Hi Artem,

Thanks a lot for your input. I was looking to test stack advisor recommendations and validations.

e.g. ambari/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py

avatar
Master Mentor

avatar
Contributor

Thanks again!

Here is what worked for me (using python 2.6.6). Still need to investigate how to run the test from ambari root directory.

$ pip install discover
$ export PYTHONPATH=~/git/ambari/ambari-common/src/test/python
$ cd ~/git/ambari/ambari-server/src/test/python/stacks/2.3/common
$ python -m discover -v
Test that HAWQSTANDBY is not recommended on a single node cluster ... ok
...
----------------------------------------------------------------------
Ran 21 tests in 0.318s
OK

avatar
Expert Contributor

Hi FYI i have used

/git/ambari/ambari-common/src/main/python as oppose to /git/ambari/ambari-common/src/test/python