Skip to content
Snippets Groups Projects
Commit 2b945497 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

[ Issue #61 ] - update to endpoints configuration test

parent 675f70c7
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,17 @@ import time
"""
Tests the monitoring of endpoints' configuration states - currently based on model with three states (placing -> booting -> connecting)
Line Protocol report format:
mcEndpointConfig <global tags>,<state> <statePeriod=milliseconds>,<cpus=numberOfCPUs>, <memory=memoryOfVM>, <storage=storageCapacityOfVM> time
"""
# Random initialization of state periods
state_delays = [{'placing': random.randint(75, 125)/10, 'booting': random.randint(75, 125)/10, 'connecting': random.randint(75, 125)/10},
{'placing': random.randint(75, 125)/10, 'booting': random.randint(75, 125)/10, 'connecting': random.randint(75, 125)/10}] # Random initialization of state periods
{'placing': random.randint(75, 125)/10, 'booting': random.randint(75, 125)/10, 'connecting': random.randint(75, 125)/10}]
measurement_name = 'mcEndpointConfig' # measurement name for configuration of media components' endpoints
......@@ -29,6 +35,8 @@ measurement_name = 'mcEndpointConfig' # measurement name for configuration of m
])
def test_endpoint_config(query, result, get_db_client):
"""
Test endpoint configuration state measurements in general.
:param query: query under test for the endpoint configuration state
:param result: expected result of executed query
:param get_db_client: the InfluxDB client fixture from conftest.py
......@@ -36,13 +44,51 @@ def test_endpoint_config(query, result, get_db_client):
print("\n") # blank line for formatting purposes
measurements = get_db_client.query(query, raise_errors=False).get_points()
query_result = get_db_client.query(query, raise_errors=False)
# 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)
measurements = query_result.get_points()
assert all(map(lambda measurement: compare(measurement, result), measurements)), "Comparison failure for query:\n{0}".format(query)
print("Successfully passed test for query:\n{0}".format(query))
@pytest.mark.parametrize("query, result", [
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'placing\' and ipendpoint=\'adaptive_streaming_I1_apache1\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[0]['placing']}),
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'booting\' and ipendpoint=\'adaptive_streaming_I1_apache1\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[0]['booting']}),
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'connecting\' and ipendpoint=\'adaptive_streaming_I1_apache1\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[0]['connecting']}),
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'placing\' and ipendpoint=\'adaptive_streaming_I1_apache2\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[1]['placing']}),
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'booting\' and ipendpoint=\'adaptive_streaming_I1_apache2\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[1]['booting']}),
('SELECT MEAN("statePeriod") as "mean_statePeriod" FROM "CLMCMetrics"."autogen"."mcEndpointConfig" WHERE state=\'connecting\' and ipendpoint=\'adaptive_streaming_I1_apache2\' and sf=\'adaptive_streaming\'',
{"mean_statePeriod": state_delays[1]['connecting']})
])
def test_mean_config_periods(query, result, get_db_client):
"""
:param query: query under test for the endpoint configuration state
:param result: expected result of executed query
:param get_db_client: the InfluxDB client fixture from conftest.py
"""
print("\n") # blank line for formatting purposes
query_result = get_db_client.query(query, raise_errors=False)
# 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)
measurement = next(query_result.get_points())
measurement.pop('time')
assert measurement == result, "Comparison failure for query of mean state period:\n{0}".format(query)
print("Successfully passed test for query of mean state period:\n{0}".format(query))
@pytest.fixture(scope='module', autouse=True)
def generate_states_data(streaming_sim_config, get_db_client):
"""
......@@ -61,8 +107,8 @@ def generate_states_data(streaming_sim_config, get_db_client):
time.sleep(2)
for i in range(1, 3):
measurement_time = 1
for state in state_delays[i-1].keys():
measurement_time = 0
for state in ('placing', 'booting', 'connecting'):
epURL = streaming_sim_config['hosts'][i]['ip_address'] # endpoint URL
mc_EndpointID = streaming_sim_config['hosts'][i]['ipendpoint_id']
cpu = streaming_sim_config['hosts'][i]['cpus']
......
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