testing.rst 3.5 KB

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