("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"cpu_usage\"","{\"results\":[{\"statement_id\":0,\"series\":[{\"name\":\"cpu_usage\",\"columns\":[\"time\",\"count_cpu_active_time\",\"count_cpu_idle_time\",\"count_cpu_usage\"],\"values\":[[\"1970-01-01T00:00:00Z\",7200,7200,7200]]}]}]}"),
("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"ipendpoint_route\"","{\"results\":[{\"statement_id\":0,\"series\":[{\"name\":\"ipendpoint_route\",\"columns\":[\"time\",\"count_http_requests_fqdn_m\",\"count_network_fqdn_latency\"],\"values\":[[\"1970-01-01T00:00:00Z\",7200,7200]]}]}]}"),
("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"mpegdash_service\"","{\"results\":[{\"statement_id\":0,\"series\":[{\"name\":\"mpegdash_service\",\"columns\":[\"time\",\"count_avg_response_time\",\"count_peak_response_time\",\"count_requests\"],\"values\":[[\"1970-01-01T00:00:00Z\",7200,7200,7200]]}]}]}"),
("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"net_port_io\"","{\"results\":[{\"statement_id\":0,\"series\":[{\"name\":\"net_port_io\",\"columns\":[\"time\",\"count_RX_BYTES_PORT_M\",\"count_TX_BYTES_PORT_M\"],\"values\":[[\"1970-01-01T00:00:00Z\",7200,7200]]}]}]}"),
("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"vm_res_alloc\"","{\"results\":[{\"statement_id\":0,\"series\":[{\"name\":\"vm_res_alloc\",\"columns\":[\"time\",\"count_cpu\",\"count_memory\",\"count_storage\"],\"values\":[[\"1970-01-01T00:00:00Z\",12,12,12]]}]}]}")
("SELECT count(*) FROM \"CLMCMetrics\".\"autogen\".\"cpu_usage\"",
An auxiliary static method to send a query to a url and retrieve the result
# 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)
: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
"""
# 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)
actual_result=next(query_result.get_points())
query=urlencode({"q":query}).encode("ascii")
request=Request("{0}/query".format(url),query)
result=urlopen(request)
assertexpected_result==actual_result,"Simulation test failure"
print("Successfully passed test for the following query: {0}".format(query))