README.testing 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. Special environment variables
  39. =============================
  40. DESKTOP_LOGLEVEL=<level>
  41. level can be DEBUG, INFO, WARN, ERROR, or CRITICAL
  42. When specified, the console logger is set to the given log level. A console
  43. logger is created if one is not defined.
  44. DESKTOP_DEBUG
  45. A shorthand for DESKTOP_LOG_LEVEL=DEBUG. Also turns on output HTML
  46. validation.
  47. DESKTOP_PROFILE
  48. Turn on Python profiling. The profile data is saved in a file. See the
  49. console output for the location of the file.
  50. DESKTOP_LOG_DIR=<dir>
  51. Specify the HUE log directory. Defaults to ./log.
  52. DESKTOP_DB_CONFIG=<db engine:db name:test db name:username:password:host:port>
  53. Specify alternate DB connection parameters for HUE to use. Useful for
  54. testing your changes against, for example, MySQL instead of sqlite. String
  55. is a colon-delimited list.
  56. Writing tests that depend on Hadoop
  57. ===================================
  58. Use pseudo_hdfs4.py! You should tag such tests with "requires_hadoop", as follows:
  59. from nose.plugins.attrib import attr
  60. @attr('requires_hadoop')
  61. def your_test():
  62. ...
  63. Hudson Configuration
  64. ====================
  65. Because building Hadoop (for the tests that require it) is slow, we've
  66. separated the Hudson builds into "fast" and "slow". Both are run
  67. via scripts/hudson.sh, which should be kept updated with the latest
  68. and greatest in build technologies.
  69. Headless Windmill
  70. =================
  71. Ideally, all you need to do is install xvfb and run "xvfb-run bin/hue test_windmill".
  72. To debug, however, you'll need to be able to check out what's going on. You can run
  73. "xvfb-run bash", followed by "x11vnc", and then connect to your X via VNC from another
  74. machine. This lets you eavesdrop nicely.