test.rst 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Running tests
  2. =============
  3. In the spirit of the set library `design goals`_, the aim is to have through
  4. tests for the entire library. This page explains the testing philosopy and
  5. shows how to run the tests locally.
  6. Testing philosophy
  7. ------------------
  8. Our testing goals are to:
  9. 1. Write one set of tests that all provider implementations must pass.
  10. 2. Make that set of tests a 'conformance' test suite, which validates that each
  11. implementation correctly implements the cloudbridge specification.
  12. 3. Make the test suite comprehensive enough that a provider which passes all
  13. the tests can be used safely by an application with no additional testing.
  14. In other words, the cloudbridge specification and accompanying test suite
  15. must be comprehensive enough that no provider specific workarounds, code or testing is required.
  16. 4. For development, mock providers may be used to speed up the feedback cycle,
  17. but providers must also pass the full suite of tests when run against actual
  18. cloud infrastructure to ensure that we are not testing against an idealised
  19. or imagined environment.
  20. 5. Aim for 100% code coverage.
  21. Running tests
  22. -------------
  23. To run the test suite locally:
  24. 1. Install `tox`_ with :code:`pip install tox`
  25. 2. Export all environment variables listed in ``tox.ini`` (under ``passenv``)
  26. 3. Run ``tox`` command
  27. This will run all the tests for all the environments defined in file
  28. ``tox.ini``.
  29. Specific environment
  30. ~~~~~~~~~~~~~~~~~~~~
  31. If you’d like to run the tests on a specific environment only, say Python 2.7,
  32. use a command like this: ``tox -e py27``. Alternativley, to use your default
  33. python, you can also run the test command directly ``python setup.py test``.
  34. Select infrastructure
  35. ~~~~~~~~~~~~~~~~~~~~~
  36. You can also run the tests on a specific cloud only. To do so, export an
  37. environment variable ``CB_TEST_PROVIDER`` and specify the desired provider
  38. name. The available provider names are listed in the `ProviderList`_ class
  39. (e.g., ``aws`` or ``openstack``). Then, run the ``tox`` command.
  40. Using a mock provider
  41. ~~~~~~~~~~~~~~~~~~~~~
  42. Note that running the tests may create various cloud resources, for which you
  43. may incur costs. For the AWS cloud, there is also a mock provider (`moto`_) that
  44. will simulate AWS resources. It is used by default when running the test suite.
  45. You can toggle the use of mock providers by setting an environment variable:
  46. ``CB_USE_MOCK_PROVIDERS`` to ``Yes`` or ``No``.
  47. .. _design goals: https://github.com/galaxyproject/galaxy-cloudman-playbook/
  48. blob/master/README.md
  49. .. _tox: https://tox.readthedocs.org/en/latest/
  50. .. _ProviderList: https://github.com/gvlproject/cloudbridge/blob/master/
  51. cloudbridge/cloud/factory.py#L15
  52. .. _moto: https://github.com/spulec/moto