testing.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. The short story
  2. ===============
  3. Python-based tests:
  4. "build/env/bin/hue test all" runs all the tests.
  5. You should be running that before you push.
  6. Windmill-tests:
  7. build/env/bin/hue test windmill
  8. runs all the windmill tests. It uses port 8999.
  9. build/env/bin/hue runserver_plus
  10. followed by
  11. build/env/bin/windmill -e test=core/src/desktop/windmilltests.py firefox http://localhost:8000/
  12. Jasmine tests (from your browser):
  13. http://localhost:8000/jasmine
  14. Longer story
  15. ============
  16. The ``test`` management command prepares the arguments (test app names)
  17. and passes them to nose (django_nose.nose_runner). Nose will then magically
  18. find all the tests to run.
  19. Tests themselves should be named *_test.py. These will be found
  20. as long as they're in packages covered by django. You can use the
  21. unittest frameworks, or you can just name your method with
  22. the word "test" at a word boundary, and nose will find it.
  23. See apps/hello/src/hello/hello_test.py for an example.
  24. Helpful command-line tricks
  25. ===========================
  26. To run tests that do not depend on Hadoop, use:
  27. build/env/bin/hue test fast
  28. To run all tests, use:
  29. build/env/bin/hue test all
  30. To run only tests of a particular app, use:
  31. build/env/bin/hue test specific <app>
  32. E.g.
  33. build/env/bin/hue test specific filebrowser
  34. To run a specific test, use:
  35. build/env/bin/hue test specific <test_func>
  36. E.g.
  37. build/env/bin/hue test specific useradmin.tests:test_user_admin
  38. Start up pdb on test failures:
  39. build/env/bin/hue test <args> --pdb --pdb-failure -s
  40. Point to an Impalad and trigger the Impala tests:
  41. build/env/bin/hue test impala impalad-01.gethue.com
  42. Special environment variables
  43. =============================
  44. DESKTOP_LOGLEVEL=<level>
  45. level can be DEBUG, INFO, WARN, ERROR, or CRITICAL
  46. When specified, the console logger is set to the given log level. A console
  47. logger is created if one is not defined.
  48. DESKTOP_DEBUG
  49. A shorthand for DESKTOP_LOG_LEVEL=DEBUG. Also turns on output HTML
  50. validation.
  51. DESKTOP_PROFILE
  52. Turn on Python profiling. The profile data is saved in a file. See the
  53. console output for the location of the file.
  54. DESKTOP_LOG_DIR=<dir>
  55. Specify the HUE log directory. Defaults to ./log.
  56. DESKTOP_DB_CONFIG=<db engine:db name:test db name:username:password:host:port>
  57. Specify alternate DB connection parameters for HUE to use. Useful for
  58. testing your changes against, for example, MySQL instead of sqlite. String
  59. is a colon-delimited list.
  60. TEST_IMPALAD_HOST=impalad-01.gethue.com
  61. Point to an Impalad and trigger the Impala tests.
  62. Writing tests that depend on Hadoop
  63. ===================================
  64. Use pseudo_hdfs4.py! You should tag such tests with "requires_hadoop", as follows:
  65. from nose.plugins.attrib import attr
  66. @attr('requires_hadoop')
  67. def your_test():
  68. ...
  69. Hudson Configuration
  70. ====================
  71. Because building Hadoop (for the tests that require it) is slow, we've
  72. separated the Hudson builds into "fast" and "slow". Both are run
  73. via scripts/hudson.sh, which should be kept updated with the latest
  74. and greatest in build technologies.
  75. Headless Windmill
  76. =================
  77. Ideally, all you need to do is install xvfb and run "xvfb-run bin/hue test_windmill".
  78. To debug, however, you'll need to be able to check out what's going on. You can run
  79. "xvfb-run bash", followed by "x11vnc", and then connect to your X via VNC from another
  80. machine. This lets you eavesdrop nicely.