From 4c55f10262140aebe15841df4c72fa31c63bd98d Mon Sep 17 00:00:00 2001 From: Derek Schultz Date: Thu, 15 Dec 2016 23:39:47 -0700 Subject: [PATCH] update testing doc --- testing.md | 99 ++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 59 deletions(-) diff --git a/testing.md b/testing.md index 4b2c346..bbbf5bb 100644 --- a/testing.md +++ b/testing.md @@ -1,28 +1,21 @@ -Testing -------- +# Testing -In order to run tests you need to install `Tox`: +## Requirements - $ pip install tox +* Install `Tox` -Also, you will need a running MySQL instance with the database migrations applied from the previous step. -Tests are dependent on pre-created MySQL database for persistence. -Please set env var + $ pip install tox - $ export TEST_DB_URI=mysql://:@:/ +* MySQL instance with database migrations applied (refer to quick start guide) -PEP8 style checks ------------------ + $ export TEST_DB_URI=mysql://:@:/ -In order to run `PEP8` style checks run following command: +### PEP8 style checks $ tox -e pep8 -Functional testing ------------------- - -In order to run `functional` tests run following command: +### Functional testing $ tox -e py35-functional @@ -38,10 +31,9 @@ Cons: * OpenStack authentication is not tested * IronFunctions API stubbed with fake implementation -Integration integrations ------------------------- +### Integration tests -Integration tests are dependent on following env variables: +The following env variables are required: * TEST_DB_URI - similar to functional tests, database endpoint * FUNCTIONS_API_URL - IronFunctions API URL (default value - `http://localhost:8080/v1`) @@ -50,63 +42,52 @@ Integration tests are dependent on following env variables: * OS_USERNAME - OpenStack user name * OS_PASSWORD - OpenStack user user password -To run tests use following command: +```bash +export TEST_DB_URI=mysql://:@:/ +export FUNCTIONS_API_URL=://:/ +export OS_AUTH_URL=://:/ +export OS_PROJECT_NAME= +export OS_USERNAME= +export OS_PASSWORD= +tox -epy35-integration +``` - export TEST_DB_URI=mysql://:@:/ - export FUNCTIONS_API_URL=://:/ - export OS_AUTH_URL=://:/ - export OS_PROJECT_NAME= - export OS_USERNAME= - export OS_PASSWORD= - tox -epy35-integration +### Testing: Docker-build -Testing: Docker-build ---------------------- - -This type of testing allows to ensure if code can be build inside docker container with no problems. -In order to run this check use following commands:: - - export DOCKER_HOST=tcp://:> - export TEST_DB_URI=mysql://:@:/ - export FUNCTIONS_API_URL=://:/ - export OS_AUTH_URL=://:/ - tox -e docker-build - -During this check Tox: +The following operations are performed: * builds an image * deletes all artifacts (Python3.5 image and recently built image) -Testing Docker-full -------------------- +```bash +export DOCKER_HOST=tcp://:> +export TEST_DB_URI=mysql://:@:/ +export FUNCTIONS_API_URL=://:/ +export OS_AUTH_URL=://:/ +tox -e docker-build +``` -This type of testing allows to ensure if code code can be build and run successfully inside docker container with no problems. -In order to run this check use following commands:: +### Testing Docker-full - export DOCKER_HOST=tcp://:> - export TEST_DB_URI=mysql://:@:/ - export FUNCTIONS_API_URL=://:/ - export OS_AUTH_URL=://:/ - tox -e docker-full - -During this check following operations are performed:: +The following operations are performed: * build container from source code * run container with exposed ports * request Swagger API doc to see if API is responsive -* tear-down running container +* destroy running container +```bash +export DOCKER_HOST=tcp://:> +export TEST_DB_URI=mysql://:@:/ +export FUNCTIONS_API_URL=://:/ +export OS_AUTH_URL=://:/ +tox -e docker-full +``` -Coverage regression testing ---------------------------- - -In order to build quality software it is necessary to keep test coverage at its highest point. -So, as part of `Tox` testing new check was added - functional test coverage regression. -In order to run it use following command: +### Coverage regression testing $ tox -e py35-functional-regression -Static code analysis with Bandit -================================ +### Static code analysis with Bandit $ tox -e bandit