5GTANGO Test Library - sonata-nfv/tng-tests GitHub Wiki
The tng-lib is available in Github here
How to use it with robot framework
WIP
- In order to use with Robot, you would have to install the library, and add to your Robot test:
*** Settings ***
Library tnglib
When you want to use a method, you can write as any other known keyword in Robot Framework. Example:
*** Test Cases ***
Setting the SP Path
Set SP Path ${HOST} # This is a method from tnglib
${result} = Sp Health Check
Should Be True ${result}
- Devops flow reference: Devops Workflow
- Working example reference: example
Global variables:
Building all paths for global use
sp_path = ''
pkg_api = ''
pkg_status_api = ''
request_api = ''
service_descriptor_api = ''
service_instance_api = ''
function_descriptor_api = ''
function_instance_api = ''
sl_templates_api = ''
sl_agreements_api = ''
sl_violations_api = ''
sl_guarantees_api = ''
slice_template_api = ''
slice_instance_api = ''
policy_api = ''
policy_bind_api = ''
test_results_api = ''
SP Available methods:
Packages:
get_packages():
"""Returns info on all available packages.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a package descriptor.
"""
remove_all_packages():
"""Removes all packages from the catalogue.
:returns: A list. [0] is a bool with the result. [1] is a list of
uuids of packages that were removed.
"""
remove_package(package_uuid):
"""Removes one package from the catalogue.
:param package_uuid: uuid of the package
:returns: A list. [0] is a bool with the result. [1] is a string
with either the uuid or an error message.
"""
upload_package(pkg_path, url=False):
"""Uploads a package from file.
:param pkg_path: relative path to the package that needs uploading, or url
:param pkg_path: A bool, True if pkg_path is an url
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the uploaded package, or an error message.
"""
get_package(package_uuid):
"""Returns info on a specific package.
:param package_uuid: the uuid of the package
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing a package descriptor.
"""
map_package_on_service(package_uuid):
"""Return the uuid of a network service based on a package uuid.
:param package_uuid: the uuid of the package
:returns: A list. [0] is a bool with the result. [1] is a string
containing a nsd uuid.
"""
Requests:
get_requests():
"""Returns info on all requests.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries, each containing a request.
"""
get_request(request_uuid):
"""Returns info on a specific request.
:param request_uuid: A string. The uuid of the request.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing the request.
"""
service_instantiate(service_uuid, sla_uuid=None):
"""Makes a request to instantiate a service.
:param service_uuid: A string. The uuid of the service.
:param sla_uuid: A string (Default value = None). The uuid of the SLA.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the instantiated service.
"""
service_terminate(instance_uuid):
"""Makes a request to terminate a service.
:param instance_uuid: A string. The uuid of the instance.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the terminated instance.
"""
slice_instantiate(slice_template_uuid, name=None, description=None):
"""Makes a request to instantiate a slice.
:param slice_template_uuid: A string. The uuid of the slice template.
:param name: A string (Default value = None). A name for the slice
instance.
:param description: A string (Default value = None). A description
for the slice template
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the instantiated slice.
"""
slice_terminate(instance_uuid):
"""Makes a request to terminate a slice.
:param instance_uuid: A string. The uuid of the slice instance.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the terminated slice instance.
"""
_post_request(data):
""" Generic request maker. """
Functions:
get_function_descriptors():
"""Returns info on all available function descriptors.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a descriptor.
get_function_descriptor(function_descriptor_uuid):
"""Returns info on a specific function descriptor.
:param function_descriptor_uuid: uuid of the vnfd.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing the vnfd.
"""
get_function_instances():
"""Returns info on all available function instances.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a vnfr.
"""
get_function_instance(function_instance_uuid):
"""Returns info on a specific function instance.
:param function_instance_uuid: uuid of the vnfr.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing a vnfr.
"""
Records
get_ips_from_vnfr(vnfr):
"""Returns info on the ip addresses in a vnfr, per vdu.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
with a key for each VDU. The value is a list of dictionaries.
Each dictionary has a type key, indicating which type of id,
and an ip field containing the ip.
"""
SLAs
create_sla_template(templateName, nsd_uuid, expireDate, guaranteeId):
"""Generates an initial SLA template.
:param templateName: name for the SLA template.
:param nsd_uuid: uuid of the network service.
:param expireDate: DD/MM/YYYY expiration date.
:param guaranteeId: id of the SLA guarantee.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the created SLA template.
"""
get_sla_templates():
"""Returns info on all available SLA templates.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains an SLA template.
"""
get_sla_template(sla_uuid):
"""Returns info on all available SLA templates.
:param sla_uuid: uuid of an SLA template.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing an SLA template.
"""
delete_sla_template(sla_template_uuid):
"""Deletes an SLA template.
:param sla_template_uuid: uuid of an SLA template.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the terminated SLA.
"""
get_sla_guarantees():
"""Returns info on all available SLA guarantees.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains an SLA guarantee.
"""
get_agreements(nsi_uuid=None):
"""Returns info on all available SLA agreements.
:param nsi_uuid: (Default value = None) uuid of a service instance.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains an SLA agreement.
"""
get_detailed_agreement(sla_uuid, nsi_uuid):
"""Returns info on a specific Agreement.
:param sla_uuid: uuid of an SLA template.
:param nsi_uuid: uuid of a service instance.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing details on a single SLA agreement.
"""
get_violations(nsi_uuid=None):
"""Returns info on all SLA violations.
:param nsi_uuid: (Default value = None) uuid of a service instance.
:returns: A list. [0] is a bool with the result. [1] is a list of
SLA violations associated to a service instance.
"""
get_violations_per_nsi_sla(sla_uuid, nsi_uuid):
"""Returns the vaiolations for a specific SLA.
:param sla_uuid: uuid of SLA template.
:param nsi_uuid: uuid of network service instance.
:returns: A list. [0] is a bool with the result. [1] is a list of
SLA violations associated to a service instance and an SLA
template.
"""
Policies
get_policies():
"""Returns info on all available policiy descriptors.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a policy descriptor.
"""
get_policy(policy_uuid):
"""Returns info on a specific policy descriptor.
:param policy_uuid: uuid of a policy descriptor.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containg a policy descriptor.
"""
create_policy(path):
"""Uploads a policy descriptor.
:param path: relative path where policy descriptor is stored.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the uploaded policy descriptor.
"""
delete_policy(policy_uuid):
"""Deletes a policy descriptor.
:param policy_uuid: uuid of a policy descriptor.
:returns: A list. [0] is a bool with the result. [1] is a string containing
the uuid of the terminated policy descriptor.
"""
attach_policy(policy_uuid, service_uuid, sla_uuid):
"""Attaches a policy to a service and SLA.
:param policy_uuid: uuid of a policy descriptor.
:param service_uuid: uuid of a network service.
:param sla_uuid: uuid of an SLA.
:returns: A list. [0] is a bool with the result. [1] is a string indicating
the result.
"""
Logs
get_logs():
"""Returns all the error logs from an specific environment from Graylogs.
:param from: Timerange start example: "2019-04-25 17:11:01.201".
:param to: Timerange end example: "2019-04-25 17:26:01.201".
:param sp_path: Url of the SP.
:param file: Boolean to write the logs to file (Default=True).
:output: File (if param file is True) with the error logs from Graylogs for the sp_path.
"""
VnV Available methods:
tests
get_tests_plans():
"""Returns info on all available tests plans.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a result.
"""
get_test_plan(uuid):
"""Returns info on a specific test plan.
:param uuid: uuid of test plan.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing a test plan.
"""
get_tests_results():
"""Returns info on all available tests results.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a result.
"""
get_test_result(uuid):
"""Returns info on a specific test result.
:param uuid: uuid of test.
:returns: A list. [0] is a bool with the result. [1] is a dictionary
containing a test.
"""
get_test_uuid_by_instance_uuid(instance_uuid):
"""Returns the test_uuid on a specific test result filtering by instance_uuid.
:returns: A list. [0] is a bool with the result. [1] is a list of
dictionaries. Each dictionary contains a test_uuid.
"""