diff --git a/test/data/update_test_data.py b/test/data/update_test_data.py index f599ae3b0a43af9f813f509207d8ea235f08f181..a0e819f9235e41536404ec3649008da6e35aad8b 100644 --- a/test/data/update_test_data.py +++ b/test/data/update_test_data.py @@ -1,3 +1,8 @@ +""" +this utility runs the juniper shell commands from dashboard +v1 and v3 on all routers and saves them to local files as +reusable unit test data +""" import logging import os import multiprocessing diff --git a/test/test_juniper_data.py b/test/test_juniper_data.py index efac80a114fee880f5627e008a16dec4e2f9bb5c..f2ba03b0a4173b05aa9142c0885c0adcd5ef0226 100644 --- a/test/test_juniper_data.py +++ b/test/test_juniper_data.py @@ -1,4 +1,5 @@ import json +import os import re import jsonschema @@ -6,6 +7,42 @@ import pytest from inventory_provider import juniper +TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data") + +ROUTER_HOSTNAMES = [ + 'mx2.ath.gr.geant.net', + 'mx1.tal.ee.geant.net', + 'mx2.tal.ee.geant.net', + 'mx2.rig.lv.geant.net', + 'mx1.kau.lt.geant.net', + 'mx2.kau.lt.geant.net', + 'mx2.zag.hr.geant.net', + 'mx2.lju.si.geant.net', + 'mx1.bud.hu.geant.net', + 'mx1.pra.cz.geant.net', + 'mx2.bra.sk.geant.net', + 'mx1.lon.uk.geant.net', + 'mx1.vie.at.geant.net', + 'mx2.bru.be.geant.net', + 'mx1.poz.pl.geant.net', + 'mx1.ams.nl.geant.net', + 'mx1.fra.de.geant.net', + 'mx1.par.fr.geant.net', + 'mx1.gen.ch.geant.net', + 'mx1.mil2.it.geant.net', + 'mx1.lis.pt.geant.net', + 'mx2.lis.pt.geant.net', + 'mx1.mad.es.geant.net', + 'mx1.sof.bg.geant.net', + 'mx1.buc.ro.geant.net', + 'mx1.ham.de.geant.net', + 'mx1.dub.ie.geant.net', + 'mx1.dub2.ie.geant.net', + 'mx1.mar.fr.geant.net', + 'mx1.lon2.uk.geant.net', + 'mx1.ath2.gr.geant.net', +] + CACHE_SCHEMA = { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", @@ -39,212 +76,6 @@ CACHE_SCHEMA = { "additionalProperties": False } -# data for mx1.ams.nl.geant.net -OLD_STYLE_V4_DATA = """ -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.133 description "Limelight " -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.20 description Microsoft -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.21 description Microsoft -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.215 description "Leaseweb " -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.231 description OVH -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.245 description OVH -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.168 description Akamai -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.208 description Akamai -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.215 description Leaseweb -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.150 description "Hurricane Electric" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.47 description IPTRANSIT -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.115 description Facebook -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.164 description "Facebook (2)" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.192 description Telenor -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.100 description Amazon -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.217 description "Amazon (2)" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.108 description BT -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.236 description COLT -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.52 description "COLT (2)" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.34 description TalkTalk -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.251 description "Free SAS" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.123 description "VODAFONE (2)" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.123 description VODAFONE -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.232 description BLACKBOARD -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.53 description Neotelekoms -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.13 description Lattelekom -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.224 description ECATEL -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.125 description MegaFon -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.234 description "SIG Telecom" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.155 description "Telindus Luxembourg" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.176 description Wikimedia -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.88 description OpenDNS -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.198 description "Nerim SAS" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.210 description "Init7 peering#1" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.210 description "Init7 peering#2" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.111 description "ISC F-root #1" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.140 description "ISC F-root #2" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.140 description CloudFlare -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.27 description Twitch_Interactive__Justin.tv_ -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.197 description Twitch_Interactive__Justin.tv_ -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.10 description Feral_Hosting -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.43 description Voxility -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.228 description NFOrce_Entertainment_BV -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.175 description NFOrce_Entertainment_BV -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.55 description Hetzner_Online_AG -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.45 description Liquid_Telecommunications -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.160 description DENIC_eG,_AS31529 -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.160 description Apple_Inc -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.183 description Apple_Inc -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.92 description Netnod -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.56 description Netnod -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.124 description Incapsula -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.51 description RDSnet -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.162 description EdgeCast_Networks,_Inc. -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.151 description EdgeCast_Networks,_Inc. -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.82 description SoftLayer_Technologies,_Inc._an_IBM_Company -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.217 description PT_Comunicacoes_S.A. -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.23 description Valve_Corporation -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.164 description Dailymotion -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.46 description Bezeq_International -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.113 description Code_42_Software,_Inc. -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.174 description "Blue_Jeans_Network,_Inc. AS18541" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.14 description "Dropbox AS19679" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.93 description "ONLINE AS12876" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.63 description "M247_Ltd AS9009" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.62 description "Spotify AS8403" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.94 description "Highwinds_Network_Group,_Inc AS12989" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.70 description "Highwinds_Network_Group,_Inc AS12989" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.183 description "FASTLY AS54113" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.184 description "FASTLY AS54113" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.209 description Limelight -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.216 description "RETN AS9002" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.153 description "VIMPELCOM AS3216" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.217 description "ATOM86 AS8455" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.60 description "Post_Group_Luxembourg AS6661" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.232 description "VeriSign AS7342" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.130 description "Twitter,_Inc. AS13414" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.46 description "Twitter,_Inc. AS13414" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.41 description "DSTORAGE AS198792" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.187 description "Internap AS29791" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.213.152 description "ONLINE AS12876" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.128 description "Core-Backbone_GmbH AS33891" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.212 description "Automattic AS2635" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.250 description "Netflix AS2906" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.250 description "Netflix AS2906" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.250 description "Packet_Clearing_House AS42" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.250 description "Packet_Clearing_House AS3856" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.45 description "USC_/_UFMG_PEERING_Research_Testbed AS47065" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.110 description "Oath,_Inc. AS10310" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.163 description "Oath,_Inc. AS10310" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.136 description "Canadian_Internet_Registration_Authority_-_.CA_Registry AS55195" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.191 description "CDNetworks_Inc. AS36408" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.106 description "CDNetworks_Inc. AS36408" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.38 description "Choopa,_LLC AS20473" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.211.200 description "Yandex_LLC AS13238" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.210.150 description "G-Core_Labs_S.A. AS199524" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.132 description "RIPE_NCC AS197000" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.69 description "RIPE_NCC AS12654" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.213.234 description "IP_Transit,_Inc. AS46786" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.82 description "Claranet AS8426" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.209.228 description "Claranet AS8426" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.212.146 description "ViewQwest AS18106" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.122 description "Zayo_Group AS6461" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.213.122 description "Highwinds_Network_Group,_Inc AS33438" -set routing-instances IAS protocols bgp group GEANT-IX-AMS-IX neighbor 80.249.208.39 description "OARC,_Inc. AS112" -""" - -OLD_STYLE_V6_DATA = """ -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:6265:2 description "Leaseweb " -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:6276:1 description OVH -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:6276:2 description OVH -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8075:1 description Microsoft -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8075:2 description Microsoft -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:940:2 description Akamai -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:940:1 description Akamai -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:2822:1 description Limelight -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:6265:1 description Leaseweb -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:6939:1 description "Hurricane Electric" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8708:1 description RDSnet -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:6786:1 description IPTRANSIT -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:2934:1 description Facebook -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:2934:2 description "Facebook (2)" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8220:1 description COLT -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8220:2 description "COLT (2)" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3285:1 description TalkTalk -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2322:1 description "Free SAS" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:3209:2 description "VODAFONE (2)" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:3209:1 description VODAFONE -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8218:2 description Neotelekoms -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2578:1 description Lattelekom -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:9073:1 description ECATEL -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:1133:1 description MegaFon -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:932:1 description "SIG Telecom" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a505:6665:1 description "Telindus Luxembourg" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:4907:1 description Wikimedia -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:6692:1 description OpenDNS -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3030:1 description "Init7 peering#1" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3030:2 description "Init7 peering#2" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:132:1 description "ISC F-root #1" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:132:2 description "ISC F-root #2" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3335:1 description CloudFlare -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1:0:a500:20:52:1 description Feral_Hosting -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:3350:2 description NFOrce_Entertainment_BV -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:3350:1 description NFOrce_Entertainment_BV -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:4940:1 description Hetzner_Online_AG -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:0844:1 description Liquid_Telecommunications -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:1529:1 description DENIC_eG,_AS31529 -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:0714:1 description Apple_Inc -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:0714:2 description Apple_Inc -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8674:1 description Netnod -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8674:2 description Netnod -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:9551:1 description Incapsula -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:5133:1 description EdgeCast_Networks,_Inc. -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:5133:2 description EdgeCast_Networks,_Inc. -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:6351:1 description SoftLayer_Technologies,_Inc._an_IBM_Company -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8657:1 description PT_Comunicacoes_S.A. -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:2590:1 description Valve_Corporation -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8551:1 description Bezeq_International -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a506:2715:1 description Code_42_Software,_Inc. -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3193:1 description "Nerim SAS" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:5400:1 description BT -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:2119:1 description Telenor -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:9679:1 description "Dropbox AS19679" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2876:2 description "ONLINE AS12876" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:9009:1 description "M247_Ltd AS9009" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8403:1 description "Spotify AS8403" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2989:1 description "Highwinds_Network_Group,_Inc AS12989" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2989:2 description "Highwinds_Network_Group,_Inc AS12989" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:2822:2 description Limelight -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:9002:1 description "RETN AS9002" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:3216:1 description "VIMPELCOM AS3216" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8455:1 description "ATOM86 AS8455" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:6661:1 description "Post_Group_Luxembourg AS6661" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a505:4113:1 description "FASTLY AS54113" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a505:4113:2 description "FASTLY AS54113" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:7342:1 description "VeriSign AS7342" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3414:1 description "Twitter,_Inc. AS13414" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3414:2 description "Twitter,_Inc. AS13414" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a519:8792:1 description "DSTORAGE AS198792" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:9791:1 description "Internap AS29791" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:3891:1 description "Core-Backbone_GmbH AS33891" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:2635:1 description "Automattic AS2635" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:2906:1 description "Netflix AS2906" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:2906:2 description "Netflix AS2906" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:1690:1 description "Dailymotion AS41690" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:42:1 description "Packet_Clearing_House AS42" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:3856:1 description "Packet_Clearing_House AS3856" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:7065:1 description "USC_/_UFMG_PEERING_Research_Testbed AS47065" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:310:1 description "Oath,_Inc. AS10310" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:310:2 description "Oath,_Inc. AS10310" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a505:5195:1 description "Canadian_Internet_Registration_Authority_-_.CA_Registry AS55195" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a502:473:1 description "Choopa,_LLC AS20473" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:3238:1 description "Yandex_LLC AS13238" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1:0:a500:19:9524:1 description "G-Core_Labs_S.A. AS199524" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1:0:a500:19:7000:1 description "RIPE_NCC AS197000" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:2654:1 description "RIPE_NCC AS12654" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a504:6786:2 description "IP_Transit,_Inc. AS46786" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8426:1 description "Claranet AS8426" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:8426:2 description "Claranet AS8426" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a501:8106:1 description "ViewQwest AS18106" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:6461:1 description "Zayo_Group AS6461" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a503:3438:1 description "Highwinds_Network_Group,_Inc AS33438" -set routing-instances IAS protocols bgp group GEANT-IXv6-AMS-IX neighbor 2001:7f8:1::a500:112:1 description "OARC,_Inc. AS112" -""" @pytest.fixture @@ -255,7 +86,7 @@ def cached_test_data(): return cache -def _old_data(s): +def _parsed_old_style_output_data(s): for l in s.splitlines(): if not l: continue @@ -277,14 +108,30 @@ def _old_data(s): } -def test_ipv4_neighbors(cached_test_data): - return - old_v4_data = dict((x["neighbor"], x) for x in _old_data(OLD_STYLE_V4_DATA)) +@pytest.fixture(params=ROUTER_HOSTNAMES) +def router_output(request): + output = {} + for key in ["bgpv4", "bgpv6", "bgp", "interfaces", "vrr"]: + filename = os.path.join( + TEST_DATA_DIR, + "%s-%s.output" % (request.param, key)) + with open(filename) as f: + output[key] = f.read() + return output + + +def test_ipv4_neighbors(router_output): - k = "mx1.ams.nl.geant.net" - v = cached_test_data[k] + old_v4_data = dict([ + (x["neighbor"], x) + for x in + _parsed_old_style_output_data(router_output["bgpv4"])]) + + parsers = dict([(c["key"], c["parser"]) for c in juniper.shell_commands()]) + neighbors = parsers["bgp"]( + router_output["bgp"], + group_expression = r'^GEANT-IX[\s-].*$') - neighbors = list(juniper.neighbors(v, group_expression=r'^GEANT-IX[\s-].*')) assert len(neighbors) == len(old_v4_data) for n in neighbors: address = n["name"]["data"] @@ -292,14 +139,18 @@ def test_ipv4_neighbors(cached_test_data): assert old_v4_data[address]["description"] == description -def test_ipv6_neighbors(cached_test_data): - return - old_v6_data = dict((x["neighbor"], x) for x in _old_data(OLD_STYLE_V6_DATA)) +def test_ipv6_neighbors(router_output): + + old_v6_data = dict([ + (x["neighbor"], x) + for x in + _parsed_old_style_output_data(router_output["bgpv6"])]) - k = "mx1.ams.nl.geant.net" - v = cached_test_data[k] + parsers = dict([(c["key"], c["parser"]) for c in juniper.shell_commands()]) + neighbors = parsers["bgp"]( + router_output["bgp"], + group_expression = r'^GEANT-IXv6[\s-].*$') - neighbors = list(juniper.neighbors(v, group_expression=r'^GEANT-IXv6[\s-].*')) assert len(neighbors) == len(old_v6_data) for n in neighbors: address = n["name"]["data"] @@ -307,61 +158,17 @@ def test_ipv6_neighbors(cached_test_data): assert old_v6_data[address]["description"] == description -def test_interfaces_tmp(cached_test_data): - return - k = "mx1.ams.nl.geant.net" - v = cached_test_data[k] - # print(v["interfaces"]) - # with open("/tmp/mx1.ams.nl.geant.net.interfaces.json", "w") as f: - # f.write(json.dumps(v["interfaces"])) - - for ifc in juniper.interfaces(v): - print(ifc) - # - # interfaces = {} - # for k, v in cached_test_data.items(): - # interfaces[k] = v["interfaces"] - # with open("/tmp/interfaces.json", "w") as f: - # f.write(json.dumps(interfaces,sort_keys=True,indent=2, separators=(',', ': '))) +def test_juniper_shell_output_parsing(router_output): + """ + just call the correct parser for each type of shell output + (not a proper test ... just verifies there's no crash) + TODO: add jsonschema validation + :param router_output: + :return: + """ + for c in juniper.shell_commands(): + if c["key"] is None: + continue + c["parser"](router_output[c["key"]]) -@pytest.mark.parametrize("hostname", [ - 'mx2.ath.gr.geant.net', - 'mx1.tal.ee.geant.net', - 'mx2.tal.ee.geant.net', - 'mx2.rig.lv.geant.net', - 'mx1.kau.lt.geant.net', - 'mx2.kau.lt.geant.net', - 'mx2.zag.hr.geant.net', - 'mx2.lju.si.geant.net', - 'mx1.bud.hu.geant.net', - 'mx1.pra.cz.geant.net', - 'mx2.bra.sk.geant.net', - 'mx1.lon.uk.geant.net', - 'mx1.vie.at.geant.net', - 'mx2.bru.be.geant.net', - 'mx1.poz.pl.geant.net', - 'mx1.ams.nl.geant.net', - 'mx1.fra.de.geant.net', - 'mx1.par.fr.geant.net', - 'mx1.gen.ch.geant.net', - 'mx1.mil2.it.geant.net', - 'mx1.lis.pt.geant.net', - 'mx2.lis.pt.geant.net', - 'mx1.mad.es.geant.net', - 'mx1.sof.bg.geant.net', - 'mx1.buc.ro.geant.net', - 'mx1.ham.de.geant.net', - 'mx1.dub.ie.geant.net', - 'mx1.dub2.ie.geant.net', - 'mx1.mar.fr.geant.net', - 'mx1.lon2.uk.geant.net', - 'mx1.ath2.gr.geant.net', -]) -def test_juniper_shell_output_parsing(hostname): - result = {} - for i, c in enumerate(juniper.shell_commands()): - data_filename = "data/%s-%d.output" % (hostname, i) - with open(data_filename) as f: - output = f.read() - result[c["key"]] = c["parser"](output)