-
Robert Latta authored
when processing data from the inventory_provider poller/interfaces endpoint BDM now uses dashboards_info rather than dashboard_info dashboards_info contains a list of objects rather than dashboard_info which contains a single object
Robert Latta authoredwhen processing data from the inventory_provider poller/interfaces endpoint BDM now uses dashboards_info rather than dashboard_info dashboards_info contains a list of objects rather than dashboard_info which contains a single object
test_aggregrate.py 9.85 KiB
from brian_dashboard_manager.grafana.utils.request import TokenRequest
import responses
from brian_dashboard_manager.grafana.provision import provision_aggregate
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
"Accept": ["application/json"]
}
TEST_DASHBOARD = {
"tag": "TEST_AGGREGATE",
"dashboard_name": "TEST CLS Peers",
"group_by": "remote",
"interfaces": [
{
"router": "mx1.gen.ch.geant.net",
"name": "ae23.667",
"bundle": [],
"bundle-parents": [
"et-1/0/5",
"et-5/0/2"
],
"description": "SRV_CLS PRIVATE EXOSCALE #CH-EXOSCALE-CLS|ASN61098 | ", # noqa: E501
"circuits": [
{
"id": 663057,
"name": "CH-EXOSCALE-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1276,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "EXOSCALE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "EXOSCALE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.100.26/31"
],
"ipv6": [
"2001:798::29/126"
]
},
{
"router": "mx1.fra.de.geant.net",
"name": "ae24.0",
"bundle": [],
"bundle-parents": [
"xe-10/1/5"
],
"description": "SRV_CLS PRIVATE EXOSCALE #DE-EXOSCALE-CLS|ASN61098 | ", # noqa: E501
"circuits": [
{
"id": 708254,
"name": "DE-EXOSCALE_CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1251,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "EXOSCALE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "EXOSCALE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"62.40.100.20/31"
],
"ipv6": [
"2001:798::51/126"
]
},
{
"router": "mx1.fra.de.geant.net",
"name": "ae25.0",
"bundle": [],
"bundle-parents": [
"xe-10/2/2"
],
"description": "SRV_CLS PRIVATE T-SYSTEMS #DE-T-SYSTEMS-CLS|ASN6878 | ", # noqa: E501
"circuits": [
{
"id": 708258,
"name": "DE-T-SYSTEMS-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1079,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "T-SYSTEMS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "T-SYSTEMS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"94.100.252.88/31"
],
"ipv6": []
},
{
"router": "mx1.fra.de.geant.net",
"name": "ae29.0",
"bundle": [],
"bundle-parents": [
"xe-10/1/2"
],
"description": "SRV_CLS PRIVATE AWS #DE-AWS-CLS |ASN16509 | ",
"circuits": [
{
"id": 708273,
"name": "DE-AWS-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1208,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "AWS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "AWS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"52.95.219.129/31"
],
"ipv6": [
"2620:107:4008:27b::2/64"
]
},
{
"router": "mx1.fra.de.geant.net",
"name": "ae35.0",
"bundle": [],
"bundle-parents": [
"xe-11/2/3"
],
"description": "SRV_CLS PRIVATE CLOUDFERRO #DE-CLOUDFERRO-CLS|ASN200999 | ", # noqa: E501
"circuits": [
{
"id": 708235,
"name": "DE-CLOUDFERRO-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1218,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "CLOUDFERRO",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "CLOUDFERRO",
"interface_type": "LOGICAL"
}],
"ipv4": [
"45.92.241.127/31"
],
"ipv6": []
},
{
"router": "mx1.fra.de.geant.net",
"name": "ae37.0",
"bundle": [],
"bundle-parents": [
"xe-3/3/0"
],
"description": "SRV_CLS PRIVATE ORACLE #DE-ORACLE-CLS|ASN31898 ",
"circuits": [
{
"id": 708312,
"name": "DE-ORACLE-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 1281,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "ORACLE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "ORACLE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"130.61.6.73/31"
],
"ipv6": [
"2603:c000:280::5/127"
]
},
{
"router": "mx1.vie.at.geant.net",
"name": "ae25.0",
"bundle": [],
"bundle-parents": [
"xe-4/0/4"
],
"description": "SRV_CLS PRIVATE AWS #AT-AWS-CLS|ASN16509 | ",
"circuits": [
{
"id": 708166,
"name": "AT-AWS-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 942,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "AWS",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "AWS",
"interface_type": "LOGICAL"
}],
"ipv4": [
"52.95.219.37/31"
],
"ipv6": [
"2620:107:4008:251::2/64"
]
},
{
"router": "mx1.lon.uk.geant.net",
"name": "ae24.0",
"bundle": [],
"bundle-parents": [
"xe-3/1/7"
],
"description": "SRV_CLS PRIVATE ORACLE #UK-ORACLE-CLS |ASN31898",
"circuits": [
{
"id": 708307,
"name": "UK-ORACLE-CLS",
"type": "GEANT CLOUD PEERING",
"status": "operational"
}
],
"snmp-index": 976,
"dashboards": [
"CLS",
"CLS_PEERS"
],
"dashboard_info": {
"name": "ORACLE",
"interface_type": "LOGICAL"
},
"dashboards_info": [{
"name": "ORACLE",
"interface_type": "LOGICAL"
}],
"ipv4": [
"132.145.7.81/31"
],
"ipv6": [
"2603:c000:380::9/127"
]
}
]
}
def generate_folder(data):
return {
"id": 555,
"uid": data['uid'],
"title": data['title'],
"url": f"/dashboards/f/{data['uid']}/{data['title'].lower()}",
"hasAcl": False,
"canSave": True,
"canEdit": True,
"canAdmin": True,
"createdBy": "Anonymous",
"created": "2021-02-23T15:33:46Z",
"updatedBy": "Anonymous",
"updated": "2021-02-23T15:33:46Z",
"version": 1
}
@responses.activate
def test_provision_aggregate(data_config, mocker, client):
def create_dashboard(_, dash, folder=None):
return dash
mocker.patch(
'brian_dashboard_manager.grafana.provision.create_dashboard',
create_dashboard)
request = TokenRequest(**data_config, token='test')
fake_folder = generate_folder({'uid': 'aggtest', 'title': 'aggtest'})
result = provision_aggregate(request, fake_folder, TEST_DASHBOARD,
'test_datasource')
panels = result['panels']
expected_title = f'Aggregate - {TEST_DASHBOARD["dashboard_name"]}'
assert result['title'] == expected_title
assert len(panels) == 14
assert len(panels[0]['targets']) == len(TEST_DASHBOARD['interfaces'])