Skip to content
Snippets Groups Projects
user avatar
MJB authored
2842975c
History

FLAME Cross Layer Management and Control

Version: 1.0.0

About this document

Authors

Authors Organisation
Michael Boniface University of Southampton, IT Innovation Centre
Simon Crowle University of Southampton, IT Innovation Centre

Contents

Documentation

Implementation documentation and discussion can be found in the FLAME CLMC Information Model Specification

Development Environment

The development environment is currently Vagrant/Virtualbox providing the infrastructure for dev and testing.

Vagrant-disksize plugin must be installed.

vagrant plugin install vagrant-disksize

Testing

Testing is implemented using pytest using the following convention:

  • Tests are written in python using pytest
  • Related tests are stored in a python module clmctest/<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

Each test has a fixture defining a set of VMs required for the test. The fixture is described in an rspec.yml file that is stored within the clmctest/ directory. For example, the monitoring test fixture is stored in the following file.

clmctest\monitoring\rspec.yml

The fixture is created by running the vagrant up command with the test module name as a parameter

vagrant --fixture=monitoring -- up

This will provision the following VMs clmc-service, ipendpoint1, ipendpoint2

The clmc-service vm includes influx, Kapacitor and Chronograf. The following ports forwarded to the clmc VM from the host machine are as follows:

  • Influx: 8086
  • Chronograf: 8888
  • Kapacitor: 9092

Typically, tests are run from a test-runner VM that has pytest installed. The script used to install pytest is

clmctest/services/pytest/install.sh

To run a test, SSH into the test runner machine

vagrant --fixture=monitoring -- ssh test-runner

Then go to the 'vagrant' directory.

cd /vagrant

Run the pytest.

pytest -s clmctest/monitoring/

Tests run from the host

Tests can be run from the host by sshing commands to the test running. This is described in the .gitlab-ci.yml file. The file shows how a python package is created

python setup.py sdist --dist-dir=build

Then the package is installed

vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 install /vagrant/build/clmctest-SNAPSHOT.tar.gz"

Then the tests are run

vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.scripts"