Skip to content
Snippets Groups Projects
Commit a2b3dc6d authored by Maryam Mokhtarifar's avatar Maryam Mokhtarifar
Browse files

write unit test

parent e08fa065
No related branches found
No related tags found
1 merge request!16Implement get_router_dashboard_data and _provision_vlan_dashboards
......@@ -569,6 +569,7 @@ def get_router_dashboard_data(interfaces):
'hostname': host
})
# return dict(sorted(result.items(),key=lambda item: item[0]))
return result
......
......@@ -11,7 +11,8 @@ TEST_INTERFACES = [
"name": "ge-0/0/8",
"bundle": [],
"bundle-parents": [],
"description": "PHY CUSTOMER GEANT CORPORATE SRF000001 | GEANT Corporate to MX1.LON - Via Vodafone", # noqa: E501
"description": "PHY CUSTOMER GEANT CORPORATE SRF000001 | GEANT Corporate to MX1.LON - Via Vodafone",
# noqa: E501
"circuits": [
{
"id": 679232,
......@@ -41,7 +42,8 @@ TEST_INTERFACES = [
"name": "ge-0/0/8.10",
"bundle": [],
"bundle-parents": [],
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE-ViaVodafone | GEANT Corporate to mx1.lon - Via Vodafone ", # noqa: E501
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE-ViaVodafone | GEANT Corporate to mx1.lon - Via Vodafone ",
# noqa: E501
"circuits": [
{
"id": 679360,
......@@ -75,7 +77,8 @@ TEST_INTERFACES = [
"name": "ge-0/0/8.11",
"bundle": [],
"bundle-parents": [],
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE_ViaVodafone-VRF | GEANT Corporate to mx1.lon - Via Vodafone - for VRF", # noqa: E501
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE_ViaVodafone-VRF | GEANT Corporate to mx1.lon - Via Vodafone - for VRF",
# noqa: E501
"circuits": [
{
"id": 712144,
......@@ -107,7 +110,8 @@ TEST_INTERFACES = [
"name": "ge-0/0/8.12",
"bundle": [],
"bundle-parents": [],
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE_ViaVodafone-VRF-TEST | GEANT Corporate to mx1.lon - Via Vodafone - DASHBOARD BGP TEST VLAN", # noqa: E501
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_CORPORATE_ViaVodafone-VRF-TEST | GEANT Corporate to mx1.lon - Via Vodafone - DASHBOARD BGP TEST VLAN",
# noqa: E501
"circuits": [
{
"id": 678920,
......@@ -139,7 +143,8 @@ TEST_INTERFACES = [
"name": "ge-0/0/8.996",
"bundle": [],
"bundle-parents": [],
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_OPERATIONS_LabConnectivity | GEANT MX1.LON Infinera VRF to Operations Lab", # noqa: E501
"description": "SRV_GLOBAL CUSTOMER GEANT #GEANT_OPERATIONS_LabConnectivity | GEANT MX1.LON Infinera VRF to Operations Lab",
# noqa: E501
"circuits": [
{
"id": 678999,
......@@ -725,14 +730,14 @@ def populate_inventory(get_test_data, data_config):
("NREN Access", [], {'ASNET-AM', 'CESNET', 'GEANT', 'KIAE', 'LITNET', 'SWITCH'}),
("NREN Access", ["GEANT", "KIAE"], {'ASNET-AM', 'CESNET', 'LITNET', 'SWITCH'}),
(
"NREN Access",
[],
{'ASNET-AM', "LITNET", "CESNET", "GEANT", "KIAE", "SWITCH"},
"NREN Access",
[],
{'ASNET-AM', "LITNET", "CESNET", "GEANT", "KIAE", "SWITCH"},
),
(
"NREN Access",
["GEANT"],
{'ASNET-AM', "LITNET", "CESNET", "KIAE", "SWITCH"},
"NREN Access",
["GEANT"],
{'ASNET-AM', "LITNET", "CESNET", "KIAE", "SWITCH"},
),
("testfolder", ["GEANT"], {"KIAE", "SWITCH"}),
],
......@@ -891,6 +896,122 @@ def test_provision_re_peer_dashboard(
assert len(panels[-1]['panels'][0]) > 0
@responses.activate
def test_vlan_interfaces(mocker, data_config, mock_grafana, reporting_provider, populate_inventory
):
interfaces = [
{'bundle': ['et-4/0/0', 'et-5/0/5', 'et-8/1/2', 'et-8/1/5'],
'bundle-parents': ['et-4/0/0', 'et-5/0/5', 'et-8/1/2', 'et-8/1/5'], 'circuits': [],
'dashboard_info': {'interface_type': 'AGGREGATE', 'name': 'REDIRIS'}, 'dashboards': ['NREN', 'RE_CUST'],
'dashboards_info': [{'interface_type': 'AGGREGATE', 'name': 'REDIRIS'}],
'description': 'LAG CUSTOMER REDIRIS SRF21114 $GA-01800 |', 'ipv4': [], 'ipv6': [], 'name': 'ae16',
'port_type': 'ACCESS', 'router': 'mx1.mad.es.geant.net', 'snmp-index': 654, 'vlan_type': 'TRUNK'},
{'bundle': [], 'bundle-parents': ['et-4/0/0', 'et-5/0/5', 'et-8/1/2', 'et-8/1/5'], 'circuits': [
{'id': 739804, 'name': 'UC3M-REDIRIS-BELNET-SLICES-IMEC', 'status': 'non-monitored', 'type': 'GEANT PLUS'}],
'dashboard_info': {'interface_type': 'LOGICAL', 'name': 'REDIRIS'},
'dashboards': ["VLAN Interfaces"],
'dashboards_info': [{'interface_type': 'LOGICAL', 'name': 'REDIRIS'},
{'interface_type': 'LOGICAL', 'name': 'BELNET'}],
'description': 'SRV_L2CIRCUIT CUSTOMER REDIRIS BELNET #UC3M-RedIRIS-BELNET-SLICES-IMEC $GS-02514 |',
'ipv4': [], 'ipv6': [], 'name': 'ae16.975', 'port_type': 'SERVICE', 'router': 'mx1.mad.es.geant.net',
'snmp-index': 818, 'vlan_type': 'VLAN'},
{'bundle': [], 'bundle-parents': ['et-4/0/0', 'et-5/0/5', 'et-8/1/2', 'et-8/1/5'], 'circuits': [
{'id': 732759, 'name': 'FRA-MAD-RARE-REDIRIS-23017-VL201', 'status': 'non-monitored',
'type': 'GEANT PLUS'}], 'dashboard_info': {'interface_type': 'LOGICAL', 'name': 'RARE'},
'dashboards': ['L2_CIRCUIT'], 'dashboards_info': [{'interface_type': 'LOGICAL', 'name': 'RARE'},
{'interface_type': 'LOGICAL', 'name': 'REDIRIS'}],
'description': 'SRV_L2CIRCUIT CUSTOMER RARE REDIRIS #fra-mad-RARE-REDIRIS-23017-VL201 $GS-02274', 'ipv4': [],
'ipv6': [], 'name': 'ae16.201', 'port_type': 'SERVICE', 'router': 'mx1.mad.es.geant.net', 'snmp-index': 642,
'vlan_type': 'VLAN'},
{'bundle': [], 'bundle-parents': [], 'circuits': [
{'id': 729417, 'name': 'PAR-LON2-SUPERPOP-QFX-2-GEANT', 'status': 'operational', 'type': 'GEANT - GBS'}],
'dashboard_info': {'interface_type': 'LOGICAL', 'name': 'GEANT-IT'}, 'dashboards': ['GBS_10G'],
'dashboards_info': [{'interface_type': 'LOGICAL', 'name': 'GEANT-IT'}],
'description': 'SRV_10GGBS CUSTOMER GEANT-IT #par-lon2-SUPERPOP-QFX-2-GEANT $GS-00081 |', 'ipv4': [],
'ipv6': [], 'name': 'xe-2/2/7.0', 'port_type': 'SERVICE', 'router': 'mx1.lon2.uk.geant.net', 'snmp-index': 613,
'vlan_type': 'VLAN'},
{'bundle': ['xe-0/1/0', 'xe-0/1/1'], 'bundle-parents': ['xe-0/1/0', 'xe-0/1/1'], 'circuits': [],
'dashboard_info': {'interface_type': 'AGGREGATE', 'name': 'LITNET'}, 'dashboards': ['NREN', 'RE_CUST'],
'dashboards_info': [{'interface_type': 'AGGREGATE', 'name': 'LITNET'}],
'description': 'LAG CUSTOMER LITNET AP2 #LITNET-AP2-LAG $GA-02071 |', 'ipv4': [], 'ipv6': [], 'name': 'ae10',
'port_type': 'ACCESS', 'router': 'art1.kau.lt.geant.net', 'snmp-index': 588, 'vlan_type': 'TRUNK'},
{'bundle': [], 'bundle-parents': ['et-0/0/2'], 'circuits': [
{'id': 679356, 'name': 'LAT-AP1-IPV6', 'status': 'operational', 'type': 'GEANT IP'}],
'dashboard_info': {'interface_type': 'LOGICAL', 'name': 'LAT'},
'dashboards': ['NREN', 'RE_CUST'],
'dashboards_info': [{'interface_type': 'LOGICAL', 'name': 'LAT'}],
'description': 'SRV_GLOBAL CUSTOMER LAT #LAT-AP1 $GS-00484 | ASN5538',
'ipv4': ['62.40.124.237/30'], 'ipv6': ['2001:798:99:1::51/126'], 'name': 'ae10.83',
'port_type': 'SERVICE', 'router': 'art1.kau.lt.geant.net', 'snmp-index': 604,
'vlan_type': 'VLAN'},
{'bundle': [], 'bundle-parents': ['et-2/1/2', 'et-2/1/5', 'et-11/1/0'], 'circuits': [
{'id': 707643, 'name': 'GARR-UDMILANO_EXPRESSROUTE_VLAN4086', 'status': 'operational',
'type': 'EXPRESS ROUTE'}], 'dashboard_info': {'interface_type': 'LOGICAL', 'name': 'GARR'},
'dashboards': ['GCS'], 'dashboards_info': [{'interface_type': 'LOGICAL', 'name': 'GARR'}],
'description': 'SRV_GCS CUSTOMER GARR MICROSOFT #GARR-UDMilano_ExpressRoute_Vlan4086 $GS-01148 | UNIT CONFIGURATION HAS BEEN SYSTEM GENERATED',
'ipv4': [], 'ipv6': [], 'name': 'ae10.4086', 'port_type': 'SERVICE', 'router': 'art1.kau.lt.geant.net',
'snmp-index': 795, 'vlan_type': 'VLAN'},
{'bundle': [], 'bundle-parents': [], 'circuits': [],
'dashboard_info': {'interface_type': 'PHYSICAL', 'name': 'BUD-ZAG'}, 'dashboards': ['INFRASTRUCTURE_BACKBONE'],
'dashboards_info': [{'interface_type': 'PHYSICAL', 'name': 'BUD-ZAG'}],
'description': 'PHY INFRASTRUCTURE BACKBONE P_ae5 | BUD-ZAG', 'ipv4': [], 'ipv6': [], 'name': 'et-7/0/2',
'port_type': 'UNKNOWN', 'router': 'mx1.bud.hu.geant.net', 'snmp-index': 1133, 'vlan_type': 'ACCESS'},
]
populate_inventory(
{
"/poller/interfaces": interfaces,
"/data/interfaces": interfaces,
"/poller/eumetsat-multicast": EUMETSAT_MULTICAST,
"/poller/regions": NREN_REGIONS,
}
)
_mocked_gws = mocker.patch(
"brian_dashboard_manager.grafana.provision.get_gws_direct"
)
_mocked_gws.return_value = []
_mocked_gws_indirect = mocker.patch(
"brian_dashboard_manager.grafana.provision.get_gws_indirect"
)
_mocked_gws_indirect.return_value = []
# _mocked_vlan_data = mocker.patch(
# "brian_dashboard_manager.grafana.provision.get_router_dashboard_data"
# )
# _mocked_vlan_data.return_value = []
#
# _mocked_dashboard_data_dropdown = mocker.patch(
# "brian_dashboard_manager.grafana.provision.get_dashboard_data_dropdown"
# )
# _mocked_dashboard_data_dropdown.return_value = []
data_config["organizations"] = [
{"name": "Testorg1", "excluded_nrens": ["GEANT"], "excluded_dashboards": []},
]
provision(data_config)
folder_uid = "VLAN_Interfaces"
# assert len(mock_grafana.folders[folder_uid]) == 1
result = mock_grafana.dashboards_by_folder_uid[folder_uid]
assert len(result) == 3
# assert result[0]["title"] == "art1.kau.lt.geant.net"
assert result[0]["tags"][0] == "vlandash"
panels = mock_grafana.dashboards_by_folder_uid[folder_uid][0]["panels"]
expected_types = ["text", "row"]
assert [p["type"] for p in panels] == expected_types
assert "INFO" in panels[0]["options"]["content"]
# assert "ae10" in panels[1]["title"]
# assert len(panels[1]["panels"]) == 3
@responses.activate
@pytest.mark.parametrize(
"folder_name, dashboard_id, expected_dashboard_count",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment