diff --git a/README.md b/README.md index 9ba8e0803839936ed80cd8eac7385c52b68d6306..b0dbab9c9fc4db926b31a0a07c15acc18b1e615c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,24 @@ https://gitlab.it-innovation.soton.ac.uk/mjb/flame-clmc/blob/integration/docs/ad tbd -#### Creating a fixture +#### Testing + +Testing is implemented using pytest. + +The installation script is here: + +`test/services/pytest/install.sh` + +using the following convention: + +* Tests are written in python using pytest +* Related tests are stored in a python module `test/<testmodule>` to create a suite of tests. All tests are stored in files test_*.py, there can be many tests per file, and many files per module +* Each test module has a rspec.yml that provides the baseline "fixture" for the tests in the module +* Tests are executed against fixtures. Fixtures are modular "setups" created for a test, that are inserted into the python code using dependancy injection. This offers more flexibility than the *unit style testing. The baseline deployment is created using `vagrant up` with an appropriate rspec, and the pytest fixture reads the rspec.yml and makes the configuration available to the test. +* Tests are executed from a guest VM (not the host) in the repo root using the command `pytest test/<testmodule>` +* Pytest will scan the directory for all tests including in files test_*.py and run them + +#### Creating a deployment for a test To set up a simualtion of the adaptive streaming use case scenario @@ -64,7 +81,9 @@ The **clmc-service** vm includes influx, Kapacitor and Chronograf. The following * Chronograf: 8888 * Kapacitor: 9092 -#### Running the simulation using the fixture +#### Running the streaming-sim test + +**needs to be updated once we have this in pytest format** SSH into the CLMC server diff --git a/test/streaming-sim/conftest.py b/test/streaming-sim/conftest.py index 5b953a0f97f64478d57fde8bcd96b4cd4d6ac609..16c5ffa37cb65baac8cd6670c5a5a6dfb2422adf 100644 --- a/test/streaming-sim/conftest.py +++ b/test/streaming-sim/conftest.py @@ -1,9 +1,11 @@ import pytest import yaml -@pytest.fixture(scope="module") -def streaming_sim_config(): +@pytest.fixture(scope="module", + params=['test/streaming-sim/rspec.yml']) +def streaming_sim_config(request): """Returns the service configuration deployed for the streaming simulation test. In future this needs to be a parameterised fixture shared with other rspec.yml based tests""" - with open("test/streaming-sim/rspec.yml", 'r') as stream: + print(request.param) + with open(request.param, 'r') as stream: data_loaded = yaml.load(stream) return data_loaded \ No newline at end of file