testing.rst 3.3 KB

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