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
No related branches found
No related tags found
No related merge requests found
......@@ -11,20 +11,18 @@ from inventory_provider.routes.common import _ignore_cache_or_retrieve
logger = logging.getLogger(__name__)
routes = Blueprint('lnetd-support-routes', __name__)
Gb = 1 << 30
INTERFACE_LIST_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'definitions': {
"ipv4-interface-address": {
"type": "string",
"pattern": r'^(\d+\.){3}\d+/\d+$'
'ipv4-interface-address': {
'type': 'string',
'pattern': r'^(\d+\.){3}\d+/\d+$'
},
"ipv6-interface-address": {
"type": "string",
"pattern": r'^[a-f\d:]+/\d+$'
'ipv6-interface-address': {
'type': 'string',
'pattern': r'^[a-f\d:]+/\d+$'
},
'interface': {
......@@ -33,13 +31,13 @@ INTERFACE_LIST_SCHEMA = {
'hostname': {'type': 'string'},
'interface': {'type': 'string'},
'ifIndex': {'type': 'integer', 'minimum': 1},
"ipv4": {
"type": "array",
"items": {"$ref": "#/definitions/ipv4-interface-address"}
'ipv4': {
'type': 'array',
'items': {'$ref': '#/definitions/ipv4-interface-address'}
},
"ipv6": {
"type": "array",
"items": {"$ref": "#/definitions/ipv6-interface-address"}
'ipv6': {
'type': 'array',
'items': {'$ref': '#/definitions/ipv6-interface-address'}
},
},
'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
from inventory_provider.routes import lnetd
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.
Finish editing this message first!
Please register or to comment