Skip to content
Snippets Groups Projects
Commit 3fc79692 authored by Michael Boniface's avatar Michael Boniface
Browse files

Merge branch 'rp-scripts' into 'integration'

Rp scripts

Closes #48

See merge request FLAME/flame-clmc!17
parents 8e7c45f5 b10d1339
No related branches found
No related tags found
No related merge requests found
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: "192.168.50.10"
- name: apache
cpus: 1
memory: 2048
disk: "10GB"
service_name: "apache"
forward_ports:
- guest: 80
host: 8881
ip_address: "192.168.50.11"
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"
influxdb_url: "http://192.168.50.10:8086"
database_name: "CLMCMetrics"
- name: nginx
cpus: 1
memory: 2048
disk: "10GB"
service_name: "nginx"
forward_ports:
- guest: 80
host: 8082
ip_address: "192.168.50.13"
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"
influxdb_url: "http://192.168.50.10:8086"
database_name: "CLMCMetrics"
- name: mongo
cpus: 1
memory: 2048
disk: "10GB"
service_name: "mongo"
forward_ports:
- guest: 80
host: 8083
ip_address: "192.168.50.14"
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"
influxdb_url: "http://192.168.50.10:8086"
database_name: "CLMCMetrics"
- name: ffmpeg
cpus: 1
memory: 2048
disk: "10GB"
service_name: "ffmpeg"
forward_ports:
- guest: 80
host: 8084
ip_address: "192.168.50.15"
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"
influxdb_url: "http://192.168.50.10:8086"
database_name: "CLMCMetrics"
- name: ipendpoint
cpus: 1
memory: 2048
disk: "10GB"
service_name: "ipendpoint"
forward_ports:
- guest: 80
host: 8085
ip_address: "192.168.50.16"
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"
influxdb_url: "http://192.168.50.10:8086"
database_name: "CLMCMetrics"
\ No newline at end of file
#!/usr/bin/python3
import sys
if sys.version_info[0] < 3:
raise Exception("Python 3 or a more recent version is required.")
import pytest
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from os.path import join, dirname
def test_service_names(telegraf_agent_config):
print(telegraf_agent_config['hosts'][0]['name'])
assert telegraf_agent_config['hosts'][0]['name'] == 'clmc-service'
assert telegraf_agent_config['hosts'][1]['name'] == 'apache'
assert telegraf_agent_config['hosts'][2]['name'] == 'nginx'
assert telegraf_agent_config['hosts'][3]['name'] == 'mongo'
assert telegraf_agent_config['hosts'][4]['name'] == 'ffmpeg'
assert telegraf_agent_config['hosts'][5]['name'] == 'ipendpoint'
def test_ping(telegraf_agent_config):
"""This test will only run on linux"""
for x in telegraf_agent_config['hosts']:
print("Testing service" + x['name'] + " " + x['ip_address'])
response = os.system("ping -c 1 " + x['ip_address'])
assert response == 0, "Could not ping " + x['name'] + " on ip address " + x['ip_address']
@pytest.mark.parametrize("queries",
[{'nginx': {'measurement': 'nginx', 'query': 'SELECT mean("requests") AS "mean_active" FROM "CLMCMetrics"."autogen"."nginx"', 'result': '1'}}])
def test_nginx(telegraf_agent_config, queries):
measurements = send_query("http://localhost:8086", 'SHOW measurements ON "CLMCMetrics"')
assert queries['nginx']['measurement'] in measurements, "Measurement " + measurement + " not in the CLMCMetrics database"
result = send_query("http://localhost:8086", queries['nginx']['query'])
print("result" + result)
# assert results is correct
def send_query(url, query):
"""
An auxiliary static method to send a query to a url and retrieve the result
:param url: the target url to which the query is sent to - a string containing a valid URL address
:param query: the query to be executed on the given URL
:return: the result of the executed query
"""
query = urlencode({"q": query}).encode("ascii")
request = Request("{0}/query".format(url), query)
result = urlopen(request)
return result.read().decode("utf-8").strip()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment