diff --git a/README.md b/README.md index 05f8934137f2f05f9519ff0c6b02eb0cda64c205..fb15f05b9043977eec723f107ff5c2f31066ecb7 100644 --- a/README.md +++ b/README.md @@ -37,71 +37,59 @@ #### Documentation -Implementation documentation and discussion can be found in the [FLAME CLMC Information Model Specification](docs/clmc-information-model.md) - -#### 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` +Implementation documentation and discussion can be found in the docs directory. #### Testing Testing is implemented using pytest using the following convention: +* The testing environment is Vagrant/Virtualbox for a base VM with LXC is installed for specific containers. * 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/<testmoduel> 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: +* Related tests are stored in a python module `src/test/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 +* Tests are executed against a set of LXC containers described in `src/test/clmctest/rspec.json`. +* Tests are executed from the test-runner container on the VM using install python modules -* Influx: 8086 -* Chronograf: 8888 -* Kapacitor: 9092 +Here's the instructions -Typically, tests are run from a test-runner VM that has pytest installed. The script used to install pytest is +`vagrant up` -`clmctest/services/pytest/install.sh` +This will create a single VM with LXC installed and configured with lxcbr0 configured for the network 172.40.231.0/24 -To run a test, SSH into the test runner machine +SSH into the VM -`vagrant --fixture=monitoring -- ssh test-runner` +`vagrant ssh` -Then go to the 'vagrant' directory. +Create the services needed for integration tests -`cd /vagrant` +`/vagrant/scripts/test/conts-create.sh` -Run the pytest. +All of the containers created are defined in the file `/vagrant/src/test/clmctest/rspec.json` -`pytest -s clmctest/monitoring/` +Attach to the test-runner -#### Tests run from the host +`lxc-attach -n test-runner` -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 +Here we need to define a make file but for now the commands are manual -`python setup.py sdist --dist-dir=build` +``` +cd /vagrant/src/test +python setup.py sdist --dist-dir=../../build +cd ../../src/service +python setup.py sdist --dist-dir=../../build +pip3 install /vagrant/build/clmctest-SNAPSHOT.tar.gz +pip3 install /vagrant/build/clmcservice-SNAPSHOT.tar.gz +``` -Then the package is installed +The following modules are unit tests -`vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 install /vagrant/build/clmctest-SNAPSHOT.tar.gz"` +``` +pytest -s --pyargs clmctest.scripts +pytest -s --pyargs clmcservice.tests +``` -Then the tests are run +The following modules are integration tests -`vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.scripts"` +``` +pytest -s --pyargs clmctest.monitoring +pytest -s --pyargs clmctest.inputs +``` diff --git a/scripts/test/conts-create.sh b/scripts/test/conts-create.sh index ca3aac39375941c356f69e14b19798aab342b3e6..637d8ba519666e16c9681a2d96903fe3914ec1e9 100644 --- a/scripts/test/conts-create.sh +++ b/scripts/test/conts-create.sh @@ -1,5 +1,6 @@ #!/bin/bash set -eu -o pipefail +cd `dirname $0` source conts-env.sh diff --git a/scripts/test/conts-destroy.sh b/scripts/test/conts-destroy.sh index 9a707149bd224f58cc441108647439afef269f29..29fa36db677fa276edf31c825a9118c2cf6211ac 100644 --- a/scripts/test/conts-destroy.sh +++ b/scripts/test/conts-destroy.sh @@ -1,5 +1,6 @@ #!/bin/bash set -eu -o pipefail +cd `dirname $0` source conts-env.sh diff --git a/scripts/test/conts-start.sh b/scripts/test/conts-start.sh index f15a3a1dc6f457bbd81ea0074b3c9a88a97dacf7..2af56c1a6f3ee7a301bdefd6f9e4fe1ce7487e1e 100644 --- a/scripts/test/conts-start.sh +++ b/scripts/test/conts-start.sh @@ -1,5 +1,6 @@ #!/bin/bash set -eu -o pipefail +cd `dirname $0` source conts-env.sh diff --git a/scripts/test/conts-stop.sh b/scripts/test/conts-stop.sh index 33d89360d8b7254dc4b4f5280b07474d0b78abd4..a64786939ffdbfa2a7916da356d69b3a197c749f 100644 --- a/scripts/test/conts-stop.sh +++ b/scripts/test/conts-stop.sh @@ -1,5 +1,6 @@ #!/bin/bash set -eu -o pipefail +cd `dirname $0` source conts-env.sh diff --git a/src/test/clmctest/e2e_response_time/rspec.yml b/src/test/clmctest/e2e_response_time/rspec.yml deleted file mode 100644 index 4fe3767ddb075e033c3b10acd81a885d73cdc18a..0000000000000000000000000000000000000000 --- a/src/test/clmctest/e2e_response_time/rspec.yml +++ /dev/null @@ -1,56 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - ip_address: "172.40.231.51" - - name: minio - service_name: "minio" - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 9000 - host: 9000 - ip_address: "172.40.231.155" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_minio" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 1 - memory: 2048 - disk: "10GB" - ip_address: "172.40.231.200" diff --git a/src/test/clmctest/inputs/rspec.yml b/src/test/clmctest/inputs/rspec.yml deleted file mode 100644 index 5084b29ebdb308e7c116f9db5827f0c15ff289d0..0000000000000000000000000000000000000000 --- a/src/test/clmctest/inputs/rspec.yml +++ /dev/null @@ -1,147 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - ip_address: "172.40.231.51" - - name: apache - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "apache" - forward_ports: - - guest: 80 - host: 8881 - ip_address: "172.40.231.150" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: nginx - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "nginx" - forward_ports: - - guest: 80 - host: 8882 - ip_address: "172.40.231.151" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_nginx_I1" - ipendpoint_id: "adaptive_streaming_nginx_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: mongo - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "mongo" - forward_ports: - - guest: 80 - host: 8883 - ip_address: "172.40.231.152" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "metadata_database" - sf_id_instance: "metadata_database_I1" - ipendpoint_id: "metadata_database_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: ffmpeg - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ffmpeg" - forward_ports: - - guest: 80 - host: 8884 - ip_address: "172.40.231.153" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "metadata_database" - sf_id_instance: "metadata_database_I1" - ipendpoint_id: "metadata_database_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: host - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "host" - forward_ports: - - guest: 80 - host: 8885 - ip_address: "172.40.231.154" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 2 - memory: 4096 - disk: "10GB" - ip_address: "172.40.231.200" - - name: minio - service_name: "minio" - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 9000 - host: 9000 - ip_address: "172.40.231.155" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_minio" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" \ No newline at end of file diff --git a/src/test/clmctest/inputs/test_rspec.py b/src/test/clmctest/inputs/test_rspec.py index e3e0f6650d30d70e96ce1b13ee704b040795d398..e56bac91e7335a0fcad399dc41f5ac00ae8c1fd5 100644 --- a/src/test/clmctest/inputs/test_rspec.py +++ b/src/test/clmctest/inputs/test_rspec.py @@ -32,7 +32,6 @@ import pytest 'apache', 'nginx', 'mongo', - 'ffmpeg', 'host', 'minio' ]) diff --git a/src/test/clmctest/inputs/test_telegraf_agents.py b/src/test/clmctest/inputs/test_telegraf_agents.py index 65f79ad7f300fb3cecd70221501055d8a968a402..2358d93d6968f83ad7c0712e7dcce25575df638b 100644 --- a/src/test/clmctest/inputs/test_telegraf_agents.py +++ b/src/test/clmctest/inputs/test_telegraf_agents.py @@ -32,7 +32,6 @@ from influxdb import InfluxDBClient ('apache'), ('nginx'), ('mongo'), - ('ffmpeg'), ('host'), ('minio') ]) diff --git a/src/test/clmctest/monitoring/rspec.yml b/src/test/clmctest/monitoring/rspec.yml deleted file mode 100644 index fa5297ab2aca0d58b3c9ecd9b5373c5a3ee3f49e..0000000000000000000000000000000000000000 --- a/src/test/clmctest/monitoring/rspec.yml +++ /dev/null @@ -1,80 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - - guest: 9080 - host: 9080 - ip_address: "172.40.231.51" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - report_period: 25 - - name: ipendpoint1 - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ipendpoint" - forward_ports: - - guest: 80 - host: 8081 - ip_address: "172.40.231.170" - location: "nova" - sfc_id: "media_service_A" - sfc_id_instance: "StackID" - sf_id: "test-sf-clmc-agent-build" - sf_id_instance: "ms-A.ict-flame.eu" - ipendpoint_id: "endpoint1.ms-A.ict-flame.eu" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: ipendpoint2 - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ipendpoint" - forward_ports: - - guest: 80 - host: 8082 - ip_address: "172.40.231.171" - location: "nova" - sfc_id: "media_service_A" - sfc_id_instance: "StackID" - sf_id: "test-sf-clmc-agent-build" - sf_id_instance: "ms-A.ict-flame.eu" - ipendpoint_id: "endpoint2.ms-A.ict-flame.eu" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 1 - memory: 2048 - disk: "10GB" - ip_address: "172.40.231.200" \ No newline at end of file