diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2ab134fafb39ba2c4d539f5863065082ec5dd2b..e26aa2fb49ffa0641d9af5f7224e667e656c9415 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,24 @@ +## © 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 : 21-03-2018 +## Created for Project : FLAME + stages: - build - test diff --git a/README.md b/README.md index f12d18fc94d7d85dd6bb512159686252ad4a514d..0d9dbc763b314984cbd9a9e975e27427f6293b0c 100644 --- a/README.md +++ b/README.md @@ -56,14 +56,14 @@ Testing is implemented using pytest. The installation script is here: -`test/services/pytest/install.sh` +`sudo clmctest/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 +* 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 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 @@ -75,7 +75,7 @@ To set up a simulation of the adaptive streaming use case scenario first install and then execute the following command -`vagrant --fixture=streaming-sim -- up` +`vagrant --fixture=monitoring -- up` This will provision the following VMs clmc-service, ipendpoint1, ipendpoint2 @@ -89,7 +89,7 @@ The **clmc-service** vm includes influx, Kapacitor and Chronograf. The following SSH into the CLMC server -`vagrant --fixture=streaming-sim -- ssh clmc-service` +`vagrant --fixture=monitoring -- ssh clmc-service` Then go to the 'vagrant' directory. @@ -99,20 +99,19 @@ The next step is to generate the test data, which could be done in two ways. First option is to run a python script to generate the test data sets -`python3 test/streaming-sim/StreamingSim.py` +`python3 clmctest/monitoring/StreamingSim.py` This script could also be used to clear the generated data by using the '-c' option -`python3 test/streaming-sim/StreamingSim.py -c` +`python3 clmctest/monitoring/StreamingSim.py -c` -The second option is to directly run the testing module, which will detect if the data was generated, and if not, will automatically -generate the data before executing the tests. Keep in mind that if the test data is being generated using this way, a 10 seconds timeout -is given after the generation is finished so that the data could properly be inserted into the database. If the data was already generated -using the first option, only the tests would be executed. +#### Running the monitoring tests -The command for running the testing module is +The second option is to directly run the testing module, which will detect if the data was generated, and if not, will automatically generate the data before executing the tests. Keep in mind that if the test data is being generated using this way, a 10 seconds timeout is given after the generation is finished so that the data could properly be inserted into the database. If the data was already generated using the first option, only the tests would be executed. -`pytest -s test/streaming-sim/test_simresults.py` +The command for running the testing module is: + +`pytest -s clmctest/monitoring/test_simresults.py` The `-s` option in the command is used to output prints used in the test code and is, therefore, optional. @@ -120,4 +119,4 @@ If pytest is not installed, an easy solution is to use the Python Package Index `sudo apt-get install python3-pip` -`pip3 install pytest` +`pip3 install pytest` \ No newline at end of file diff --git a/clmctest/inputs/conftest.py b/clmctest/inputs/conftest.py index aab39c31dc321060faa907d7c8adc3fe9261c704..c3b3b40eb5ee6141e7096d161b591f5e5a43bc19 100644 --- a/clmctest/inputs/conftest.py +++ b/clmctest/inputs/conftest.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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-03-2018 +## Created for Project : FLAME +""" import pytest import time diff --git a/clmctest/inputs/rspec.yml b/clmctest/inputs/rspec.yml index 7200d3d5b356230a6e3e5a47add330ccca1da895..15b245f6b3a4fac0444e2fa7fe185d98a51f372f 100644 --- a/clmctest/inputs/rspec.yml +++ b/clmctest/inputs/rspec.yml @@ -1,3 +1,24 @@ +## © 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 diff --git a/clmctest/inputs/test_rspec.py b/clmctest/inputs/test_rspec.py index 5442eed2d366f64c32e8896f87de02f662e21dae..5658e663b786dc2a13687c8dccbc2a1c1beb2cc7 100644 --- a/clmctest/inputs/test_rspec.py +++ b/clmctest/inputs/test_rspec.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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 : 25-02-2018 +## Created for Project : FLAME +""" from subprocess import run from platform import system diff --git a/clmctest/inputs/test_telegraf_agents.py b/clmctest/inputs/test_telegraf_agents.py index b2e8ce59e229dc1862f200e833e946c6c6272d2e..c465af09179ff78b3636d3eb2c7a0ca896efa7c4 100644 --- a/clmctest/inputs/test_telegraf_agents.py +++ b/clmctest/inputs/test_telegraf_agents.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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-03-2018 +## Created for Project : FLAME +""" import pytest from subprocess import run diff --git a/clmctest/monitoring/LineProtocolGenerator.py b/clmctest/monitoring/LineProtocolGenerator.py index 213e84da0fff40208d621de5597bca3711ba4a7e..76ffd32d28acf86ab201a71a3d56dbc1cbaf8828 100644 --- a/clmctest/monitoring/LineProtocolGenerator.py +++ b/clmctest/monitoring/LineProtocolGenerator.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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 +""" # line protocol @@ -23,23 +45,6 @@ def generate_network_report(recieved_bytes, sent_bytes, time): return result -# Formats VM config -def generate_vm_config(state, cpu, mem, storage, time): - result = [{"measurement": "vm_res_alloc", - "tags": { - "vm_state": state - }, - "fields": { - "cpu": cpu, - "memory": mem, - "storage": storage - }, - "time": _getNSTime(time) - }] - - return result - - # Reports cpu usage, scaling on requests def generate_cpu_report(cpu_usage, cpu_active_time, cpu_idle_time, time): result = [{"measurement": "cpu_usage", @@ -87,60 +92,83 @@ def generate_ipendpoint_route(resource, requests, latency, time): return result -# InfluxDB likes to have time-stamps in nanoseconds -def _getNSTime(time): - # Convert to nano-seconds - timestamp = int(1000000000*time) +def generate_endpoint_config(time, cpu, mem, storage, current_state, current_state_time, **kwargs): + """ + generates a measurement for a VM configuration states - return timestamp + :param cpu: the number of CPUs of VM endpoint + :param mem: memory of VM endpoint + :param storage: storage capacity of VM endpoint + :param current_state: the current state the endpoint is in (TAG) + :param current_state_time: the part of the sampling period the endpoint was in the current state + :param time: time of measurement + :param kwargs: 'python-style' keyword arguments used to store the state as a key and it's respective state period (in seconds) as value -def generate_mc_service_config( mcMeasurement, stateTimeStats, time ): + :return: dictionary object representing the data to post on influx + """ - validStats = validate_state_time_stats( stateTimeStats ) + # lambda function to validate whether a state is given as a key in the keyword arguments dictionary + validate = lambda key: kwargs.get(key) if key in kwargs else 0.0 - result = [{ "measurement" : mcMeasurement, - "fields" : - { "stopped" : validStats['stopped'], - "avg_stopped" : validStats['avg_stopped'], - "starting" : validStats['starting'], - "avg_starting" : validStats['avg_starting'], - "running" : validStats['running'], - "avg_running" : validStats['avg_running'], - "stopping" : validStats['stopping'], - "avg_stopping" : validStats['avg_stopping'] - }, - "time" : _getNSTime(time) }] + # generate and validate the state values + fields = {"cpus": cpu, "memory": mem, "storage": storage, "current_state_time": current_state_time} # NOTE: Do we need the cpus, memory and storage fields ? + for state in ("unplaced", "placing", "placed", "booting", "booted", "connecting", "connected"): + fields["{0}_sum".format(state)] = validate(state) + fields[("{0}_mst".format(state))] = validate("{0}_mst".format(state)) + + result = [{"measurement": "endpoint_config", + "tags": { + "current_state": current_state + }, + "fields": fields, + "time": _getNSTime(time)}] return result -def validate_state_time_stats( stateTimeStats ): +def generate_mc_service_config( time, mcMeasurement, current_state, current_state_time, config_state_values ): + """ + generates a measurement line for a media component configuration state - if ( not 'stopped' in stateTimeStats ): - stateTimeStats['stopped'] = 0.0 + : time - timestamp for the measurement + : mcMeasurement - measurement label + : current_state - the current state of the service configuration + : current_state_time - the current length of time in the current state + : config_state_values - dictionary of media component configuration states (summed time and mean average over the sampling period) + : - stopped, starting, running, stopping [use '_sum' and '_mst' for sum and average respectively] + """ - if ( not 'avg_stopped' in stateTimeStats ): - stateTimeStats['avg_stopped'] = 0.0 - - if ( not 'starting' in stateTimeStats ): - stateTimeStats['starting'] = 0.0 + # define state value validation function (inserting key/0 where key is supplied) + validate_f = lambda key: config_state_values.get(key) if key in config_state_values else 0.0 - if ( not 'avg_starting' in stateTimeStats ): - stateTimeStats['avg_starting'] = 0.0 + # define expected keys + state_keys = [ "stopped_sum", "stopped_mst", + "starting_sum", "starting_mst", + "running_sum", "running_mst", + "stopping_sum", "stopping_mst" ] - if ( not 'running' in stateTimeStats ): - stateTimeStats['running'] = 0.0 + # define current state time first + fields = {} + fields["current_state_time"] = current_state_time - if ( not 'avg_running' in stateTimeStats ): - stateTimeStats['avg_running'] = 0.0 + # then add in validated state values + for key in state_keys : + fields[key] = validate_f(key) - if ( not 'stopping' in stateTimeStats ): - stateTimeStats['stopping'] = 0.0 + # compose result + result = [{ "measurement" : mcMeasurement, + "tags" : { "current_state" : current_state }, + "fields" : fields, + "time" : _getNSTime(time) + }] - if ( not 'avg_stopping' in stateTimeStats ): - stateTimeStats['avg_stopping'] = 0.0 + return result - return stateTimeStats +# InfluxDB likes to have time-stamps in nanoseconds +def _getNSTime(time): + # Convert to nano-seconds + timestamp = int(1000000000*time) + return timestamp # DEPRECATED @@ -153,6 +181,23 @@ def quote_wrap(string): return "\"" + string + "\"" +# Formats VM config +def generate_vm_config(state, cpu, mem, storage, time): + result = [{"measurement": "vm_res_alloc", + "tags": { + "vm_state": state + }, + "fields": { + "cpu": cpu, + "memory": mem, + "storage": storage + }, + "time": _getNSTime(time) + }] + + return result + + def _generateClientRequest(cReq, id, time): # Tags first result = 'sid="' + str(id) + '",' + cReq diff --git a/clmctest/monitoring/StreamingSim.py b/clmctest/monitoring/StreamingSim.py index a7d8d9ce3aa74c4ec5e8be46dd64e36d704e9c85..290cadec1a7b0a3b0e59929478f5f8c920c087de 100644 --- a/clmctest/monitoring/StreamingSim.py +++ b/clmctest/monitoring/StreamingSim.py @@ -1,11 +1,33 @@ #!/usr/bin/python3 +""" +## © 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 +""" import clmctest.monitoring.LineProtocolGenerator as lp import time import urllib.parse -import pytest import random -import sys, getopt +import sys +import getopt from influxdb import InfluxDBClient # Simulation parameters @@ -73,80 +95,166 @@ class Sim(object): 'segment_size': 2, 'video_bit_rate': 80, 'packet_size': 1500} ] - # Simulate configuration of the ipendpoints - # endpoint state->mu, sigma, secs normal distribution - config_delay_dist = {"placing": [10, 0.68], "booting": [10, 0.68], "connecting": [10, 0.68]} + endpoint_states_config = {self.agent1_url: {"current_state": "unplaced", "current_state_time": 0}, + self.agent2_url: {"current_state": "unplaced", "current_state_time": 0}} - # Simulation configuration of the media component (MC) state changes - # "MC state", [average (sec), stddev] - mc_config_delay_dist = { "stopped":[1, 0.68], "starting": [5, 0.68], "running":[1, 0.68], "stopping": [2, 0.68]} + mc_curr_states = { self.agent1_url : { "current_state": "stopped", "current_state_time": 0 }, + self.agent2_url : { "current_state": "stopped", "current_state_time": 0 } } print("\nSimulation started. Generating data...") - # Place endpoints - max_delay = 0 + # Simulate configuration of the ip endpoints + + # Move endpoints from state unplaced to state placing + # reports: 1, unplaced: 0.7s (completed), placing: 0.3s for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_time = self._changeVMState(agent_db_client, sim_time, ip_endpoint, config_delay_dist['placing'][0], - config_delay_dist['placing'][0] * config_delay_dist['placing'][1], - 'placing', 'placed') - max_delay = max(delay_time, max_delay) - sim_time += max_delay + self._changeVMState(agent_db_client, sim_time, ip_endpoint, (("unplaced", 0.7, 1),), 'placing', 0.3) + # report the change of the state in the config dictionary, to keep track of unreported seconds for the current state + endpoint_states_config[agent]["current_state"] = "placing" + endpoint_states_config[agent]["current_state_time"] = 0.3 + sim_time += TICK_TIME - # Boot endpoints - max_delay = 0 + # Place endpoints + # reports: 10 (SAMPLE PERIOD is 1), placing: 9.1s (completed), placed: 0.9s + # addition to uncompleted states from previous report: placing += 0.3s for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_time = self._changeVMState(agent_db_client, sim_time, ip_endpoint, config_delay_dist['booting'][0], - config_delay_dist['booting'][0] * config_delay_dist['booting'][1], - 'booting', 'booted') - max_delay = max(delay_time, max_delay) - sim_time += max_delay - - # move mpegdash_service media component state from 'stopped' to 'starting' - max_delay = 0 + + # since the current state in the dictionary is still placing, only the current state time is incremented + for i in range(9): + endpoint_states_config[agent]["current_state_time"] += TICK_TIME + self._writeVMSingleState(agent_db_client, sim_time + (i * TICK_TIME), ip_endpoint, "placing", endpoint_states_config[agent]["current_state_time"]) + + # here, the VM exits state placing, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time + (9*TICK_TIME), ip_endpoint, (("placing", 0.1 + endpoint_states_config[agent]["current_state_time"], 1),), 'placed', 0.9) + # since VM changed its current state, readjust the config dictionary + endpoint_states_config[agent]["current_state"] = "placed" + endpoint_states_config[agent]["current_state_time"] = 0.9 + sim_time += 10 * TICK_TIME + + # Move endpoints from state placed to state booting + # reports: 1, placed: 0.8s, booting: 0.2s + # addition to uncompleted states from previous report: placed += 0.9s for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_avg = mc_config_delay_dist['stopped'][0] - delay_std = delay_avg * mc_config_delay_dist['stopped'][1] - - delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'stopped', 'starting') - max_delay = max(delay_time, max_delay) - sim_time += max_delay + # here, the VM exits state placed, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time, ip_endpoint, (('placed', 0.8 + endpoint_states_config[agent]["current_state_time"], 1),), 'booting', 0.2) + endpoint_states_config[agent]["current_state"] = "booting" + endpoint_states_config[agent]["current_state_time"] = 0.2 + sim_time += TICK_TIME + + # Boot endpoints + # reports: 10 (SAMPLE PERIOD is 1), booting: 9.4s, booted: 0.6s + # addition to uncompleted states from previous report: booting += 0.2s + for ip_endpoint in ip_endpoints: + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - # move mpegdash_service media component state from 'starting' to 'running' - max_delay = 0 + # since the current state in the dictionary is still booting, only the current state time is incremented + for i in range(9): + endpoint_states_config[agent]["current_state_time"] += TICK_TIME + self._writeVMSingleState(agent_db_client, sim_time + (i * TICK_TIME), ip_endpoint, "booting", endpoint_states_config[agent]["current_state_time"]) + + # here, the VM exits state booting, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time + (9*TICK_TIME), ip_endpoint, (('booting', 0.4 + endpoint_states_config[agent]["current_state_time"], 1),), 'booted', 0.6) + # since VM changed its current state, readjust the config dictionary + endpoint_states_config[agent]["current_state"] = "booted" + endpoint_states_config[agent]["current_state_time"] = 0.6 + sim_time += 10*TICK_TIME + + # Move endpoints from state booted to state connecting + # reports: 2, booted: 1.5s, connecting: 0.5s + # addition to uncompleted states from previous report: booted += 0.6s for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_avg = mc_config_delay_dist['starting'][0] - delay_std = delay_avg * mc_config_delay_dist['starting'][1] - - delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'starting', 'running') - max_delay = max(delay_time, max_delay) - sim_time += max_delay + # since the current state in the dictionary is still booted, only the current state time is incremented + endpoint_states_config[agent]["current_state_time"] += TICK_TIME + self._writeVMSingleState(agent_db_client, sim_time, ip_endpoint, "booted", endpoint_states_config[agent]["current_state_time"]) + + # here, the VM exits state booted, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time + (1 * TICK_TIME), ip_endpoint, (('booted', 0.5 + endpoint_states_config[agent]["current_state_time"], 1),), 'connecting', 0.5) + + # since VM changed its current state, readjust the config dictionary + endpoint_states_config[agent]["current_state"] = "connecting" + endpoint_states_config[agent]["current_state_time"] = 0.5 + sim_time += 2 * TICK_TIME # Connect endpoints - max_delay = 0 + # reports: 10, connecting: 9.7s, connected: 0.3s + # addition to uncompleted states from previous report: connecting += 0.5s for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_time = self._changeVMState(agent_db_client, sim_time, ip_endpoint, config_delay_dist['connecting'][0], - config_delay_dist['connecting'][0] * config_delay_dist['connecting'][1], - 'connecting', 'connected') - max_delay = max(delay_time, max_delay) - sim_time += max_delay + + # since the current state in the dictionary is still connecting, only the current state time is incremented + for i in range(9): + endpoint_states_config[agent]["current_state_time"] += TICK_TIME + self._writeVMSingleState(agent_db_client, sim_time + (i * TICK_TIME), ip_endpoint, "connecting", endpoint_states_config[agent]["current_state_time"]) + + # here, the VM exits state booted, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time + (9 * TICK_TIME), ip_endpoint, (('connecting', 0.7 + endpoint_states_config[agent]["current_state_time"], 1),), + 'connected', 0.3) + # since VM changed its current state, readjust the config dictionary + endpoint_states_config[agent]["current_state"] = "connected" + endpoint_states_config[agent]["current_state_time"] = 0.3 + sim_time += 10 * TICK_TIME + + # move mpegdash media component state from 'stopped' to 'starting' + # Total reports = 1, (completed: 0.2 seconds in 'stopped', current: 0.8 seconds in 'starting') + for ip_endpoint in ip_endpoints: + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + influxClient = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) + + completed_states = ( ('stopped', 0.2, 1 ), ) + mc_curr_states[agent]["current_state"] = 'starting' + mc_curr_states[agent]["current_state_time"] = 0.8 + + self._changeMCState( influxClient, sim_time, 'mpegdash_mc_config', completed_states, 'starting', 0.8 ) + + sim_time += TICK_TIME + + # move mpegdash media component state from 'starting' to 'running' + # Total reports = 5, (4 incomplete 'starting', completed: 0.8 + 4 + 0.7 seconds in 'starting', current: 0.3 seconds in 'running') + for ip_endpoint in ip_endpoints: + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + influxClient = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) + + # 4 seconds of starting + for i in range(0, 4): + mc_curr_states[agent]["current_state"] = 'running' + mc_curr_states[agent]["current_state_time"] += TICK_TIME + self._writeMCSingleState( influxClient, sim_time +(i * TICK_TIME), 'mpegdash_mc_config', 'running', mc_curr_states[agent]["current_state_time"] ) + + # Switch over to running + completed_states = ( ('starting', 0.8 + 4 + 0.7, 1 ), ) + mc_curr_states[agent]["current_state"] = 'running' + mc_curr_states[agent]["current_state_time"] = 0.3 + + self._changeMCState( influxClient, sim_time, 'mpegdash_mc_config', completed_states, 'running', 0.3 ) + + sim_time += 5 * TICK_TIME request_arrival_rate_inc = DEFAULT_REQUEST_RATE_INC inc_period_count = 0 for i in range(simulation_length_seconds): for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) # linear inc to arrival rate @@ -206,40 +314,72 @@ class Sim(object): # remove requests processed off the queue ip_endpoint['request_queue'] -= int(requests_processed) - # update mpegdash_service media component state (continuously 'running') - state_stats = {} - state_stats['running'] = float(TICK_TIME) - state_stats['avg_running'] = float(TICK_TIME) - agent_db_client.write_points(lp.generate_mc_service_config("mpegdash_service_config",state_stats,sim_time)) + # update current state time in the config dictionary + endpoint_states_config[agent]["current_state_time"] += 1 + # update endpoint state (continuously 'connected') + self._writeVMSingleState(agent_db_client, sim_time, ip_endpoint, "connected", endpoint_states_config[agent]["current_state_time"]) + + # update mpegdash media component state (continuously 'running') + mc_curr_states[agent]["current_state"] = 'running' + mc_curr_states[agent]["current_state_time"] += TICK_TIME + + # Just write the current state out here (it will be summed and averaged at the end) + self._writeMCSingleState( agent_db_client, sim_time, 'mpegdash_mc_config', 'running', mc_curr_states[agent]["current_state_time"] ) sim_time += TICK_TIME - # Simulate tear-down of media components - # move mpegdash_service media component state from 'running' to 'stopping' - max_delay = 0 + # Simulate tear-down of media components and endpoints + + # move mpegdash media component state from 'running' to 'stopping' + # Total reports = 2, ( completed: n+1.8 seconds in 'running', current: 0.2 seconds in 'stopping') for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) - agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_avg = mc_config_delay_dist['running'][0] - delay_std = delay_avg * mc_config_delay_dist['running'][1] + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + influxClient = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'running', 'stopping') - max_delay = max(delay_time, max_delay) + completed_states = ( ('running', mc_curr_states[ip_endpoint["agent_url"]]["current_state_time"] +1.8, 1), ) + mc_curr_states[agent]["current_state"] = 'stopping' + mc_curr_states[agent]["current_state_time"] = 0.2 - sim_time += max_delay + self._changeMCState( influxClient, sim_time, 'mpegdash_mc_config', completed_states, 'stopping', 0.2 ) + + sim_time += 2 * TICK_TIME - # move mpegdash_service media component state from 'stopping' to 'stopped' - max_delay = 0 + # move mpegdash media component state from 'stopping' to 'stopped' + # Total reports = 1, (0.9 seconds in 'stopping', 0.1 seconds in 'stopped') for ip_endpoint in ip_endpoints: - agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"]) - agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_avg = mc_config_delay_dist['stopping'][0] - delay_std = delay_avg * mc_config_delay_dist['stopping'][1] + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + influxClient = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) - delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'stopping', 'stopped') - max_delay = max(delay_time, max_delay) + completed_states = ( ('stopping', mc_curr_states[ip_endpoint["agent_url"]]["current_state_time"] +0.9, 1), ) + mc_curr_states[agent]["current_state"] = 'stopped' + mc_curr_states[agent]["current_state_time"] = 0.1 + + self._changeMCState( influxClient, sim_time, 'mpegdash_mc_config', completed_states, 'stopped', 0.1 ) + + sim_time += TICK_TIME + + # remove endpoints + # reports: 5, connected: 4.7s, unplaced: 0.3s + # addition to uncompleted states from previous report: connected += 3600s + 0.3s + for ip_endpoint in ip_endpoints: + agent = ip_endpoint["agent_url"] + agent_url = urllib.parse.urlparse(agent) + agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10) + + # since the current state in the dictionary is still connected, only the current state time is incremented + for i in range(4): + endpoint_states_config[agent]["current_state_time"] += TICK_TIME + self._writeVMSingleState(agent_db_client, sim_time + (i * TICK_TIME), ip_endpoint, "connected", endpoint_states_config[agent]["current_state_time"]) - sim_time += max_delay + # here, the VM exits state connected, hence need to append the current state time + self._changeVMState(agent_db_client, sim_time + (4 * TICK_TIME), ip_endpoint, (('connected', 0.7 + endpoint_states_config[agent]["current_state_time"], 1),), + 'unplaced', 0.3) + # since VM changed its current state, readjust the config dictionary + endpoint_states_config[agent]["current_state"] = "unplaced" + endpoint_states_config[agent]["current_state_time"] = 0.3 + sim_time += 5 * TICK_TIME # End simulation end_time = sim_time @@ -270,58 +410,90 @@ class Sim(object): return response_delay @staticmethod - def _changeVMState(agent_db_client, sim_time, ip_endpoint, mu, sigma, transition_state, next_state): + def _writeVMSingleState(agent_db_client, sim_time, ip_endpoint, current_state, current_state_time): """ - Send influx data to change VM state. Declared as static method since it doesn't need access to any instance variables. - :param sim_time: - :param ip_endpoint: - :param mu: - :param sigma: - :param transition_state: - :param next_state: - :return: the delay time + Write a single state as a sample over TICK_TIME. + + :param agent_db_client: agent used to send metric data to CLMC + :param sim_time: current simulation time + :param ip_endpoint: dict with info for ip endpoint + :param current_state: state that's being reported + :param current_state_time: the current state time """ - agent_db_client.write_points(lp.generate_vm_config(transition_state, ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], sim_time)) + # since no state has been finished, the generate_endpoint_config is called without any keyword arguments (field:value pairs) and only the tags for the current state are set + data = lp.generate_endpoint_config(sim_time, ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], current_state, current_state_time) + agent_db_client.write_points(data) - delay_time = random.normalvariate(mu, sigma) + @staticmethod + def _changeVMState(agent_db_client, sim_time, ip_endpoint, completed_states, next_state, next_state_time): + """ + Send influx data to report change of VM state over the sample period. - agent_db_client.write_points(lp.generate_vm_config(next_state, ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], sim_time + delay_time)) + :param agent_db_client: agent used to send metric data to CLMC + :param sim_time: current simulation time + :param ip_endpoint: endpoint configuration (cpu, memory, storage, etc.) - return delay_time + :param completed_states: states that have been completed + These are the state that have been completed over the sample period (could be more than 1). In terms of data format, a tuple of tuples. + Each completed state is a tuple if format (state, state_period, count), where state is the state's name, period is the total time the VM was in this state and count + is the number of times the VM was in this state (used to derive the average for the sample period. + E.g. ((booting, 5, 2), (booted, 2, 1)) - this is for transitions: booting(3s) -> booted(2s) -> booting(2s) -> booted(1s) + since booted is the last (current state), it is reported only once in the completed states tuple - @staticmethod - def _changeMCState(agent_db_client, sim_time, mc_measurement, mu, sigma, trans_ratio, transition_state, next_state): + :param next_state: name of next state (which is also the current state of the VM) - in the above example this would be booted. + :param next_state_time: the time the VM was in the next state (which is also the current state of the VM) - in the above example this would be 1 second. """ - Send INFLUX data indicating the time taken to transition to a new state - Returns the total time delay for the state change + state_stats = {} + for state, period, count in completed_states: + state_stats[state] = period + state_stats["{0}_mst".format(state)] = float(period/count) + + # transition state and state period are passed to the generate report function as keyword arguments + agent_db_client.write_points(lp.generate_endpoint_config(sim_time, ip_endpoint['cpu'], ip_endpoint['mem'], ip_endpoint['storage'], + next_state, next_state_time, **state_stats)) + + @staticmethod + def _writeMCSingleState(influxClient, sim_time, measurement, curr_state, curr_state_time): """ + Write a single state as a sample over TICK_TIME - # Calculate a randomized total time for the transition (and calculate relative ratios of time in transition and next state) - total_delay_time = max( random.normalvariate(mu, sigma), 1 ) # minimum total delay is 1 second - transition_time = total_delay_time * trans_ratio - next_state_time = total_delay_time - transition_time + : influxClient - agent used to send metric data to CLMC + : sim_time - time stamp for this measurement + : measurement - name of influx measurement set + : curr_state - the current state + : curr_state_time - length of time in the current state + """ - mc_states = {} - - # Report time in transition (and add the same as average) - mc_states[transition_state] = transition_time - mc_states["avg_" +transition_state] = transition_time + influxClient.write_points( lp.generate_mc_service_config(sim_time, measurement, curr_state, curr_state_time, {}) ) - # Report time remaining in the next state (adding the same as the average) - mc_states[next_state] = next_state_time - mc_states["avg_" +next_state] = next_state_time + @staticmethod + def _changeMCState(influxClient, sim_time, measurement, completed_states, curr_state, curr_state_time): + """ + Send INFLUX data indicating the time taken to transition to a new state - agent_db_client.write_points(lp.generate_mc_service_config(mc_measurement, mc_states, sim_time)) + : influxClient - agent used to send metric data to CLMC + : sim_time - simulation time at start of state changing period + : measurement - measurement name + : completed_states - dictionary of states that have been completed (each includes the state name, state time sum and count) + : curr_state - the current state + : curr_state_time - the current state's running time + """ - return total_delay_time + mc_states = {} + for state, state_sum, state_count in completed_states: + mc_states[ state +"_sum" ] = state_sum + mc_states[ state +"_mst" ] = state_sum / state_count + influxClient.write_points( lp.generate_mc_service_config(sim_time, measurement, curr_state, curr_state_time, mc_states) ) def run_simulation(generate=True, sTime=3600): """ - A method which runs the data generation simulator + A method which runs the data generation simulator. + :param generate: True for generating data, False for deleting the DB (optional argument, if not given, default value True is used) + :param sTime: the number of 'seconds' the simulation will run """ global INFLUX_DB_NAME @@ -340,6 +512,7 @@ def run_simulation(generate=True, sTime=3600): else: simulator.db_client.drop_database(simulator.influx_db_name) + if __name__ == "__main__": """ The main entry for this module. Code here is executed only if the StreamingSim.py file is executed, @@ -352,24 +525,24 @@ if __name__ == "__main__": # Try get some options try: - opts, args = getopt.getopt( sys.argv[1:], "c:t:", ['clear','time=']) + opts, args = getopt.getopt(sys.argv[1:], "c:t:", ['clear', 'time=']) except getopt.GetoptError: - print( 'StreamingSim.py -c -t <seconds>' ) + print('StreamingSim.py -c -t <seconds>') sys.exit(2) # Apply options, if any for opt, arg in opts: - if opt in ( '-c','--clear' ): + if opt in ('-c', '--clear'): genOpt = False - elif opt in ('-t','--time'): + elif opt in ('-t', '--time'): simTime = arg - if ( genOpt == True ): - print( "Running simulation to generate data" ) - print( "Time period for this simulation: " + str(simTime) + " seconds" ) + if genOpt: + print("Running simulation to generate data") + print("Time period for this simulation: " + str(simTime) + " seconds") else: - print( "Clearing simulation data" ) + print("Clearing simulation data") - run_simulation( genOpt, simTime ) + run_simulation(genOpt, simTime) diff --git a/clmctest/monitoring/conftest.py b/clmctest/monitoring/conftest.py index b6af171be569615762b0c1a94079ac4c1d441d7b..69389c98a172e75e4600a8baf909a204ecfc9447 100644 --- a/clmctest/monitoring/conftest.py +++ b/clmctest/monitoring/conftest.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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 : 25-02-2018 +## Created for Project : FLAME +""" import pytest import yaml @@ -12,16 +34,16 @@ def streaming_sim_config(): """ Reads the service configuration deployed for the streaming simulation test. - :param request: access the parameters of the fixture :return: the python object representing the read YAML file """ rspec = pkg_resources.resource_filename('clmctest.monitoring', 'rspec.yml') - print("rspec file: {0}".format(rspec)) + print("\nrspec file: {0}".format(rspec)) with open(rspec, 'r') as stream: data_loaded = yaml.load(stream) return data_loaded + @pytest.fixture(params=[{'database': 'CLMCMetrics'}], scope='module') def influx_db(streaming_sim_config, request): """ @@ -34,6 +56,7 @@ def influx_db(streaming_sim_config, request): return InfluxDBClient(host=streaming_sim_config['hosts'][0]['ip_address'], port='8086', database=request.param['database'], timeout=10) + @pytest.fixture(scope="module") def simulator(streaming_sim_config): @@ -42,10 +65,7 @@ def simulator(streaming_sim_config): agent1_url = "http://" + streaming_sim_config['hosts'][1]['ip_address'] + ":8186" agent2_url = "http://" + streaming_sim_config['hosts'][2]['ip_address'] + ":8186" - simulator = Sim( influx_url, influx_db_name, agent1_url, agent2_url ) - - dbs = simulator.db_client.get_list_database() - dbs = [db.get("name") for db in dbs] + simulator = Sim(influx_url, influx_db_name, agent1_url, agent2_url) simulator.reset() diff --git a/clmctest/monitoring/rspec.yml b/clmctest/monitoring/rspec.yml index 7328a2e888d3c79ff176aae5b2bdd1003363045c..f585e2b49a6493668fea99eceed6319fe64bf201 100644 --- a/clmctest/monitoring/rspec.yml +++ b/clmctest/monitoring/rspec.yml @@ -1,3 +1,24 @@ +## © 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 diff --git a/clmctest/monitoring/test_rspec.py b/clmctest/monitoring/test_rspec.py index ecce587eab36aab6873b6c10c1c3924bcee93717..a9bd72884b235315a288ed1a971add4f445c04c8 100644 --- a/clmctest/monitoring/test_rspec.py +++ b/clmctest/monitoring/test_rspec.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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 : 25-02-2018 +## Created for Project : FLAME +""" from subprocess import run from platform import system diff --git a/clmctest/monitoring/test_simresults.py b/clmctest/monitoring/test_simresults.py index 8cac2b8ec825b0d01ef56daaecb5d6aede520994..ce64c922d85ce7f48db29ce4ca75d520d4db8a31 100644 --- a/clmctest/monitoring/test_simresults.py +++ b/clmctest/monitoring/test_simresults.py @@ -1,19 +1,47 @@ #!/usr/bin/python3 +""" +## © 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 : Nikolay Stanchev +## Created Date : 06-03-2018 +## Created for Project : FLAME +""" import pytest import time +import random class TestSimulation(object): """ A testing class used to group all the tests related to the simulation data """ - @pytest.fixture(scope='class') - def run_simulator( self, simulator ): - simulator.run( 3600 ) - - print( "Waiting for INFLUX to finish receiving simulation data..." ) - time.sleep( 10 ) # wait for data to finish arriving at the INFLUX database + + @pytest.fixture(scope='class', autouse=True) + def run_simulator(self, simulator): + random.seed(0) # Seed random function so we can reliably test for average queries + + print("Running simulation, please wait...") + simulator.run(3600) + + print("Waiting for INFLUX to finish receiving simulation data...") + time.sleep(10) # wait for data to finish arriving at the INFLUX database + print( "... simulation data fixture finished" ) @pytest.mark.parametrize("query, expected_result", [ ('SELECT count(*) FROM "CLMCMetrics"."autogen"."cpu_usage"', @@ -24,22 +52,61 @@ class TestSimulation(object): {"time": "1970-01-01T00:00:00Z", "count_avg_response_time": 7200, "count_peak_response_time": 7200, "count_requests": 7200}), ('SELECT count(*) FROM "CLMCMetrics"."autogen"."net_port_io"', {"time": "1970-01-01T00:00:00Z", "count_RX_BYTES_PORT_M": 7200, "count_TX_BYTES_PORT_M": 7200}), - ('SELECT count(*) FROM "CLMCMetrics"."autogen"."vm_res_alloc"', - {"time": "1970-01-01T00:00:00Z", "count_cpu": 12, "count_memory": 12, "count_storage": 12}), - - ('SELECT count(*) FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', - {"time" : "1970-01-01T00:00:00Z", "count_avg_running" : 3604, "count_avg_starting" : 3604, "count_avg_stopped" : 3604, "count_avg_stopping" : 3604, "count_running" : 3604, "count_starting" : 3604, "count_stopped" : 3604, "count_stopping" : 3604}), - ('SELECT count(*) FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', - {"time" : "1970-01-01T00:00:00Z", "count_avg_running" : 3604, "count_avg_starting" : 3604, "count_avg_stopped" : 3604, "count_avg_stopping" : 3604, "count_running" : 3604, "count_starting" : 3604, "count_stopped" : 3604, "count_stopping" : 3604}), + + ('SELECT count(*) FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "count_current_state_time": 3639, "count_unplaced_sum": 3639, "count_unplaced_mst": 3639, "count_placing_sum": 3639, "count_placing_mst": 3639, "count_placed_sum": 3639, "count_placed_mst": 3639, "count_booting_sum": 3639, "count_booting_mst": 3639, "count_booted_sum": 3639, + "count_booted_mst": 3639, "count_connecting_sum": 3639, "count_connecting_mst": 3639, "count_connected_sum": 3639, "count_connected_mst": 3639, "count_cpus": 3639, "count_memory": 3639, "count_storage": 3639}), + ('SELECT count(*) FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "count_current_state_time": 3639, "count_unplaced_sum": 3639, "count_unplaced_mst": 3639, "count_placing_sum": 3639, "count_placing_mst": 3639, "count_placed_sum": 3639, "count_placed_mst": 3639, "count_booting_sum": 3639, "count_booting_mst": 3639, "count_booted_sum": 3639, + "count_booted_mst": 3639, "count_connecting_sum": 3639, "count_connecting_mst": 3639, "count_connected_sum": 3639, "count_connected_mst": 3639, "count_cpus": 3639, "count_memory": 3639, "count_storage": 3639}), + + ('SELECT count(*) FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "count_current_state_time": 3607, "count_running_mst": 3607, "count_running_sum": 3607, "count_starting_mst": 3607, "count_starting_sum": 3607, "count_stopped_mst": 3607, "count_stopped_sum": 3607, "count_stopping_mst": 3607, "count_stopping_sum": 3607}), + ('SELECT count(*) FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "count_current_state_time": 3607, "count_running_mst": 3607, "count_running_sum": 3607, "count_starting_mst": 3607, "count_starting_sum": 3607, "count_stopped_mst": 3607, "count_stopped_sum": 3607, "count_stopping_mst": 3607, "count_stopping_sum": 3607}), + + ('SELECT mean(placing_mst) as "placing_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE placing_mst <> 0 and ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "placing_mst": 9.4}), + ('SELECT mean(booting_mst) as "booting_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE booting_mst <> 0 and ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "booting_mst": 9.6}), + ('SELECT mean(connecting_mst) as "connecting_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE connecting_mst <> 0 and ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "connecting_mst": 10.2}), + ('SELECT mean(connected_mst) as "connected_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE connected_mst <> 0 and ipendpoint=\'endpoint1.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "connected_mst": 3605.0}), + ('SELECT mean(placing_mst) as "placing_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE placing_mst <> 0 and ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "placing_mst": 9.4}), + ('SELECT mean(booting_mst) as "booting_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE booting_mst <> 0 and ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "booting_mst": 9.6}), + ('SELECT mean(connecting_mst) as "connecting_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE connecting_mst <> 0 and ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "connecting_mst": 10.2}), + ('SELECT mean(connected_mst) as "connected_mst" FROM "CLMCMetrics"."autogen"."endpoint_config" WHERE connected_mst <> 0 and ipendpoint=\'endpoint2.ms-A.ict-flame.eu\'', + {"time": "1970-01-01T00:00:00Z", "connected_mst": 3605.0}), + + ('SELECT mean(stopped_sum) as "stopped_sum" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE stopped_sum <> 0', + {"time": "1970-01-01T00:00:00Z", "stopped_sum": 0.2}), + ('SELECT mean(stopped_mst) as "stopped_mst" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE stopped_mst <> 0', + {"time": "1970-01-01T00:00:00Z", "stopped_mst": 0.2}), + ('SELECT mean(starting_sum) as "starting_sum" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE starting_sum <> 0', + {"time": "1970-01-01T00:00:00Z", "starting_sum": 5.5}), + ('SELECT mean(starting_mst) as "starting_mst" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE starting_mst <> 0', + {"time": "1970-01-01T00:00:00Z", "starting_mst": 5.5}), + ('SELECT mean(running_sum) as "running_sum" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE running_sum <> 0', + {"time": "1970-01-01T00:00:00Z", "running_sum": 3602.1000000000004}), + ('SELECT mean(running_mst) as "running_mst" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE running_mst <> 0', + {"time": "1970-01-01T00:00:00Z", "running_mst": 3602.1000000000004}), + ('SELECT mean(stopping_sum) as "stopping_sum" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE stopping_sum <> 0', + {"time": "1970-01-01T00:00:00Z", "stopping_sum": 1.1}), + ('SELECT mean(stopping_mst) as "stopping_mst" FROM "CLMCMetrics"."autogen"."mpegdash_mc_config" WHERE stopping_mst <> 0', + {"time": "1970-01-01T00:00:00Z", "stopping_mst": 1.1}), ]) - def test_simulation( self, run_simulator, influx_db, query, expected_result ): + + def test_simulation(self, influx_db, query, expected_result): """ This is the entry point of the test. This method will be found and executed when the module is ran using pytest :param query: the query to execute (value obtained from the pytest parameter decorator) :param expected_result: the result expected from executing the query (value obtained from the pytest parameter decorator) :param influx_db the import db client fixture - imported from contest.py - :param run_simulation_fixture: the imported fixture to use to generate the testing data - the return value of the fixture is not needed in this case """ # pytest automatically goes through all queries under test, declared in the parameters decorator @@ -51,7 +118,7 @@ class TestSimulation(object): # test the error attribute of the result is None, that is no error is returned from executing the DB query assert query_result.error is None, "An error was encountered while executing query {0}.".format(query) - # get the dictionary of result points; the next() function just gets the first element of the query results iterator (we only expect one item in the iterator) + # get the dictionary of result points; the next() function just gets the first element of the query results generator (we only expect one item in the generator) actual_result = next(query_result.get_points()) assert expected_result == actual_result, "Simulation test failure" diff --git a/clmctest/scripts/rspec.yml b/clmctest/scripts/rspec.yml index a9ca71b117302d17baa1948801cc500b46f2e40a..7812fbe193262e2baf8b3b747a0dfda23e38a288 100644 --- a/clmctest/scripts/rspec.yml +++ b/clmctest/scripts/rspec.yml @@ -1,3 +1,24 @@ +## © 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 : 20-03-2018 +## Created for Project : FLAME + hosts: - name: test-runner cpus: 1 diff --git a/clmctest/scripts/test_config_telegraf.py b/clmctest/scripts/test_config_telegraf.py index 2ae71b896942b6d3db600a077ab4caad6ca37050..72ed589207d0f65d651289bfb8a189f5fd89d59c 100644 --- a/clmctest/scripts/test_config_telegraf.py +++ b/clmctest/scripts/test_config_telegraf.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +## © 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 : 20-03-2018 +## Created for Project : FLAME +""" import pytest import subprocess diff --git a/clmctest/services/apache/telegraf_apache.conf b/clmctest/services/apache/telegraf_apache.conf index dd614108a27146a226b508c8095c6ab1be6eb86d..3a4650b81037cac5b4d7a99290f62ddb87117807 100644 --- a/clmctest/services/apache/telegraf_apache.conf +++ b/clmctest/services/apache/telegraf_apache.conf @@ -1,3 +1,24 @@ +## © 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 : Rowan Powell +## Created Date : 27-02-2018 +## Created for Project : FLAME + [[inputs.apache]] ## An array of URLs to gather from, must be directed at the machine ## readable version of the mod_status page including the auto query string. diff --git a/clmctest/services/ffmpeg/install.sh b/clmctest/services/ffmpeg/install.sh index 02d6e1e3d7394a636b80731ac0c3d8aa5d295e1e..cb3c873afe87ea7ac52651ab8314ab8c7d28486f 100755 --- a/clmctest/services/ffmpeg/install.sh +++ b/clmctest/services/ffmpeg/install.sh @@ -1,4 +1,24 @@ #!/bin/bash +## © 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 : 09-02-2018 +## Created for Project : FLAME apt-get update apt-get -y install zip python diff --git a/clmctest/services/ffmpeg/telegraf_ffmpeg.conf b/clmctest/services/ffmpeg/telegraf_ffmpeg.conf index efe72dc2d05e785c1615f1b6c55794294f630be2..86fa878a160c9dfb78b65b2a68f1e84ba5a61ebd 100644 --- a/clmctest/services/ffmpeg/telegraf_ffmpeg.conf +++ b/clmctest/services/ffmpeg/telegraf_ffmpeg.conf @@ -1,3 +1,24 @@ +## © 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 : 08-03-2018 +## Created for Project : FLAME + # # Influx HTTP write listener [[inputs.http_listener]] ## Address and port to host HTTP listener on diff --git a/clmctest/services/ffmpeg/transcode.sh b/clmctest/services/ffmpeg/transcode.sh index 877472b2be6f55f5ec8a60d9f2b3e41ba57ae301..3645fea34f54430b6aab81d5012bef0d7e241515 100755 --- a/clmctest/services/ffmpeg/transcode.sh +++ b/clmctest/services/ffmpeg/transcode.sh @@ -1,4 +1,25 @@ #!/bin/bash +## © 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 : 09-02-2018 +## Created for Project : FLAME + # # Bento4 must be manually obtained from https://www.bento4.com/downloads/ ffmpeg can be installed as follows # (Debian - http://www.deb-multimedia.org/) ~$ diff --git a/clmctest/services/host/telegraf_host.conf b/clmctest/services/host/telegraf_host.conf index 1fdd33a7b4c8eef188469cd9c94bcef746351ed4..b1fc8ddc55650ade37a074a26ab651d1a6f04c41 100644 --- a/clmctest/services/host/telegraf_host.conf +++ b/clmctest/services/host/telegraf_host.conf @@ -1,3 +1,23 @@ +## © 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 : 20-03-2018 +## Created for Project : FLAME ############################################################################### # INPUTS # diff --git a/clmctest/services/ipendpoint/telegraf_ipendpoint.conf b/clmctest/services/ipendpoint/telegraf_ipendpoint.conf index efe72dc2d05e785c1615f1b6c55794294f630be2..86fa878a160c9dfb78b65b2a68f1e84ba5a61ebd 100644 --- a/clmctest/services/ipendpoint/telegraf_ipendpoint.conf +++ b/clmctest/services/ipendpoint/telegraf_ipendpoint.conf @@ -1,3 +1,24 @@ +## © 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 : 08-03-2018 +## Created for Project : FLAME + # # Influx HTTP write listener [[inputs.http_listener]] ## Address and port to host HTTP listener on diff --git a/clmctest/services/mongo/telegraf_mongo.conf b/clmctest/services/mongo/telegraf_mongo.conf index 80a6a6964394ca33a50e1389121ea142e273bcc2..e80c1a61fa461c861e167a30e87c31b0e103a5c0 100644 --- a/clmctest/services/mongo/telegraf_mongo.conf +++ b/clmctest/services/mongo/telegraf_mongo.conf @@ -1,3 +1,24 @@ +## © 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 : Rowan Powell +## Created Date : 27-02-2018 +## Created for Project : FLAME + [[inputs.mongodb]] ## An array of URLs of the form: ## "mongodb://" [user ":" pass "@"] host [ ":" port] diff --git a/clmctest/services/nginx/nginx.conf b/clmctest/services/nginx/nginx.conf index 1c906bec4096ecd77a0eb8d46c091288841b92d5..5e20c74c7e478f2dadb878ec3b9a8154ee28056d 100644 --- a/clmctest/services/nginx/nginx.conf +++ b/clmctest/services/nginx/nginx.conf @@ -1,4 +1,23 @@ - +## © 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 : Rowan Powell +## Created Date : 27-02-2018 +## Created for Project : FLAME events { worker_connections 4096; ## Default: 1024 diff --git a/clmctest/services/nginx/telegraf_nginx.conf b/clmctest/services/nginx/telegraf_nginx.conf index c91cdeb3265bf703a6438456d12942956938c96d..d6588d5599fb3951f105b2b1d2f056a76c8381c0 100644 --- a/clmctest/services/nginx/telegraf_nginx.conf +++ b/clmctest/services/nginx/telegraf_nginx.conf @@ -1,3 +1,24 @@ +## © 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 : Rowan Powell +## Created Date : 02-02-2018 +## Created for Project : FLAME + # Read Nginx's basic status information (ngx_http_stub_status_module) [[inputs.nginx]] ## An array of Nginx stub_status URI to gather stats. diff --git a/clmctest/streaming/conftest.py b/clmctest/streaming/conftest.py index 8aa64e50f91b5dda288d9fb05a8241320b36b46c..1eb9a2dbfb7998ed67998de242051a520f8ba7d4 100644 --- a/clmctest/streaming/conftest.py +++ b/clmctest/streaming/conftest.py @@ -1,9 +1,34 @@ #!/usr/bin/python3 +""" +## © 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 : 25-02-2018 +## Created for Project : FLAME +""" import pytest import yaml +import requests +import time import pkg_resources + @pytest.fixture(scope="module") def streaming_config(): """ @@ -18,3 +43,16 @@ def streaming_config(): with open(rspec, 'r') as stream: data_loaded = yaml.load(stream) return data_loaded + + +@pytest.fixture(scope="module", autouse=True, + params=[{'config': {'kapacitor_url': 'http://localhost:8888/chronograf/v1/sources/1/kapacitors', 'kapacitor_file': '/vagrant/test/streaming/kapacitor.json'}}]) +def kapacitor_config(request): + + kapacitor_configuration = request.param['config']['kapacitor_file'] + with open(kapacitor_configuration, "r") as rule_file: + data = "".join(line.strip() for line in rule_file.readlines()) + + kapacitor_url = request.param['config']['kapacitor_url'] + requests.post(url=kapacitor_url, data=data, headers={"Content-Type": "application/json"}) + time.sleep(1) diff --git a/clmctest/streaming/kapacitor.conf b/clmctest/streaming/kapacitor.conf index e8332d6297a5ba109fff0a191ff5a50d9ade15fd..7dfb7974600c5c2a8775d5c1d5a0f6caa8d94e87 100644 --- a/clmctest/streaming/kapacitor.conf +++ b/clmctest/streaming/kapacitor.conf @@ -1,3 +1,24 @@ +## © 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 : Simon Crowle +## Created Date : 15-02-2018 +## Created for Project : FLAME + # The hostname of this node. # Must be resolvable by any configured InfluxDB hosts. hostname = "localhost" diff --git a/clmctest/streaming/report.sh b/clmctest/streaming/report.sh index ad1251a7cb908a97b4bb97834fc39c455cabbc5d..0179a1e652f0c61b34788360e0c57129db0ca323 100644 --- a/clmctest/streaming/report.sh +++ b/clmctest/streaming/report.sh @@ -1,4 +1,24 @@ #!/bin/bash +## © 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 : Stephen Phillips +## Created Date : 19-02-2018 +## Created for Project : FLAME # This script reads stdin and expects the output of cvlc. # It is used by the run.sh script and receives the output of the cvlc client. diff --git a/clmctest/streaming/rspec.yml b/clmctest/streaming/rspec.yml index b1291a381c3ca2eb09078958dec0e0f29706a7a3..c340424059185137df158b8dbc19aac60a5fb152 100644 --- a/clmctest/streaming/rspec.yml +++ b/clmctest/streaming/rspec.yml @@ -1,3 +1,24 @@ +## © 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 diff --git a/clmctest/streaming/setupCLMC.sh b/clmctest/streaming/setupCLMC.sh index 6d2bd38390aca17ad2ad89a2debb6d5f89eab794..e7e2fc91b89cef38d690781cac3f1c92ba39a901 100644 --- a/clmctest/streaming/setupCLMC.sh +++ b/clmctest/streaming/setupCLMC.sh @@ -33,18 +33,8 @@ echo $TEST_DIR"/kapacitor.conf" cp $TEST_DIR/kapacitor.conf /etc/kapacitor/kapacitor.conf systemctl start kapacitor -# wait for kapacitor to restart -# TODO: do this better -sleep 5 - # Set up Influx data source curl -i -X POST -H "Content-Type: application/json" http://localhost:8888/chronograf/v1/sources -d @$TEST_DIR/influx.json -# Set up Kapacitor -curl -i -X POST -H "Content-Type: application/json" http://localhost:8888/chronograf/v1/sources/1/kapacitors -d @$TEST_DIR/kapacitor.json - -# Set up rules -curl -i -X POST -H "Content-Type: application/json" http://localhost:9092/kapacitor/v1/tasks -d @$TEST_DIR/rules.json - # Set up dashboard curl -i -X POST -H "Content-Type: application/json" http://localhost:8888/chronograf/v1/dashboards -d @$TEST_DIR/dashboard.json diff --git a/clmctest/streaming/stop.sh b/clmctest/streaming/stop.sh index b332fe3b1d7d1e9ff2e974cb59b036e2252d0bc9..55c8a28389b00dc5dc6e4360ad4b9536106b5d8b 100644 --- a/clmctest/streaming/stop.sh +++ b/clmctest/streaming/stop.sh @@ -1,4 +1,26 @@ #!/bin/bash +""" +// © 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 : 15-02-2018 +// Created for Project : FLAME +""" for pid in $(ps -ef | grep "/usr/bin/vlc" | awk '{print $2}'); do kill -9 $pid; done # TODO: 'killall vlc' should work: need to test though \ No newline at end of file diff --git a/clmctest/streaming/test_rspec.py b/clmctest/streaming/test_rspec.py index 0bbea5403b59178f609661eb2f4fd280822b5b74..b90f5010f8f6b0d18d3389f7e591c98f957c934d 100644 --- a/clmctest/streaming/test_rspec.py +++ b/clmctest/streaming/test_rspec.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +// © 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 : 24-02-2018 +// Created for Project : FLAME +""" from subprocess import run from platform import system diff --git a/clmctest/streaming/test_rule1.json b/clmctest/streaming/test_rule1.json new file mode 100644 index 0000000000000000000000000000000000000000..17d4cdec27f49226968e54cb0f5cb3e794eddd33 --- /dev/null +++ b/clmctest/streaming/test_rule1.json @@ -0,0 +1,9 @@ +{ + "id" : "TestRule1", + "type" : "batch", + "dbrps" : [{"db": "CLMCMetrics", "rp" : "autogen"}], + + "script" : "var ruleData = batch\r\n |query(''' SELECT mean(\"handled\") AS \"mean_handled\" FROM \"CLMCMetrics\".\"autogen\".\"nginx\" WHERE \"ipendpoint\"='adaptive_streaming_I1_nginx1' ''')\r\n .period(5s)\r\n .every(5s)\r\n\r\nvar ruleAlert = ruleData\r\n |alert()\r\n .id('{{ .Name }}\/adaptive_streaming_I1_nginx1')\r\n .message('{{ .ID }} is {{ .Level }} Mean handled connections: {{ index .Fields \"mean_handled\" }}')\r\n .warn(lambda: \"mean_handled\" > 10)\r\n .log( '\/tmp\/TestRule1.log' )", + + "status" : "enabled" +} \ No newline at end of file diff --git a/clmctest/streaming/test_rule2.json b/clmctest/streaming/test_rule2.json new file mode 100644 index 0000000000000000000000000000000000000000..c9adb8401df6662ba14882f3316c84b27e9aa50c --- /dev/null +++ b/clmctest/streaming/test_rule2.json @@ -0,0 +1,9 @@ +{ + "id" : "TestRule2", + "type" : "batch", + "dbrps" : [{"db": "CLMCMetrics", "rp" : "autogen"}], + + "script" : "var ruleData = batch\r\n |query(''' SELECT mean(\"waiting\") AS \"mean_waiting\" FROM \"CLMCMetrics\".\"autogen\".\"nginx\" WHERE \"ipendpoint\"='adaptive_streaming_I1_nginx1' ''')\r\n .period(5s)\r\n .every(5s)\r\n\r\nvar ruleAlert = ruleData\r\n |alert()\r\n .id('{{ .Name }}\/adaptive_streaming_I1_nginx1')\r\n .message('{{ .ID }} is {{ .Level }} Mean waiting connections: {{ index .Fields \"mean_waiting\" }}')\r\n .warn(lambda: \"mean_waiting\" > 10)\r\n .log( '\/tmp\/TestRule2.log' )", + + "status" : "enabled" +} \ No newline at end of file diff --git a/clmctest/streaming/test_streaming.py b/clmctest/streaming/test_streaming.py index c1b7f77190e144a8c77a63c9f83d63e62d1fd1ad..9097b817770e94351695199ef31e87fdde4c2a4e 100644 --- a/clmctest/streaming/test_streaming.py +++ b/clmctest/streaming/test_streaming.py @@ -1,4 +1,26 @@ #!/usr/bin/python3 +""" +// © 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 : 19-03-2018 +// Created for Project : FLAME +""" from threading import Thread from time import sleep @@ -21,6 +43,8 @@ class TestStreamingAlerts(object): @pytest.mark.parametrize("rule, log", [ ("rules.json", "/tmp/RPSLoad.log"), + ("test_rule1.json", "/tmp/TestRule1.log"), + ("test_rule2.json", "/tmp/TestRule2.log"), ]) def test_alerts(self, rule, log, streaming_url, streaming_manifest): """ @@ -38,14 +62,10 @@ class TestStreamingAlerts(object): :param streaming_manifest: the fixture providing the root of the XML streaming manifest """ - kapacitor_setter = self.kapacitor_setting(rule) + kapacitor_setter = self.kapacitor_setting(rule, log) next(kapacitor_setter) # Setup the test rule - try: - if isfile(log): - remove(log) # delete log file if existing from previous tests - except PermissionError: - system("sudo rm {0}".format(log)) # handles the case for running on linux where permission will be required to delete the old log file + print("Testing alert creation for rule: {0}".format(rule)) segments = streaming_manifest.findall(".//{urn:mpeg:DASH:schema:MPD:2011}SegmentURL") @@ -56,9 +76,11 @@ class TestStreamingAlerts(object): t.start() alert_created = False + counter = 0 + time_delay = 2.5 while True: # loop while threads are execution and do a check every 2.5 seconds to check if either alert log has been created or threads have finished execution - sleep(2.5) + sleep(time_delay) if isfile(log): for t in threads: # kill all running threads in case log file is created beforehand t.stop() @@ -67,32 +89,55 @@ class TestStreamingAlerts(object): if threads_queue.full(): break - assert alert_created, "Alerts test failed: no log file is created indicating a triggered alert." + counter += time_delay # the counter tracks the time taken; for the rules under test usually a 30 seconds time frame is enough to trigger the alert + if counter >= 12*time_delay: + for t in threads: # kill all running threads in case of test failure + t.stop() + break + + assert alert_created, "Alerts test failed: no log file is created indicating a triggered alert for rule {0}.".format(rule) - print("\nSuccessfully passed alert creation test.\n") + print("Successfully passed alert creation test for rule: {0}.".format(rule)) next(kapacitor_setter) # Teardown the test rule - def kapacitor_setting(self, rule): + def kapacitor_setting(self, rule, log): """ A generator function used to provide setUp/tearDown actions for a particular kapacitor rule. On setUp rule is initialized, on tearDown rule is deleted. Interleaving is achieved using the generator pattern. :param rule: the name of the json file for the rule under test + :param log: the absolute path of the log file that's being tested """ + # check if the log file is already created due to a previous test + try: + if isfile(log): + remove(log) # delete log file if existing from previous tests + except PermissionError: + system("sudo rm {0}".format(log)) # handles the case for running on linux where permission will be required to delete the old log file + # Initialization of the kapacitor rule - Test setUp (UnitTest style) with open(join(dirname(__file__), rule), "r") as rule_file: data = "".join(line.strip() for line in rule_file.readlines()) rule_data = json.loads(data) requests.delete(url=urljoin(self.kapacitor_url + "/", rule_data.get("id"))) # delete in case of a task with the same ID already set in the kapacitor - requests.post(url=self.kapacitor_url, data=data, headers={"Content-Type": "application/json"}) + r = requests.post(url=self.kapacitor_url, data=data, headers={"Content-Type": "application/json"}) + assert r.status_code == 200, "Couldn't create alert rule {0}".format(rule) + print("\nSuccessfully created test rule {0}".format(rule)) yield # Deleting the kapacitor rule used for testing - Test tearDown (UnitTest style) requests.delete(url=urljoin(self.kapacitor_url + "/", rule_data.get("id"))) + + # check if the log file is created and clean it up + try: + if isfile(log): + remove(log) # delete log file if existing from previous tests + except PermissionError: + system("sudo rm {0}".format(log)) # handles the case for running on linux where permission will be required to delete the old log file yield @staticmethod diff --git a/docs/CLMC monitoring specification for a basic scenario.md b/docs/CLMC monitoring specification for a basic scenario.md index 032d170cbf8278385945eb95208383704ffa3a9a..7bce8245fad97010150e3ebd00bc3c3814532022 100644 --- a/docs/CLMC monitoring specification for a basic scenario.md +++ b/docs/CLMC monitoring specification for a basic scenario.md @@ -1,3 +1,26 @@ +<!-- +// © 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 : Simon Crowle +// Created Date : 10-01-2018 +// Created for Project : FLAME +--> + # Adaptive Streaming Use Case Scenario ## Infrastructure Slice diff --git a/docs/TestScenarios.md b/docs/TestScenarios.md index d9758c908ca1d5bfcde7038eb340a2d06b374923..d40d24a04d3aa62bb01c7a388a585cee0a4dd3b5 100644 --- a/docs/TestScenarios.md +++ b/docs/TestScenarios.md @@ -1,3 +1,26 @@ +<!-- +// © 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 : Rowan Powell +// Created Date : 05-01-2018 +// Created for Project : FLAME +--> + # Test Scenarios |author| diff --git a/docs/adaptive-streaming-usecase-scenario.md b/docs/adaptive-streaming-usecase-scenario.md index 6f77df0e261d7c1db4fd6f543b4a07c1eaf50352..7fc524ab9f768d0f401bdca725a8e1fba0173f7e 100644 --- a/docs/adaptive-streaming-usecase-scenario.md +++ b/docs/adaptive-streaming-usecase-scenario.md @@ -1,3 +1,26 @@ +<!-- +// © 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 : 15-01-2018 +// Created for Project : FLAME +--> + # Adaptive Streaming Use Case Scenario  diff --git a/docs/image/configStateFlow.png b/docs/image/configStateFlow.png new file mode 100644 index 0000000000000000000000000000000000000000..1916e8cac5e9eca7156c1f6fafdbb7fe0805aab7 Binary files /dev/null and b/docs/image/configStateFlow.png differ diff --git a/docs/monitoring.md b/docs/monitoring.md index e116d73a66b5386f1ebdedbf8f68a27299cb43a6..c69733e55b2d0b3b817eed7f6237970a36610d2e 100644 --- a/docs/monitoring.md +++ b/docs/monitoring.md @@ -497,6 +497,150 @@ NAP service request and response metrics tbd +## Configuration status modelling and monitoring + +FLAME _endpoints_ (VMs created and managed by the SFEMC) and media service _media components_ (processes that realise the execution of the media service) both undergo changes in configuration state during the lifetime of a media service's deployment. Observations of these state changes are recorded in the CLMC under named measurement sets, for example 'endpoint_config' and '\<media component name\>_config' for endpoint and media component labels respectively. In each case, all recordable states of the endpoint/media component are enumerated as columns within the measurement set (see respective state models below for details). + +> +> __Side note: a few definitions__ +> +> 'EP' - Endpoint: a VM created and managed by the SFEMC +> +> 'MC' - Media component: a process that realizes a part or the whole of a media service +> +> 'Sampling period' - the time elapsed before Telegraf reports (plugin generated) metrics to the CLMC +> +> 'Completed state' - a state that has been entered into and then exited +> +> 'Current state' - a state that has been entered into but not yet exited +> +> 'MST' - Mean state time: the sum of each time taken by each completed state of type 'X' divided by the number of completed state 'X's; i.e: +> +>```math +> meanStateTime = \frac{\sum(endTimeOfState - startTimeOfState)}{numberOfTimesInState} +>``` +> + +Observation of EP or MC states will be performed by a Telegraf plugin. For example, a Telegraf plugin could periodically __report__ on the state of an NGINX process to the CLMC at a _fixed_ time interval (say 10 seconds). In between these times (the _sampling period_) the Telegraf plugin will sample (or 'poll') the state of the EP or MC several times (say 10 each second). Note that during any sampling period, the EP or MC _may_ transition from one state to another, as a simple example: + + + +_Above: example observations within a four sampling periods for a MC configuration state_ + +In the example provided above a MC moves through several states. During each sampling period, the total time in the observed states is measured and for those that are _completed states_ a sum of all the time and the mean average time for that state is recorded. For any state that has not been observed during the sample period, the sum and average values will be recorded as zero. For a state that has not yet completed, this state will be considered as the 'current state' and the length of time in this state increases and does so continuously, over multiple sample periods if necessary, until it exits. Finally, if a state completes directly after sample period '1' ends and a new state begins before the start of the next sample period '2', then the previous current state (from period '1') should be recorded as _completed_ as part period '2's report. + + +##### Endpoint configuration state model + +An endpoint configuration state model consists of the following states: + +* unplaced +* placing [transitional] +* placed +* booting [transitional] +* booted +* connecting [transitional] +* connected + +A simple example and some measurement rows for an endpoint configuration states is given in the table below. The scenario is the following: + +Each sample period is 1 second. + +First sample period reports the VM being in state __unpalced__ for 0.7s, then changing state to __placing__ for 0.3 seconds. __placing__ is not +reported since it is not a **completed state**. The mean state time value for __unplaced__ is the same as the sum value because the VM has only been once in this state. + +Then the VM is reported to be in current state __placing__ for the whole sample period (1s) for 9 consecutive times. Only the 'current_state' tag value and the 'current_state_time' +field value are filled in the measurement rows, since the VM has not exited its state, yet. + +The last sample period reports the VM exiting state __placing__, then changing state to __placed__. Hence, the __current_state__ tag is set to __placed__. +From the whole sample period (1s), the VM has been 0.9s in state 'placed'. Hence, the __current_state_time__ field is set to 0.9. For the other 0.1s of the sample period, +the VM has been reported to be in state __placing__. Since it has exited state __placing__, the total time spent in this state (9.3s + 0.1s = 9.4s) is reported. +This includes the state time from previous reports. The mean state time value for __placing__ is the same as the sum value because the VM has only been once in this state. + +| global tags | current_state (tag) | current_state_time | unplaced_sum | unplaced_mst | placing_sum | placing_mst | placed_sum | placed_mst | booting_sum | booting_mst | booted_sum | booted_mst | connecting_sum | connecting_mst | connected_sum | connected_mst | time | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | +| ... | placing | 0.3 | 0.7 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 1.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 2.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 3.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 4.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 5.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 6.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 7.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 8.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placing | 9.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | +| ... | placed | 0.9 | 0 | 0 | 9.4 | 9.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... | + + +##### Media component configuration state model + +A media component configuration state model consists of the following states: + +* stopped +* starting [transitional] +* running +* stopping [transitional] + +An example (based on the figure above) of some measurement rows for a media component configuration states is below: + +| global tags | current_state (tag) | current_state_time | stopped_sum | stopped_mst | starting_sum | starting_mst | running_sum | running_mst | stopping_sum | stopping_mst | time | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | +| ... | starting | 3 | 5 | 2.5 | 2 | 2 | 0 | 0 | 0 | 0 | ... | +| ... | running | 8 | 0 | 0 | 5 | 5 | 0 | 0 | 0 | 0 | ... | +| ... | stopped | 5 | 0 | 0 | 0 | 0 | 9 | 9 | 4 | 4 | ... | +| ... | starting | 10 | 5 | 5 | 0 | 0 | 0 | 0 | 0 | 0 | ... | + + +### Example endpoint state configuration queries + + +### Example media component state configuration queries + +In the following examples we illustrate how to calculate _mean time between failures_ (MTBF); _mean time to repair_ (MTTR) and _mean down time_ (MDT) for a media component (in our case, the _mpegdash_ MC) according to definitions found [here](https://en.wikipedia.org/wiki/Mean_time_between_failures). + +_Q. What is the Mean Time Before Failure (MTBF) of media component 'mpegdash'?_ + +``` +select mean(running_mst) as "mpegdash_MTBF(s)" from "mpegdash_mc_config" where running_mst <> 0 +``` + +``` +time mpegdash_MTBF(s) +---- ---------------- +0 3602.1000000000004 +``` + + +_Q. What is the Mean Time to Repair (MTTR) of media component 'mpegdash'?_ + +``` +select mean(starting_mst) as "mpegdash_MTTR(s)" from "mpegdash_mc_config" where starting_mst <> 0 +``` + +``` +name: mpegdash_mc_config +time mpegdash_MTTR(s) +---- ---------------- +0 5.5 +``` + +_Q. What is the Mean Down Time (MTD) of media component 'mpegdash'?_ + +``` +select mean(starting_mst) as "starting_mdt" into "mpegdash_mc_config_mdt" from "mpegdash_mc_config" where starting_mst <> 0 +select mean(stopping_mst) as "stopping_mdt" into "mpegdash_mc_config_mdt" from "mpegdash_mc_config" where stopping_mst <> 0 +select mean(stopped_mst) as "stopped_mdt" into "mpegdash_mc_config_mdt" from "mpegdash_mc_config" where stopped_mst <> 0 +select (starting_mdt + stopping_mdt + stopped_mdt) as "MDT(s)" from "mpegdash_mc_config_mdt" +``` + +``` +name: mpegdash_mc_config_mdt +time MDT(s) +---- ------ +0 6.8 +``` + + ## Media Service Measurements Media service measurements measure the configuration, usage and performance of media service instances deployed by the platform. diff --git a/scripts/build/deleteallvms.sh b/scripts/build/deleteallvms.sh index 4c68a7a733f909b64ddac4610f27a735b7e2d479..be8b957507e754a604bf3e7fad1a80e439d90cf2 100755 --- a/scripts/build/deleteallvms.sh +++ b/scripts/build/deleteallvms.sh @@ -1,4 +1,24 @@ #!/bin/bash +## © University of Southampton IT Innovation Centre, 2017 +## +## 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 : 28-03-2018 +## Created for Project : FLAME vboxmanage list vms | awk ' {print $1} ' | awk -F',' '{gsub(/"/, "", $1); print $1}' > runningvms diff --git a/scripts/clmc-agent/configure_template.sh b/scripts/clmc-agent/configure_template.sh index 04d1229646e57e5d8415ea9addcae315141ca671..2df916b132f6bf760921a2f566e518c44fa82cbb 100644 --- a/scripts/clmc-agent/configure_template.sh +++ b/scripts/clmc-agent/configure_template.sh @@ -19,7 +19,7 @@ #// the software. #// #// Created By : Michael Boniface -#// Created Date : 19/03/2018 +#// Created Date : 18/12/2017 #// Created for Project : FLAME #// #///////////////////////////////////////////////////////////////////////// diff --git a/scripts/clmc-agent/telegraf.conf b/scripts/clmc-agent/telegraf.conf index afe301ea820079c8b47d61d7034d527f2e8ce0d0..180094022dd874009b38e8255dea94393974f75e 100644 --- a/scripts/clmc-agent/telegraf.conf +++ b/scripts/clmc-agent/telegraf.conf @@ -1,3 +1,24 @@ +## © University of Southampton IT Innovation Centre, 2017 +## +## 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 : Simon Crowle +## Created Date : 03-01-2018 +## Created for Project : FLAME + # Telegraf configuration # Telegraf is entirely plugin driven. All metrics are gathered from the diff --git a/scripts/clmc-agent/telegraf_output.conf b/scripts/clmc-agent/telegraf_output.conf index b8e34bc44882b4e2168b23922e471a41cb8d0103..e77f2476c1d3d8ff330580fb5a8b33350041adf8 100644 --- a/scripts/clmc-agent/telegraf_output.conf +++ b/scripts/clmc-agent/telegraf_output.conf @@ -1,3 +1,24 @@ +## © 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 : 08-03-2018 +## Created for Project : FLAME + ############################################################################### # OUTPUTS # ############################################################################### diff --git a/setup.py b/setup.py index 7f18cd7528e77be3153107671db448b9d94cd72b..f015c18db76b0d92b579006a2d5242beb13b62a6 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,26 @@ +""" +// © 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 : 25-03-2018 +// Created for Project : FLAME +""" + import os from setuptools import setup, find_packages