This is the entry point of the test. This method will be found and executed when the module is ran using pytest
...
...
@@ -56,9 +55,53 @@ class TestSimulation(object):
# test the error attribute of the result is None, that is no error is returned from executing the DB query
assertquery_result.errorisNone,"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())
assertexpected_result==actual_result,"Simulation test failure"
print("Successfully passed test for the following query: {0}".format(query))
@pytest.mark.parametrize("query, field",[
('SELECT mean("placing") as "mean_transition_placing" FROM "CLMCMetrics"."autogen"."endpoint_config" where "placing" <> 0 and "placed" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache1\'',
'mean_transition_placing'),
('SELECT mean("placing") as "mean_target_placing" FROM "CLMCMetrics"."autogen"."endpoint_config" where "placing" <> 0 and "unplaced" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache1\'',
'mean_target_placing'),
('SELECT mean("booting") as "mean_transition_booting" FROM "CLMCMetrics"."autogen"."endpoint_config" where "booting" <> 0 and "booted" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache1\'',
'mean_transition_booting'),
('SELECT mean("booting") as "mean_target_booting" FROM "CLMCMetrics"."autogen"."endpoint_config" where "booting" <> 0 and "placed" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache2\'',
'mean_target_booting'),
('SELECT mean("connecting") as "mean_transition_connecting" FROM "CLMCMetrics"."autogen"."endpoint_config" where "connecting" <> 0 and "connected" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache2\'',
'mean_transition_connecting'),
('SELECT mean("connecting") as "mean_target_connecting" FROM "CLMCMetrics"."autogen"."endpoint_config" where "connecting" <> 0 and "booted" <> 0 and "ipendpoint"=\'adaptive_streaming_I1_apache2\'',
# test the error attribute of the result is None, that is no error is returned from executing the DB query
assertquery_result.errorisNone,"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 generator (we only expect one item in the generator)
result=next(query_result.get_points()).get(field)
assertfloat(result)>=0.0,"Test failure. Reported mean values cannot be negative."
print("Successfully passed test for the following query: {0}".format(query))