Tests the error handling of the graph build API endpoint.
Tests the error handling of the graph build API endpoint by passing erroneous input and confirming an HTTPBadRequest was returned.
:param body: body of the request to test
:param body: body of the request to test
:param from_timestamp: the 'from' URL param
:param from_timestamp: the 'from' URL param
:param to_timestamp: the 'to' URL param
:param to_timestamp: the 'to' URL param
:param error_msg: the error message to pass in case of an error
:param error_msg: the error message to pass in case of an error not being properly handled by the API endpoint (in other words, a test failure)
"""
"""
request=testing.DummyRequest()
request=testing.DummyRequest()
ifbodyisnotNone:
ifbodyisnotNone:
request.body=body
request.body=body
...
@@ -100,12 +101,12 @@ class TestGraphAPI(object):
...
@@ -100,12 +101,12 @@ class TestGraphAPI(object):
deftest_build(self,db_testing_data):
deftest_build(self,db_testing_data):
"""
"""
Tests the graph build API endpoint
Tests the graph build API endpoint - it makes 2 API calls and checks that the expected graph was created (the influx data that's being used is reported to InfluxDB in the conftest file)
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client object (this is a fixture from conftest)
"""
"""
globalgraph_1_id,graph_2_id
globalgraph_1_id,graph_2_id# these variables are used to store the ID of the graphs that were created during the execution of this test method; they are reused later when testing the delete method
assertendpoint_node["response_time"]==response_time,"Wrong response time property of endpoint node"
assertendpoint_node["response_time"]==response_time,"Wrong response time property of endpoint node"
# approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing
assertendpoint_node["request_size"]==pytest.approx(request_size,1),"Wrong request size attribute of endpoint node"
assertendpoint_node["request_size"]==pytest.approx(request_size,1),"Wrong request size attribute of endpoint node"
assertendpoint_node["response_size"]==pytest.approx(response_size,1),"Wrong response size attribute of endpoint node"
assertendpoint_node["response_size"]==pytest.approx(response_size,1),"Wrong response size attribute of endpoint node"
# send a new request for a new service function chain
# send a new request for a new service function chain and check the new subgraph has been created
assertendpoint_node["response_time"]==response_time,"Wrong response time property of endpoint node"
assertendpoint_node["response_time"]==response_time,"Wrong response time property of endpoint node"
# approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing
assertendpoint_node["request_size"]==pytest.approx(request_size,1),"Wrong request size attribute of endpoint node"
assertendpoint_node["request_size"]==pytest.approx(request_size,1),"Wrong request size attribute of endpoint node"
assertendpoint_node["response_size"]==pytest.approx(response_size,1),"Wrong response size attribute of endpoint node"
assertendpoint_node["response_size"]==pytest.approx(response_size,1),"Wrong response size attribute of endpoint node"
deftest_delete(self,db_testing_data):
deftest_delete(self,db_testing_data):
"""
"""
Tests the delete API endpoint of the Graph API
Tests the delete API endpoint of the Graph API - the test depends on the build test to have been passed successfully so that graph_1_id and graph_2_id have been set
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client object (this is a fixture from conftest)
"""
"""
globalgraph_1_id,graph_2_id
globalgraph_1_id,graph_2_id
...
@@ -264,11 +269,13 @@ class TestGraphAPI(object):
...
@@ -264,11 +269,13 @@ class TestGraphAPI(object):
error_raised=True
error_raised=True
asserterror_raised,"HTTP Not Found error must be raised in case of unrecognized subgraph ID"
asserterror_raised,"HTTP Not Found error must be raised in case of unrecognized subgraph ID"
Tests the error handling of the graph round trip time API endpoint.
Tests the error handling of the graph round trip time API endpoint - achieved by sending erroneous input in the request and verifying the appropriate error type has been returned.
:param graph_id: the UUID of the subgraph
:param graph_id: the UUID of the subgraph
:param endpoint: endpoint ID
:param endpoint: endpoint ID
:param compute_node: compute node ID
:param compute_node: compute node ID
:param error_type: error type to expect
:param error_type: error type to expect as a response
:param error_msg: error message in case of a test failure
:param error_msg: error message in case of a test failure
"""
"""
...
@@ -312,13 +319,14 @@ class TestGraphAPI(object):
...
@@ -312,13 +319,14 @@ class TestGraphAPI(object):
deftest_rtt(self,db_testing_data):
deftest_rtt(self,db_testing_data):
"""
"""
Tests the rtt API endpoint of the Graph API
Tests the rtt API endpoint of the Graph API.
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client
:param db_testing_data: pair of time stamps - the from-to range of the generated influx test data, test database name and the graph db client object (this is a fixture from conftest)
# approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing
# approximation is used to avoid long float numbers retrieved from influx, the test case ensures the results are different enough so that approximation of +-1 is good enough for testing
assertfrom_nodeisnotNone# IMPORTANT, assert the from_node exists, otherwise the py2neo RelationshipMatcher object assumes you are looking for any node (instead of raising an error)
assertto_nodeisnotNone# IMPORTANT, assert the from_node exists, otherwise the py2neo RelationshipMatcher object assumes you are looking for any node (instead of raising an error)
assertgraph.relationships.match(nodes=(from_node,to_node),r_type=relationship_type).first()isnotNone,"Graph is missing a required relationship"
assertgraph.relationships.match(nodes=(from_node,to_node),r_type=relationship_type).first()isnotNone,"Graph is missing a required relationship"