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

added a per-host lnetd test

parent 39151947
Branches
Tags
No related merge requests found
...@@ -11,20 +11,18 @@ from inventory_provider.routes.common import _ignore_cache_or_retrieve ...@@ -11,20 +11,18 @@ from inventory_provider.routes.common import _ignore_cache_or_retrieve
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
routes = Blueprint('lnetd-support-routes', __name__) routes = Blueprint('lnetd-support-routes', __name__)
Gb = 1 << 30
INTERFACE_LIST_SCHEMA = { INTERFACE_LIST_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#', '$schema': 'http://json-schema.org/draft-07/schema#',
'definitions': { 'definitions': {
"ipv4-interface-address": { 'ipv4-interface-address': {
"type": "string", 'type': 'string',
"pattern": r'^(\d+\.){3}\d+/\d+$' 'pattern': r'^(\d+\.){3}\d+/\d+$'
}, },
"ipv6-interface-address": { 'ipv6-interface-address': {
"type": "string", 'type': 'string',
"pattern": r'^[a-f\d:]+/\d+$' 'pattern': r'^[a-f\d:]+/\d+$'
}, },
'interface': { 'interface': {
...@@ -33,13 +31,13 @@ INTERFACE_LIST_SCHEMA = { ...@@ -33,13 +31,13 @@ INTERFACE_LIST_SCHEMA = {
'hostname': {'type': 'string'}, 'hostname': {'type': 'string'},
'interface': {'type': 'string'}, 'interface': {'type': 'string'},
'ifIndex': {'type': 'integer', 'minimum': 1}, 'ifIndex': {'type': 'integer', 'minimum': 1},
"ipv4": { 'ipv4': {
"type": "array", 'type': 'array',
"items": {"$ref": "#/definitions/ipv4-interface-address"} 'items': {'$ref': '#/definitions/ipv4-interface-address'}
}, },
"ipv6": { 'ipv6': {
"type": "array", 'type': 'array',
"items": {"$ref": "#/definitions/ipv6-interface-address"} 'items': {'$ref': '#/definitions/ipv6-interface-address'}
}, },
}, },
'required': ['hostname', 'interface', 'ifIndex', 'ipv4', 'ipv6'], 'required': ['hostname', 'interface', 'ifIndex', 'ipv4', 'ipv6'],
......
import json
import jsonschema
import pytest
from inventory_provider.routes.lnetd import INTERFACE_LIST_SCHEMA
DEFAULT_REQUEST_HEADERS = {
'Accept': ['application/json']
}
def test_router_interfaces(router, client):
if router.startswith('qfx'):
pytest.skip('no interfaces expected for {router}, skipping')
rv = client.post(
f'/LnetD/interfaces/{router}',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
response = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response, INTERFACE_LIST_SCHEMA)
assert response # at least shouldn't be empty
assert all(ifc['hostname'] == router for ifc in response)
...@@ -3,7 +3,7 @@ import jsonschema ...@@ -3,7 +3,7 @@ import jsonschema
from inventory_provider.routes import lnetd from inventory_provider.routes import lnetd
DEFAULT_REQUEST_HEADERS = { DEFAULT_REQUEST_HEADERS = {
"Accept": ["application/json"] 'Accept': ['application/json']
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment