diff --git a/Vagrantfile b/Vagrantfile index c1953901f073417b6d31c7eabd5ac70cfc543560..90ee159e5fe0b55ada9ad20219ab2f5fcd53fa43 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,127 +1,19 @@ -#///////////////////////////////////////////////////////////////////////// -#// -#// (c) 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 : 13/12/2017 -#// Created for Project : FLAME -#// -#///////////////////////////////////////////////////////////////////////// -# Requirements -require 'getoptlong' -require 'yaml' +$lxc_script = <<-SCRIPT -# Custom options: -# --fixture <fixturedir> +sudo apt-get install lxc lxc-templates wget bridge-utils jq -y +sudo lxc-checkconfig -# Set defaults -DEFAULT_FIXTURE = "streaming" +SCRIPT -# Define custom options -opts = GetoptLong.new( - [ '--fixture', GetoptLong::OPTIONAL_ARGUMENT] -) - -# Retrieve custom option values -fixture = DEFAULT_FIXTURE -opts.each do |opt, arg| - case opt - when '--fixture' - fixture = arg - end -end - -# load custom config file -puts "loading custom infrastructure configuration: #{fixture}" -puts "custom config file: /clmctest/#{fixture}/rspec.yml" -host_rspec_file = "clmctest/#{fixture}/rspec.yml" -hosts = YAML.load_file(host_rspec_file) - -# Start creating VMS using xenial64 as the base box Vagrant.configure("2") do |config| config.vm.box = "ubuntu/xenial64" - #config.vm.box = "hashicorp/precise32" - - # Dynamic VMs - hosts['hosts'].each do |host| - #p host["name"] - instance_name = host["name"] - config.vm.define instance_name do |instance_config| - - # Specify VM properties - instance_config.vm.hostname = instance_name - instance_config.disksize.size = host["disk"] - instance_config.vm.provider "virtualbox" do |v| - v.customize ["modifyvm", :id, "--memory", host["memory"]] - v.customize ["modifyvm", :id, "--cpus", host["cpus"]] - end - - # Configure network, not that we only expect 1 test to be running so we have one internal network - instance_config.vm.network :private_network, ip: "#{host["ip_address"]}", virtualbox__intnet: "clmc-net" - - # Port forwarding - puts "Forwarding the following specified ports for #{host["name"]}:" - if host.has_key? 'forward_ports' - host['forward_ports'].each do |port| - puts "Forwarding guest:#{port["guest"]} => host:#{port["host"]}" - instance_config.vm.network "forwarded_port", guest: port["guest"], host: port["host"] - end - end - - # Switch case added here to make clmc-service provisioning simple without having to have a complex rspec.yml file - # We only run a service installation script and the agent installation script when creating a specific service VM, not the clmc-service VM - - puts "Instance name #{instance_name}:" - case instance_name - when 'test-runner' - instance_config.vm.provision :shell, :path => "clmctest/services/pytest/install.sh" - when 'clmc-service' - instance_config.vm.provision :shell, :path => "scripts/clmc-service/install.sh" - else - # specific service install - instance_config.vm.provision :shell, :path => "clmctest/services/#{host["service_name"]}/install.sh", env: {"REPO_ROOT" => "/vagrant"} - - # CLMC agent install - instance_config.vm.provision "file", source: "reporc", destination: "/vagrant/reporc" - instance_config.vm.provision :shell, :path => "scripts/clmc-agent/install.sh", env: {"REPO_ROOT" => "/vagrant"} - - # CLMC agent service specific input configuration - instance_config.vm.provision :shell, inline: <<-SHELL - - cp /vagrant/scripts/clmc-agent/telegraf.conf /etc/telegraf/ - - cp /vagrant/scripts/clmc-agent/telegraf_output.conf /etc/telegraf/telegraf.d/ - - cp /vagrant/clmctest/services/#{host["service_name"]}/telegraf_#{host["service_name"]}.conf /etc/telegraf/telegraf.d/ - - SHELL - - # CLMC agent general and output configuration - #instance_config.vm.provision :shell, :path => "scripts/clmc-agent/configure_template.sh" - - instance_config.vm.provision :shell, :path => "scripts/clmc-agent/configure.sh", :args => "#{host["location"]} #{host["sfc_id"]} #{host["sfc_id_instance"]} #{host["sf_id"]} #{host["sf_id_instance"]} #{host["ipendpoint_id"]} #{host["sr_id"]} #{host["influxdb_url"]} #{host["database_name"]}" + config.vm.provider "virtualbox" do |vb| + vb.cpus = 4 + vb.memory = "8192" + end - # CLMC start agent - instance_config.vm.provision :shell, inline: "service telegraf restart" - end + #config.vm.network "forwarded_port", guest: 80, host: 8080 - - end - end - + # Install docker + config.vm.provision :shell, inline: $lxc_script end diff --git a/clmctest/conts-create.sh b/clmctest/conts-create.sh new file mode 100644 index 0000000000000000000000000000000000000000..f49e376c0c20bcc2487af78e573597f92ff666d6 --- /dev/null +++ b/clmctest/conts-create.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -eu -o pipefail + +rspec_file=rspec.json +service_count=`jq '. | length' ${rspec_file}` +i=0 +while [ $i -lt ${service_count} ]; do + service_name_key=".[${i}].name" + service_name=`jq ${service_name_key} ${rspec_file} | tr -d '"'` + + if ! lxc-info -n ${service_name}; then + echo "Creating container: ${service_name}" + lxc-create -t download -n ${service_name} -- --dist ubuntu --release xenial --arch amd64 + + ip_key=".[${i}].ip_address" + ip=`jq ${ip_key} ${rspec_file} | tr -d '"'` + echo "dhcp-host=${service_name},${ip}" >> /etc/lxc/dnsmasq.conf + + echo "Coping files" + container_dir="/var/lib/lxc/"${service_name}"/rootfs" + container_vagrant_dir=${container_dir}"/vagrant" + + mkdir -p ${container_vagrant_dir} + cp -f /vagrant/reporc "${container_vagrant_dir}" + cp -rf /vagrant/scripts ${container_vagrant_dir} + cp -rf /vagrant/clmctest ${container_vagrant_dir} + + # start the container + lxc-start -n ${service_name} + sleep 4 + + echo "Provisioning: ${service_name}" + if [ ${service_name} == "clmc-service" ] + then + cmd=/vagrant/scripts/clmc-service/install.sh + lxc-attach -n ${service_name} -- ${cmd} + elif [ ${service_name} == "test-runner" ] + then + cmd=/vagrant/clmctest/services/pytest/install.sh + lxc-attach -n ${service_name} -- ${cmd} + else + sf_id_key=".[${i}].sf_id" + sf_id=`jq ${sf_id_key} ${rspec_file} | tr -d '"'` + cmd=/vagrant/clmctest/services/${sf_id}/install.sh + lxc-attach -n ${service_name} -v REPO_ROOT=/vagrant -- ${cmd} + + cmd=/vagrant/scripts/clmc-agent/install.sh + lxc-attach -n ${service_name} -v REPO_ROOT=/vagrant -- ${cmd} + + cp -f /vagrant/scripts/clmc-agent/telegraf.conf ${container_dir}/etc/telegraf/ + cp -f /vagrant/scripts/clmc-agent/telegraf_output.conf ${container_dir}/etc/telegraf/telegraf.d/ + cp /vagrant/clmctest/services/${sf_id}/telegraf_${sf_id}.conf ${container_dir}/etc/telegraf/telegraf.d/ + + cmd=/vagrant/scripts/clmc-agent/configure_template.sh + lxc-attach -n ${service_name} -- ${cmd} + + location_key=".[${i}].location" + location=`jq ${location_key} ${rspec_file} | tr -d '"'` + sfc_id_key=".[${i}].sfc_id" + sfc_id=`jq ${sfc_id_key} ${rspec_file} | tr -d '"'` + sfc_id_instance_key=".[${i}].sfc_id_instance" + sfc_id_instance=`jq ${sfc_id_instance_key} ${rspec_file} | tr -d '"'` + sf_id_key=".[${i}].sf_id" + sf_id=`jq ${sf_id_key} ${rspec_file} | tr -d '"'` + sf_id_instance_key=".[${i}].sf_id_instance" + sf_id_instance=`jq ${sf_id_instance_key} ${rspec_file} | tr -d '"'` + ipendpoint_id_key=".[${i}].ipendpoint_id" + ipendpoint_id=`jq ${ipendpoint_id_key} ${rspec_file} | tr -d '"'` + sr_id_key=".[${i}].sr_id" + sr_id=`jq ${sr_id_key} ${rspec_file} | tr -d '"'` + influxdb_url_key=".[${i}].influxdb_url" + influxdb_url=`jq ${influxdb_url_key} ${rspec_file} | tr -d '"'` + database_name_key=".[${i}].database_name" + database_name=`jq ${database_name_key} ${rspec_file} | tr -d '"'` + + cmd="/vagrant/scripts/clmc-agent/configure.sh ${location} ${sfc_id} ${sfc_id_instance} ${sf_id} ${sf_id_instance} ${ipendpoint_id} ${sr_id} ${influxdb_url} ${database_name}" + + lxc-attach -n ${service_name} -- ${cmd} + + lxc-attach -n ${service_name} -- service telegraf restart + fi + fi + let i=i+1 +done + +./conts-stop.sh + +service lxc-net restart + +./conts-start.sh \ No newline at end of file diff --git a/clmctest/conts-destroy.sh b/clmctest/conts-destroy.sh new file mode 100644 index 0000000000000000000000000000000000000000..779b45831bb7e8a93d6d4741198e3fafc85ebaf9 --- /dev/null +++ b/clmctest/conts-destroy.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +rspec_file=rspec.json +service_count=`jq '. | length' ${rspec_file}` +i=0 +while [ $i -lt ${service_count} ]; do + service_name_key=".[${i}].name" + service_name=`jq ${service_name_key} ${rspec_file} | tr -d '"'` + + if lxc-info -n ${service_name}; then + echo "Stopping container: ${service_name}" + lxc-stop -n ${service_name} + echo "Destroying container: ${service_name}" + lxc-destroy -n ${service_name} + sed -i '/${ip}/d' /etc/lxc/dnsmasq.conf + fi + let i=i+1 +done + \ No newline at end of file diff --git a/clmctest/conts-start.sh b/clmctest/conts-start.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9f55060a2adeaf52d803bcd85f0d7b22f20c17e --- /dev/null +++ b/clmctest/conts-start.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +rspec_file=rspec.json +service_count=`jq '. | length' ${rspec_file}` +i=0 +while [ $i -lt ${service_count} ]; do + service_name_key=".[${i}].name" + service_name=`jq ${service_name_key} ${rspec_file} | tr -d '"'` + + if lxc-info -n ${service_name}; then + echo "Starting container: ${service_name}" + lxc-start -n ${service_name} + fi + let i=i+1 +done + \ No newline at end of file diff --git a/clmctest/conts-stop.sh b/clmctest/conts-stop.sh new file mode 100644 index 0000000000000000000000000000000000000000..13e97d2d2af5f665cb557fae921c07ef4c1d923f --- /dev/null +++ b/clmctest/conts-stop.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +rspec_file=rspec.json +service_count=`jq '. | length' ${rspec_file}` +i=0 +while [ $i -lt ${service_count} ]; do + service_name_key=".[${i}].name" + service_name=`jq ${service_name_key} ${rspec_file} | tr -d '"'` + + if lxc-info -n ${service_name}; then + echo "Stopping container: ${service_name}" + lxc-stop -n ${service_name} + fi + let i=i+1 +done + \ No newline at end of file diff --git a/clmctest/e2e_response_time/rspec.yml b/clmctest/e2e_response_time/rspec.yml deleted file mode 100644 index 4fe3767ddb075e033c3b10acd81a885d73cdc18a..0000000000000000000000000000000000000000 --- a/clmctest/e2e_response_time/rspec.yml +++ /dev/null @@ -1,56 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - ip_address: "172.40.231.51" - - name: minio - service_name: "minio" - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 9000 - host: 9000 - ip_address: "172.40.231.155" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_minio" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 1 - memory: 2048 - disk: "10GB" - ip_address: "172.40.231.200" diff --git a/clmctest/inputs/conftest.py b/clmctest/inputs/conftest.py index c3b3b40eb5ee6141e7096d161b591f5e5a43bc19..1f4294969e27e11d9004f68e11580f7d799ebf58 100644 --- a/clmctest/inputs/conftest.py +++ b/clmctest/inputs/conftest.py @@ -25,6 +25,7 @@ import pytest import time import yaml +import json import pkg_resources from influxdb import InfluxDBClient @@ -37,10 +38,10 @@ def telegraf_agent_config(request): :param request: access the parameters of the fixture :return: the python object representing the read YAML file """ - rspec = pkg_resources.resource_filename('clmctest.inputs', 'rspec.yml') + rspec = pkg_resources.resource_filename('clmctest', 'rspec.json') print("rspec file: {0}".format(rspec)) with open(rspec, 'r') as stream: - data_loaded = yaml.load(stream) + data_loaded = json.load(stream) return data_loaded @@ -54,7 +55,7 @@ def influxdb(telegraf_agent_config, request): :return: the created Influx DB client """ - db = InfluxDBClient(host=telegraf_agent_config['hosts'][0]['ip_address'], port=8086, database=request.param['database'], timeout=10) + db = InfluxDBClient(host=telegraf_agent_config[0]['ip_address'], port=8086, database=request.param['database'], timeout=10) db.drop_database(request.param['database']) # wait 20 seconds for the 1st measurement to arrive from agents before returning diff --git a/clmctest/inputs/rspec.yml b/clmctest/inputs/rspec.yml deleted file mode 100644 index 5084b29ebdb308e7c116f9db5827f0c15ff289d0..0000000000000000000000000000000000000000 --- a/clmctest/inputs/rspec.yml +++ /dev/null @@ -1,147 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - ip_address: "172.40.231.51" - - name: apache - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "apache" - forward_ports: - - guest: 80 - host: 8881 - ip_address: "172.40.231.150" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: nginx - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "nginx" - forward_ports: - - guest: 80 - host: 8882 - ip_address: "172.40.231.151" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_nginx_I1" - ipendpoint_id: "adaptive_streaming_nginx_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: mongo - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "mongo" - forward_ports: - - guest: 80 - host: 8883 - ip_address: "172.40.231.152" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "metadata_database" - sf_id_instance: "metadata_database_I1" - ipendpoint_id: "metadata_database_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: ffmpeg - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ffmpeg" - forward_ports: - - guest: 80 - host: 8884 - ip_address: "172.40.231.153" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "metadata_database" - sf_id_instance: "metadata_database_I1" - ipendpoint_id: "metadata_database_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: host - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "host" - forward_ports: - - guest: 80 - host: 8885 - ip_address: "172.40.231.154" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_apache1" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 2 - memory: 4096 - disk: "10GB" - ip_address: "172.40.231.200" - - name: minio - service_name: "minio" - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 9000 - host: 9000 - ip_address: "172.40.231.155" - location: "DC1" - sfc_id: "MS_Template_1" - sfc_id_instance: "MS_I1" - sf_id: "adaptive_streaming" - sf_id_instance: "adaptive_streaming_I1" - ipendpoint_id: "adaptive_streaming_I1_minio" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" \ No newline at end of file diff --git a/clmctest/inputs/test_config_collector.py b/clmctest/inputs/test_config_collector.py deleted file mode 100644 index ce320b9a7562d2aad1445973724fb59e01de4abe..0000000000000000000000000000000000000000 --- a/clmctest/inputs/test_config_collector.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/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 : 29-04-2018 -## Created for Project : FLAME -""" - -import pytest -import time -import random -import logging -import sys - -from config_collector import ConfigCollector - -STATE_INDEX = 0 -TIME_INDEX = 1 - -samples = [[['active', 0], ['active', 2]], - [['active', 0], ['active', 2], ['active', 4]], - [['active', 0], ['failed', 2]], - [['active', 0], ['active', 2], ['inactive', 4], ['active', 6], ['failed', 8], ['inactive', 10]], - [['active', 0], ['inactive', 2], ['failed', 4], ['active', 6], ['inactive', 8], ['failed', 10]]] - -def get_sample_test(): - global sample_set - global current_index - - sample = (samples[sample_set][current_index][STATE_INDEX], time.time()) - sample_count = len(samples[sample_set]) - if current_index < sample_count-1: - current_index +=1 - else: - current_index = 0 - return sample - -def write_output(measurement): - print("Writing measurement output {0}".format(measurement)) - -sample_set = 0 -current_index = 0 - -def test_agg(): - t = ConfigCollector(get_sample_test, write_output, "resource") - measurement = t.create_measurement(samples[0], 10, 12) - assert measurement[0]['fields']['current_state'] == 'active' - assert measurement[0]['fields']['current_state_time'] == 12 - assert measurement[0]['fields']['active_sum'] == 12 - assert measurement[0]['fields']['active_count'] == 1 - assert measurement[0]['time'] == 12000000000 - - t = ConfigCollector(get_sample_test, write_output, "resource") - measurement = t.create_measurement(samples[1], 10, 14) - assert measurement[0]['fields']['current_state'] == 'active' - assert measurement[0]['fields']['current_state_time'] == 14 - assert measurement[0]['fields']['active_sum'] == 14 - assert measurement[0]['fields']['active_count'] == 1 - assert measurement[0]['time'] == 14000000000 - - t = ConfigCollector(get_sample_test, write_output, "resource") - measurement = t.create_measurement(samples[2], 8, 10) - assert measurement[0]['fields']['current_state'] == 'failed' - assert measurement[0]['fields']['current_state_time'] == 0 - assert measurement[0]['fields']['active_sum'] == 2 - assert measurement[0]['fields']['active_count'] == 1 - assert measurement[0]['fields']['failed_sum'] == 0 - assert measurement[0]['fields']['failed_count'] == 1 - assert measurement[0]['time'] == 10000000000 - - t = ConfigCollector(get_sample_test, write_output, "resource") - measurement = t.create_measurement(samples[3], 2, 12) - assert measurement[0]['fields']['current_state'] == 'inactive' - assert measurement[0]['fields']['current_state_time'] == 0 - assert measurement[0]['fields']['active_sum'] == 6 - assert measurement[0]['fields']['active_count'] == 2 - assert measurement[0]['fields']['inactive_sum'] == 2 - assert measurement[0]['fields']['inactive_count'] == 2 - assert measurement[0]['fields']['failed_sum'] == 2 - assert measurement[0]['fields']['failed_count'] == 1 - assert measurement[0]['time'] == 12000000000 - - t = ConfigCollector(get_sample_test, write_output, "resource") - measurement = t.create_measurement(samples[4], 4, 14) - assert measurement[0]['fields']['current_state'] == 'failed' - assert measurement[0]['fields']['current_state_time'] == 0 - assert measurement[0]['fields']['active_sum'] == 4 - assert measurement[0]['fields']['active_count'] == 2 - assert measurement[0]['fields']['inactive_sum'] == 4 - assert measurement[0]['fields']['inactive_count'] == 2 - assert measurement[0]['fields']['failed_sum'] == 2 - assert measurement[0]['fields']['failed_count'] == 2 - assert measurement[0]['time'] == 14000000000 - -def test_one_period_collection(): - global sample_set - global current_index - - # one measurementing period - sample_set = 1 - current_index = 0 - t = ConfigCollector(get_sample_test, write_output, "resource", 2, 6) - t.start() - time.sleep(8) - t.stop() - print("Current measurement: {0}".format(str(t.current_measurement))) - assert t.current_measurement[0]['fields']['current_state'] == 'active' - assert int(round(t.current_measurement[0]['fields']['current_state_time'])) == 6 - assert int(round(t.current_measurement[0]['fields']['active_sum'])) == 6 - assert int(round(t.current_measurement[0]['fields']['active_count'])) == 1 - -def test_multi_period_single_state_collection(): - global sample_set - global current_index - # two measurementing periods - sample_set = 1 - current_index = 0 - t = ConfigCollector(get_sample_test, write_output, "resource", 1, 3) - t.start() - time.sleep(7) - t.stop() - print("Current measurement: {0}".format(str(t.current_measurement))) - assert t.current_measurement[0]['fields']['current_state'] == 'active' - assert int(round(t.current_measurement[0]['fields']['current_state_time'])) == 6 - assert int(round(t.current_measurement[0]['fields']['active_sum'])) == 6 - assert int(round(t.current_measurement[0]['fields']['active_count'])) == 1 - -# [['active', 0], ['inactive', 2], ['failed', 4], ['active', 6], ['inactive', 8], ['failed', 10]] -def test_multi_period_multi_state_collection(): - global sample_set - global current_index - # 6 samples and 2 measurementing periods - sample_set = 4 - current_index = 0 - t = ConfigCollector(get_sample_test, write_output, "resource", 2, 10) - t.start() - time.sleep(13) - t.stop() - print("Current measurement: {0}".format(str(t.current_measurement))) - assert t.current_measurement[0]['fields']['current_state'] == 'failed' - assert int(round(t.current_measurement[0]['fields']['current_state_time'])) == 0 - assert int(round(t.current_measurement[0]['fields']['active_sum'])) == 4 - assert int(round(t.current_measurement[0]['fields']['active_count'])) == 2 - assert int(round(t.current_measurement[0]['fields']['inactive_sum'])) == 4 - assert int(round(t.current_measurement[0]['fields']['inactive_count'])) == 2 - assert int(round(t.current_measurement[0]['fields']['failed_sum'])) == 2 - assert int(round(t.current_measurement[0]['fields']['failed_count'])) == 2 \ No newline at end of file diff --git a/clmctest/inputs/test_rspec.py b/clmctest/inputs/test_rspec.py index 5658e663b786dc2a13687c8dccbc2a1c1beb2cc7..e3e0f6650d30d70e96ce1b13ee704b040795d398 100644 --- a/clmctest/inputs/test_rspec.py +++ b/clmctest/inputs/test_rspec.py @@ -33,7 +33,8 @@ import pytest 'nginx', 'mongo', 'ffmpeg', - 'host' + 'host', + 'minio' ]) def test_service_name(telegraf_agent_config, service_name): """ @@ -43,7 +44,7 @@ def test_service_name(telegraf_agent_config, service_name): :param service_name the service name to test """ - assert any(s['name'] == service_name for s in telegraf_agent_config['hosts']), "{0} not in list of hosts".format(service_name) + assert any(s['name'] == service_name for s in telegraf_agent_config), "{0} not in list of hosts".format(service_name) print("\nSuccessfully passed configuration test for service name {0}\n".format(service_name)) @@ -59,7 +60,7 @@ def test_ping(telegraf_agent_config): ping_count = 1 system_dependent_param = "-n" if system().lower() == "windows" else "-c" - for service in telegraf_agent_config['hosts']: + for service in telegraf_agent_config: command = ["ping", system_dependent_param, str(ping_count), service['ip_address']] assert run(command).returncode == 0, "Service ping test failed for {0} with ip address {1}".format(service['name'], service['ip_address']) print("\nSuccessfully passed ping test for service: {0}\n".format(service['name'])) diff --git a/clmctest/inputs/test_systemctl_mon.py b/clmctest/inputs/test_systemctl_mon.py deleted file mode 100644 index d57f69e69e9dd68358b5d6ca370f2b15885cca5b..0000000000000000000000000000000000000000 --- a/clmctest/inputs/test_systemctl_mon.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/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 : 29-04-2018 -## Created for Project : FLAME -""" - -import pytest -import time -import random -import logging -import sys - -from systemctl_monitor import SystemctlMonitor - -URL = "localhost" -PORT = "8186" -DATABASE = "CLMCMetrics" - -@pytest.mark.parametrize("service_name", [('nginx')]) -def test_create_measurement(telegraf_agent_config, service_name): - - service = 'unknown' - for s in telegraf_agent_config['hosts']: - if s['name'] == service_name: - service = s - continue - assert service != 'unknown', "{0} not in list of hosts".format(service_name) - - mon = SystemctlMonitor(service_name, 2, 10, service['ip_address'], 8186, service['database_name']) - report = {'time': 1526042434.1773288, 'fields': {'loaded.active.running_sum': 231.85903143882751, 'current_state_time': 231.85903143882751, 'current_state': 'loaded.active.running', 'loaded.active.running_count': 1}} - measurement = mon.create_measurement(report) - assert measurement[0]['tags']['resource_name'] == service_name - assert measurement[0]['fields']['current_state'] == report['fields']['current_state'] - -def test_get_systemctl_status(telegraf_agent_config): - mon = SystemctlMonitor('nginx', 2, 10, URL, PORT, DATABASE) - state = mon.get_systemctl_status('nginx') - assert state == 'loaded.active.running' - -def test_monitor(telegraf_agent_config): - mon = SystemctlMonitor('nginx', 2, 10, URL, PORT, DATABASE) - mon.start() - time.sleep(21) - mon.stop() - measurement = mon.get_current_measurement() - print("Current measurement: {0}".format(str(measurement))) \ No newline at end of file diff --git a/clmctest/inputs/test_telegraf_agents.py b/clmctest/inputs/test_telegraf_agents.py index c041104c0780b25c78d862825c57604bc74b1bcc..65f79ad7f300fb3cecd70221501055d8a968a402 100644 --- a/clmctest/inputs/test_telegraf_agents.py +++ b/clmctest/inputs/test_telegraf_agents.py @@ -37,7 +37,7 @@ from influxdb import InfluxDBClient ('minio') ]) def test_service_name(telegraf_agent_config, service_name): - assert any(s['name'] == service_name for s in telegraf_agent_config['hosts']), "{0} not in list of hosts".format(service_name) + assert any(s['name'] == service_name for s in telegraf_agent_config), "{0} not in list of hosts".format(service_name) def test_ping(telegraf_agent_config): """ @@ -51,7 +51,7 @@ def test_ping(telegraf_agent_config): ping_count = 1 system_dependent_param = "-n" if system().lower() == "windows" else "-c" - for service in telegraf_agent_config['hosts']: + for service in telegraf_agent_config: command = ["ping", system_dependent_param, str(ping_count), service['ip_address']] assert run(command).returncode == 0, "Service ping test failed for {0} with ip address {1}".format(service['name'], service['ip_address']) print("\nSuccessfully passed ping test for service: {0}\n".format(service['name'])) @@ -63,7 +63,6 @@ def test_ping(telegraf_agent_config): ('mongodb', 'SELECT mean("net_in_bytes") AS "mean" FROM "CLMCMetrics"."autogen"."mongodb"', 0), ('net', 'SELECT mean("bytes_sent") AS "mean" FROM "CLMCMetrics"."autogen"."net"', 0), ('disk', 'SELECT mean("free") AS "mean" FROM "CLMCMetrics"."autogen"."disk"', 0), - ('diskio', 'SELECT mean("write_bytes") AS "mean" FROM "CLMCMetrics"."autogen"."diskio"', 0), ('mem', 'SELECT mean("free") AS "mean" FROM "CLMCMetrics"."autogen"."mem"', 0), # Report MINIO's HTTP request response time (as a rolling difference of the sum total) ('minio_http_requests_duration_seconds', 'SELECT difference(max("sum")) AS "mean" FROM "CLMCMetrics"."autogen"."minio_http_requests_duration_seconds" WHERE time > now() - 1h GROUP BY time(10s)',0), diff --git a/clmctest/monitoring/conftest.py b/clmctest/monitoring/conftest.py index 69389c98a172e75e4600a8baf909a204ecfc9447..d00695ef5f77d5730112649d997d37ff6525e88f 100644 --- a/clmctest/monitoring/conftest.py +++ b/clmctest/monitoring/conftest.py @@ -23,7 +23,7 @@ """ import pytest -import yaml +import json import pkg_resources from influxdb import InfluxDBClient from clmctest.monitoring.StreamingSim import Sim @@ -36,11 +36,11 @@ def streaming_sim_config(): :return: the python object representing the read YAML file """ - rspec = pkg_resources.resource_filename('clmctest.monitoring', 'rspec.yml') + rspec = pkg_resources.resource_filename('clmctest', 'rspec.json') print("\nrspec file: {0}".format(rspec)) with open(rspec, 'r') as stream: - data_loaded = yaml.load(stream) + data_loaded = json.load(stream) return data_loaded @@ -54,16 +54,20 @@ def influx_db(streaming_sim_config, request): :return: the created Influx DB client """ - return InfluxDBClient(host=streaming_sim_config['hosts'][0]['ip_address'], port='8086', database=request.param['database'], timeout=10) + return InfluxDBClient(host=streaming_sim_config[0]['ip_address'], port='8086', database=request.param['database'], timeout=10) @pytest.fixture(scope="module") def simulator(streaming_sim_config): - influx_url = "http://" + streaming_sim_config['hosts'][0]['ip_address'] + ":8086" - influx_db_name = streaming_sim_config['hosts'][1]['database_name'] - agent1_url = "http://" + streaming_sim_config['hosts'][1]['ip_address'] + ":8186" - agent2_url = "http://" + streaming_sim_config['hosts'][2]['ip_address'] + ":8186" + influx_url = "http://" + streaming_sim_config[0]['ip_address'] + ":8086" + + for service in streaming_sim_config: + if service['name'] == "ipendpoint1": + influx_db_name = service['database_name'] + agent1_url = "http://" + service['ip_address'] + ":8186" + elif service['name'] == "ipendpoint2": + agent2_url = "http://" + service['ip_address'] + ":8186" simulator = Sim(influx_url, influx_db_name, agent1_url, agent2_url) diff --git a/clmctest/monitoring/rspec.yml b/clmctest/monitoring/rspec.yml deleted file mode 100644 index 43fd381b410f406dfd4f323218f26aaad230d2fa..0000000000000000000000000000000000000000 --- a/clmctest/monitoring/rspec.yml +++ /dev/null @@ -1,75 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 02-02-2018 -## Created for Project : FLAME - -hosts: - - name: clmc-service - cpus: 1 - memory: 2048 - disk: "10GB" - forward_ports: - - guest: 8086 - host: 8086 - - guest: 8888 - host: 8888 - - guest: 9092 - host: 9092 - ip_address: "172.40.231.51" - - name: ipendpoint1 - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ipendpoint" - forward_ports: - - guest: 80 - host: 8081 - ip_address: "172.40.231.170" - location: "nova" - sfc_id: "media_service_A" - sfc_id_instance: "StackID" - sf_id: "test-sf-clmc-agent-build" - sf_id_instance: "ms-A.ict-flame.eu" - ipendpoint_id: "endpoint1.ms-A.ict-flame.eu" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: ipendpoint2 - cpus: 1 - memory: 2048 - disk: "10GB" - service_name: "ipendpoint" - forward_ports: - - guest: 80 - host: 8082 - ip_address: "172.40.231.171" - location: "nova" - sfc_id: "media_service_A" - sfc_id_instance: "StackID" - sf_id: "test-sf-clmc-agent-build" - sf_id_instance: "ms-A.ict-flame.eu" - ipendpoint_id: "endpoint2.ms-A.ict-flame.eu" - sr_id: "service_router" - influxdb_url: "http://172.40.231.51:8086" - database_name: "CLMCMetrics" - - name: test-runner - cpus: 1 - memory: 2048 - disk: "10GB" - ip_address: "172.40.231.200" \ No newline at end of file diff --git a/clmctest/monitoring/test_rspec.py b/clmctest/monitoring/test_rspec.py index a9bd72884b235315a288ed1a971add4f445c04c8..999b98c4e8ee6c57505e1f2059f194e33b3a19a7 100644 --- a/clmctest/monitoring/test_rspec.py +++ b/clmctest/monitoring/test_rspec.py @@ -40,7 +40,7 @@ def test_service_names(streaming_sim_config, service_name): :param service_name the service name to test """ - assert any(s['name'] == service_name for s in streaming_sim_config['hosts']), "{0} not in list of hosts".format(service_name) + assert any(s['name'] == service_name for s in streaming_sim_config), "{0} not in list of hosts".format(service_name) print("\nSuccessfully passed configuration test for service name {0}\n".format(service_name)) @@ -56,7 +56,7 @@ def test_ping(streaming_sim_config): ping_count = 1 system_dependent_param = "-n" if system().lower() == "windows" else "-c" - for service in streaming_sim_config['hosts']: + for service in streaming_sim_config: command = ["ping", system_dependent_param, str(ping_count), service['ip_address']] assert run(command).returncode == 0, "Service ping test failed for {0} with ip address {1}".format(service['name'], service['ip_address']) print("\nSuccessfully passed ping test for service: {0}\n".format(service['name'])) diff --git a/clmctest/rspec.json b/clmctest/rspec.json new file mode 100644 index 0000000000000000000000000000000000000000..6b42c7d8145ef168e22a3af4b2515aedd6b1a9be --- /dev/null +++ b/clmctest/rspec.json @@ -0,0 +1,116 @@ +[{ + "name": "clmc-service", + "ip_address": "172.40.231.51" +}, +{ + "name": "apache", + "ip_address": "172.40.231.150", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "apache", + "sf_id_instance": "adaptive_streaming_I1", + "ipendpoint_id": "adaptive_streaming_I1_apache1", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "nginx", + "ip_address": "172.40.231.151", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "nginx", + "sf_id_instance": "adaptive_streaming_nginx_I1", + "ipendpoint_id": "adaptive_streaming_nginx_I1_apache1", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "mongo", + "service_name": "mongo", + "ip_address": "172.40.231.152", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "mongo", + "sf_id_instance": "metadata_database_I1", + "ipendpoint_id": "metadata_database_I1_apache1", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "ffmpeg", + "service_name": "ffmpeg", + "ip_address": "172.40.231.153", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "ffmpeg", + "sf_id_instance": "metadata_database_I1", + "ipendpoint_id": "metadata_database_I1_apache1", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "host", + "service_name": "host", + "ip_address": "172.40.231.154", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "host", + "sf_id_instance": "adaptive_streaming_I1", + "ipendpoint_id": "adaptive_streaming_I1_apache1", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "minio", + "ip_address": "172.40.231.155", + "location": "DC1", + "sfc_id": "MS_Template_1", + "sfc_id_instance": "MS_I1", + "sf_id": "minio", + "sf_id_instance": "adaptive_streaming_I1", + "ipendpoint_id": "adaptive_streaming_I1_minio", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "ipendpoint1", + "ip_address": "172.40.231.170", + "location": "nova", + "sfc_id": "media_service_A", + "sfc_id_instance": "StackID", + "sf_id": "ipendpoint", + "sf_id_instance": "ms-A.ict-flame.eu", + "ipendpoint_id": "endpoint1.ms-A.ict-flame.eu", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "ipendpoint2", + "ip_address": "172.40.231.171", + "location": "nova", + "sfc_id": "media_service_A", + "sfc_id_instance": "StackID", + "sf_id": "ipendpoint", + "sf_id_instance": "ms-A.ict-flame.eu", + "ipendpoint_id": "endpoint2.ms-A.ict-flame.eu", + "sr_id": "service_router", + "influxdb_url": "http://172.40.231.51:8086", + "database_name": "CLMCMetrics" +}, +{ + "name": "test-runner", + "ip_address": "172.40.231.200" +} +] \ No newline at end of file diff --git a/clmctest/scripts/rspec.yml b/clmctest/scripts/rspec.yml deleted file mode 100644 index 11d3ca5d505117a27c68c8b4544e630c5eadc4e8..0000000000000000000000000000000000000000 --- a/clmctest/scripts/rspec.yml +++ /dev/null @@ -1,28 +0,0 @@ -## (c) University of Southampton IT Innovation Centre, 2018 -## -## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, -## Chilworth Science Park, Southampton, SO16 7NS, UK. -## -## This software may not be used, sold, licensed, transferred, copied -## or reproduced in whole or in part in any manner or form or in or -## on any media by any person other than in accordance with the terms -## of the Licence Agreement supplied with the software, or otherwise -## without the prior written consent of the copyright owners. -## -## This software is distributed WITHOUT ANY WARRANTY, without even the -## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE, except where stated in the Licence Agreement supplied with -## the software. -## -## Created By : Michael Boniface -## Created Date : 20-03-2018 -## Created for Project : FLAME - -hosts: - - name: test-runner - cpus: 1 - memory: 2048 - disk: "10GB" - ip_address: "172.40.231.200" - \ No newline at end of file diff --git a/clmctest/scripts/test_config_telegraf.py b/clmctest/scripts/test_config_telegraf.py index 72ed589207d0f65d651289bfb8a189f5fd89d59c..acd8866fc62f7fac51f8c6bf0f844b032d98c6f3 100644 --- a/clmctest/scripts/test_config_telegraf.py +++ b/clmctest/scripts/test_config_telegraf.py @@ -35,6 +35,7 @@ def test_write_telegraf_conf(): SF_ID="streaming_service" SF_ID_INSTANCE="streaming_service_instance" IP_ENDPOINT_ID="endpoint" + SR_ID="service_router" INFLUXDB_URL="http://172.29.236.10" DATABASE_NAME="experimentation_database" @@ -61,7 +62,7 @@ def test_write_telegraf_conf(): assert code == 1, "Failed to return error on incorrect arguments : " + str(code) + ", cmd=" + cmd # run template relacement script with all arguments - cmd = 'sudo /vagrant/scripts/clmc-agent/configure.sh ' + LOCATION + ' ' + SFC_ID + ' ' + SFC_ID_INSTANCE + ' ' + SF_ID + ' ' + SF_ID_INSTANCE + ' ' + IP_ENDPOINT_ID + ' ' + INFLUXDB_URL + ' ' + DATABASE_NAME + cmd = 'sudo /vagrant/scripts/clmc-agent/configure.sh ' + LOCATION + ' ' + SFC_ID + ' ' + SFC_ID_INSTANCE + ' ' + SF_ID + ' ' + SF_ID_INSTANCE + ' ' + IP_ENDPOINT_ID + ' ' + SR_ID + ' ' + INFLUXDB_URL + ' ' + DATABASE_NAME (out, err, code) = run_command(cmd) assert code == 0, "Configure command returned error, output=" + str(out) + ", cmd=" + cmd @@ -75,7 +76,8 @@ def test_write_telegraf_conf(): assert lines.find(SFC_ID_INSTANCE), "Cannot find sfc_id_instance" assert lines.find(SF_ID), "Cannot find sfc_id" assert lines.find(SF_ID_INSTANCE), "Cannot find sf_id_instance" - assert lines.find(IP_ENDPOINT_ID), "Cannot find location" + assert lines.find(IP_ENDPOINT_ID), "Cannot find endpoint" + assert lines.find(SR_ID), "Cannot find sr_id" except FileNotFoundError: assert False, "Telegraf general conf file not found, " + TELEGRAF_GENERAL_CONF_FILE diff --git a/clmctest/services/minio/install.sh b/clmctest/services/minio/install.sh index 5c7ff69d34e0d0f97dc93e3bf2d532a2f08d0c90..9779b25b063720b66643f3c6bee4359233b52fb9 100644 --- a/clmctest/services/minio/install.sh +++ b/clmctest/services/minio/install.sh @@ -32,7 +32,7 @@ sudo apt-get install -y wget git GOROOT=/usr/local/go PATH=$PATH:$GOROOT/bin CGO_ENABLED=0 -ENV MINIO_UPDATE=off +env MINIO_UPDATE=off # And also for separate MINIO process echo "export GOROOT=/usr/local/go" >> ~/.profile diff --git a/clmctest/services/nginx/install.sh b/clmctest/services/nginx/install.sh index 7080fe826162a59914e787d5a779579b57f5ffea..06f74d2a3ab75895b77b50bf65ce966b106a5e4a 100755 --- a/clmctest/services/nginx/install.sh +++ b/clmctest/services/nginx/install.sh @@ -26,7 +26,7 @@ # Install nginx apt-get update -yes Y | apt-get install nginx +apt-get install nginx -y # Need to set up basic stats as this not configured by default # http://nginx.org/en/docs/http/ngx_http_stub_status_module.html @@ -48,34 +48,5 @@ if [ ! -f "$NGINX_CONF_TARGET" ]; then exit 1 fi -nginx -s reload -systemctl start nginx - -## install a configuration monitoring service, this needs to be in a venv with the rest of the CLMC -sudo apt-get install python3 python3-pip -y -sudo pip3 install pyaml influxdb - -svc="nginxmon" - -echo "install systemctl monitoring service" -svc_file="${svc}.service" -echo "[Unit]" > $svc_file -echo "Description=nginxmon" >> $svc_file -echo "After=network-online.target" >> $svc_file -echo "" >> $svc_file -echo "[Service]" >> $svc_file -echo "WorkingDirectory=${inst}/${dir}" >> $svc_file -echo "ExecStart=/usr/bin/python3 ${REPO_ROOT}/src/monitoring/systemctl_monitor.py -service nginx -rate 2 -agg 10 -host localhost -port 8186 -db CLMCMetrics" >> $svc_file -echo "ExecStop=/usr/bin/bash ${REPO_ROOT}/src/monitoring/stop_systemctl_monitor.sh" >> $svc_file -echo "" >> $svc_file -echo "[Install]" >> $svc_file -echo "WantedBy=network-online.target" >> $svc_file -sudo cp $svc_file /lib/systemd/system -rm $svc_file - -echo "enable" -sudo systemctl daemon-reload -sudo systemctl enable ${svc} - -echo "start" -sudo systemctl start ${svc} \ No newline at end of file +#nginx -s reload +#systemctl start nginx \ No newline at end of file diff --git a/scripts/clmc-agent/configure.sh b/scripts/clmc-agent/configure.sh index 41e91f5607c47e4be1ee0287a4a46cdea4e22501..06504dd8e0eb109363c5422c8f9a668ae7ea1e36 100755 --- a/scripts/clmc-agent/configure.sh +++ b/scripts/clmc-agent/configure.sh @@ -51,7 +51,7 @@ TELEGRAF_CONF_FILE=$TELEGRAF_CONF_DIR"/telegraf.conf" TELEGRAF_INCLUDE_CONF_DIR=$TELEGRAF_CONF_DIR"/telegraf.d" TELEGRAF_OUTPUT_CONF_FILE=$TELEGRAF_INCLUDE_CONF_DIR"/telegraf_output.conf" -cat TELEGRAF_OUTPUT_CONF_FILE +#cat ${TELEGRAF_OUTPUT_CONF_FILE} # Replace template parameters on general configuration sed -i 's/$LOCATION/'$LOCATION'/g' $TELEGRAF_CONF_FILE diff --git a/scripts/clmc-agent/install.sh b/scripts/clmc-agent/install.sh index d0a0de1ee9dc44bff96dda3696967db13521bfcd..d82b94450ed6227446432ac230142169416866dc 100755 --- a/scripts/clmc-agent/install.sh +++ b/scripts/clmc-agent/install.sh @@ -27,6 +27,9 @@ # Force fail on command fail set -euo pipefail +apt-get update +apt-get install wget -y + echo "Installing Telegraf agent" TELEGRAF_VERSION=1.7.0~5618bb0-0 diff --git a/scripts/clmc-service/install.sh b/scripts/clmc-service/install.sh index 900c9433aed8c55c1d936b2b5f8c2e146ce3f918..f39a6498db720a3f72e0088221206703988976d8 100755 --- a/scripts/clmc-service/install.sh +++ b/scripts/clmc-service/install.sh @@ -39,7 +39,7 @@ CHRONOGRAF_CHECKSUM=eea6915aa6db8f134fcd3b095e863b773bfb3a16a26e346dd65904a07df9 # install python for the simulator apt-get update -apt-get -y install python +apt-get -y install python wget # install influx wget https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUX_VERSION}_amd64.deb 2> /dev/null