Skip to content
Snippets Groups Projects
Commit 5937d758 authored by Simon Crowle's avatar Simon Crowle
Browse files

Adds tests for averaging average state times per sample period

Seeds random number generation for predictable results
parent 9e307f70
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
import pytest
import time
import random
class TestSimulation(object):
......@@ -10,11 +11,17 @@ class TestSimulation(object):
"""
@pytest.fixture(scope='class')
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"',
{"time": "1970-01-01T00:00:00Z", "count_cpu_active_time": 7200, "count_cpu_idle_time": 7200, "count_cpu_usage": 7200}),
......@@ -26,12 +33,25 @@ class TestSimulation(object):
{"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}),
# Media component state tests
('SELECT count(*) FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE ipendpoint=\'adaptive_streaming_I1_apache1\'',
{"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=\'adaptive_streaming_I1_apache2\'',
{"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 mean(avg_stopped) as "avg_stopped" FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE avg_stopped <>0',
{"time" : "1970-01-01T00:00:00Z", "avg_stopped" : 0.9311386970408875}),
('SELECT mean(avg_starting) as "avg_starting" FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE avg_starting <>0',
{"time" : "1970-01-01T00:00:00Z", "avg_starting" : 1.4332962039049266}),
('SELECT mean(avg_running) as "avg_running" FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE avg_running <>0',
{"time" : "1970-01-01T00:00:00Z", "avg_running" : 0.9999273119631822}),
('SELECT mean(avg_stopping) as "avg_stopping" FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE avg_stopping <>0',
{"time" : "1970-01-01T00:00:00Z", "avg_stopping" : 1.1135062967253757}),
('SELECT mean(avg_stopped) as "avg_stopped" FROM "CLMCMetrics"."autogen"."mpegdash_service_config" WHERE avg_stopped <>0',
{"time" : "1970-01-01T00:00:00Z", "avg_stopped" : 0.9311386970408875})
])
def test_simulation( self, run_simulator, 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
......
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