Skip to content
Snippets Groups Projects
Commit 899213aa authored by Erik Reid's avatar Erik Reid
Browse files

added tests of /poller/services*

parent 56329ba9
No related branches found
No related tags found
No related merge requests found
......@@ -230,10 +230,12 @@ SERVICES_LIST_SCHEMA = {
'pop': {'type': 'string'},
'hostname': {'type': 'string'},
'interface': {'type': 'string'},
'type': {'type': 'string'}
},
'required': [
'id', 'name', 'customer', 'speed',
'pop', 'hostname', 'interface'],
'id', 'name', 'customer',
'speed', 'pop', 'hostname',
'interface', 'type'],
'additionalProperties': False
}
},
......@@ -740,7 +742,8 @@ def get_services(service_type=None):
'pop': s['here']['pop']['name'],
'hostname': common.ims_equipment_to_hostname(
s['here']['equipment']),
'interface': s['here']['port']
'interface': s['here']['port'],
'type': s['type']
}
cache_key = f'classifier-cache:poller:services:{service_type}' \
......@@ -781,4 +784,4 @@ def gws_indirect():
cf. :meth:`inventory_provider.routes.poller.get_services`
:return:
"""
return get_services(service_type='geant_ip')
return get_services(service_type='gws_indirect')
import json
import jsonschema
import pytest
from inventory_provider.routes import poller
DEFAULT_REQUEST_HEADERS = {
......@@ -62,3 +63,51 @@ def test_gws_direct(client):
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, poller.GWS_DIRECT_DATA_SCHEMA)
assert response_data, "the subscription list shouldn't be empty"
def test_gws_indirect(client):
rv = client.get(
'/poller/gws/indirect',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, poller.SERVICES_LIST_SCHEMA)
assert response_data # test data is non-empty
assert all(s['type'] == 'GWS - INDIRECT' for s in response_data)
def test_all_services(client):
rv = client.get(
'/poller/services',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, poller.SERVICES_LIST_SCHEMA)
assert response_data # test data is non-empty
@pytest.mark.parametrize('uri_type,expected_type', [
('gws_indirect', 'GWS - INDIRECT'),
('gws_upstream', 'GWS - UPSTREAM'),
('geant_ip', 'GEANT IP'),
('geant_lambda', 'GEANT LAMBDA'),
# ('gts', 'GTS'), # these are non-monitored (TODO: make a flag)
('md_vpn_native_', 'MD-VPN (NATIVE)'),
('md_vpn_proxy_', 'MD-VPN (PROXY)'),
# ('cbl1', 'CBL1'),
# ('l3_vpn', 'L3-VPN')
])
def test_all_services_by_type(client, uri_type, expected_type):
rv = client.get(
f'/poller/services/{uri_type}',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, poller.SERVICES_LIST_SCHEMA)
assert response_data # test data is non-empty
assert all(s['type'] == expected_type for s in response_data)
......@@ -5,6 +5,7 @@ import pytest
from inventory_provider.routes.msr import PEERING_LIST_SCHEMA, \
PEERING_GROUP_LIST_SCHEMA
from inventory_provider.routes.poller import SERVICES_LIST_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
......@@ -12,20 +13,17 @@ DEFAULT_REQUEST_HEADERS = {
}
# @pytest.mark.skip(reason='tmp disabled while changing schema')
# def test_access_services(client):
#
# # todo - fix once IMS msr code is done
#
# rv = client.get(
# '/msr/access-services',
# headers=DEFAULT_REQUEST_HEADERS)
# assert rv.status_code == 200
# assert rv.is_json
# response_data = json.loads(rv.data.decode('utf-8'))
# jsonschema.validate(response_data, ACCESS_SERVICES_LIST_SCHEMA)
#
# assert response_data # test data is non-empty
def test_access_services(client):
rv = client.get(
'/msr/access-services',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, SERVICES_LIST_SCHEMA)
assert response_data # test data is non-empty
assert all(s['type'] == 'GEANT IP' for s in response_data)
def test_logical_system_peerings_all(client):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment