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

added counter schemas and tests

parent c5550424
No related branches found
No related tags found
No related merge requests found
PHYSICAL_INTERFACE_COUNTER_SCHEMA = {
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'brian-v6-counters': {
'type': 'object',
'properties': {
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
},
'required': ['bytes', 'packets'],
'additionalProperties': False
},
'brian-ingress-errors': {
'type': 'object',
'properties': {
'errors': {'type': 'integer'},
'drops': {'type': 'integer'},
'resource': {'type': 'integer'},
'discards': {'type': 'integer'},
'fifo': {'type': 'integer'},
},
'required': ['errors', 'drops', 'resource', 'discards'],
'additionalProperties': False
},
'brian-egress-errors': {
'type': 'object',
'properties': {
'errors': {'type': 'integer'},
'drops': {'type': 'integer'},
'resource': {'type': 'integer'},
'fifo': {'type': 'integer'},
'collisions': {'type': 'integer'},
},
'required': ['errors', 'drops', 'resource'],
'additionalProperties': False
},
'brian-ingress-counters': {
'type': 'object',
'properties': {
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
'v6': {'$ref': '#/definitions/brian-v6-counters'},
'errors': {'$ref': '#/definitions/brian-ingress-errors'},
},
'required': ['bytes', 'packets', 'v6'],
'additionalProperties': False
},
'brian-egress-counters': {
'type': 'object',
'properties': {
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
'v6': {'$ref': '#/definitions/brian-v6-counters'},
'errors': {'$ref': '#/definitions/brian-egress-errors'},
},
'required': ['bytes', 'packets', 'v6'],
'additionalProperties': False
},
'brian-counters': {
'type': 'object',
'properties': {
'ingress': {'$ref': '#/definitions/brian-ingress-counters'},
'egress': {'$ref': '#/definitions/brian-egress-counters'},
},
'required': ['ingress', 'egress'],
'additionalProperties': False
},
'l2-dir-counters': {
'type': 'object',
'properties': {
'broadcast': {'type': 'integer'},
'multicast': {'type': 'integer'},
'unicast': {'type': 'integer'},
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
'errors': {
'type': 'object',
'properties': {
'crc': {'type': 'integer'},
'fifo': {'type': 'integer'},
},
'required': ['crc', 'fifo'],
'additionalProperties': False
},
},
'required': ['broadcast', 'multicast'],
'additionalProperties': False
},
'l2-counters': {
'type': 'object',
'properties': {
'ingress': {'$ref': '#/definitions/l2-dir-counters'},
'egress': {'$ref': '#/definitions/l2-dir-counters'},
},
'required': ['ingress', 'egress'],
'additionalProperties': False
}
},
'type': 'object',
'properties': {
'name': {'type': 'string'},
'brian': {'$ref': '#/definitions/brian-counters'},
'l2': {'$ref': '#/definitions/l2-counters'}
},
'required': ['name', 'brian'],
'additionalProperties': False
}
LOGICAL_INTERFACE_COUNTER_SCHEMA = {
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'brian-v6-counters': {
'type': 'object',
'properties': {
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
},
'required': ['bytes', 'packets'],
'additionalProperties': False
},
'brian-dir-counters': {
'type': 'object',
'properties': {
'bytes': {'type': 'integer'},
'packets': {'type': 'integer'},
'v6': {'$ref': '#/definitions/brian-v6-counters'}
},
'required': ['bytes', 'packets'],
'additionalProperties': False
},
'brian-counters': {
'type': 'object',
'properties': {
'ingress': {'$ref': '#/definitions/brian-dir-counters'},
'egress': {'$ref': '#/definitions/brian-dir-counters'},
},
'required': ['ingress', 'egress'],
'additionalProperties': False
}
},
'type': 'object',
'properties': {
'name': {'type': 'string'},
'brian': {'$ref': '#/definitions/brian-counters'}
},
'required': ['name', 'brian'],
'additionalProperties': False
}
......@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
# minimal inventory response schema for our purposes
INVENTORY_VERSION_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'latch': {
......@@ -31,7 +31,7 @@ INVENTORY_VERSION_SCHEMA = {
# minimal inventory response schema for our purposes
INVENTORY_INTERFACES_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'interface': {
......@@ -55,7 +55,7 @@ INVENTORY_INTERFACES_SCHEMA = {
# minimal inventory response schema for our purposes
GWS_DIRECT_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'interface-counters': {
......@@ -75,7 +75,7 @@ GWS_DIRECT_SCHEMA = {
}
GWS_INDIRECT_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'service': {
......@@ -96,7 +96,7 @@ GWS_INDIRECT_SCHEMA = {
# much less strict version of the actual schema
MULTICAST_SUBSCRIPTION_LIST_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'definitions': {
'subscription': {
......
......@@ -2,10 +2,13 @@ import itertools
import os
import re
import jsonschema
from lxml import etree
import pytest
import responses
from brian_polling_manager.interface_stats import \
PHYSICAL_INTERFACE_COUNTER_SCHEMA, LOGICAL_INTERFACE_COUNTER_SCHEMA
from brian_polling_manager.interface_stats import juniper
from brian_polling_manager import inventory
......@@ -27,19 +30,19 @@ def _cached_stats_doc_filename(router_fqdn):
with open(data_filename) as f:
return etree.parse(f)
# @pytest.mark.parametrize('router_fqdn', ROUTERS)
# def test_physical_counters(router_fqdn):
# doc = _cached_stats_doc_filename(router_fqdn)
# for ifc in juniper.physical_interface_counters(doc):
# print(ifc)
#
#
# @pytest.mark.parametrize('router_fqdn', ROUTERS)
# def test_logical_counters(router_fqdn):
# def test_validate_physical_counter_schema(router_fqdn):
# doc = _cached_stats_doc_filename(router_fqdn)
# for ifc in juniper.logical_interface_counters(doc):
# print(ifc)
# for ifc in juniper.physical_interface_counters(doc):
# jsonschema.validate(ifc, PHYSICAL_INTERFACE_COUNTER_SCHEMA)
@pytest.mark.parametrize('router_fqdn', ROUTERS)
def test_logical_counters(router_fqdn):
doc = _cached_stats_doc_filename(router_fqdn)
for ifc in juniper.logical_interface_counters(doc):
jsonschema.validate(ifc, LOGICAL_INTERFACE_COUNTER_SCHEMA)
def poller_interfaces():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment