{'placing':random.randint(75,125)/10,'booting':random.randint(75,125)/10,'connecting':random.randint(75,125)/10}]# Random initialization of state periods
# 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)
measurements=query_result.get_points()
assertall(map(lambdameasurement: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\'',
('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\'',