@ -138,18 +138,18 @@ in {
} ;
testScript = ''
def compare_tables ( expected , actual ) :
assert (
expected == actual
) , " " "
Routing tables don't match !
Expected :
{ }
Actual :
{ }
" " " . f o r m a t (
expected , actual
)
import json
def compare ( raw_json , to_compare ) :
data = json . loads ( raw_json )
assert len ( raw_json ) >= len ( to_compare )
for i , row in enumerate ( to_compare ) :
actual = data [ i ]
assert len ( row . keys ( ) ) > 0
for key , value in row . items ( ) :
assert value == actual [ key ] , f " " "
In entry { i } , value { key }: got : { actual [ key ] } , expected { value }
" " "
start_all ( )
@ -178,14 +178,28 @@ in {
# Check that networkd properly configures the main routing table
# and the routing tables for the VRF.
with subtest ( " c h e c k v r f r o u t i n g t a b l e s " ) :
compare_tables (
client_ipv4_table , client . succeed ( " i p - 4 r o u t e l i s t | h e a d - n 2 " ) . strip ( )
compare (
client . succeed ( " i p - - j s o n - 4 r o u t e l i s t " ) ,
[
{ " d s t " : " 1 9 2 . 1 6 8 . 1 . 2 " , " d e v " : " v r f 1 " , " m e t r i c " : 100 } ,
{ " d s t " : " 1 9 2 . 1 6 8 . 2 . 3 " , " d e v " : " v r f 2 " , " m e t r i c " : 100 }
]
)
compare_tables (
vrf1_table , client . succeed ( " i p - 4 r o u t e l i s t t a b l e 2 3 | h e a d - n 4 " ) . strip ( )
compare (
client . succeed ( " i p - - j s o n - 4 r o u t e l i s t t a b l e 2 3 " ) ,
[
{ " d s t " : " 1 9 2 . 1 6 8 . 1 . 0 / 2 4 " , " d e v " : " e t h 1 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 1 . 1 " } ,
{ " t y p e " : " l o c a l " , " d s t " : " 1 9 2 . 1 6 8 . 1 . 1 " , " d e v " : " e t h 1 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 1 . 1 " } ,
{ " t y p e " : " b r o a d c a s t " , " d e v " : " e t h 1 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 1 . 1 " , " d s t " : " 1 9 2 . 1 6 8 . 1 . 2 5 5 " }
]
)
compare_tables (
vrf2_table , client . succeed ( " i p - 4 r o u t e l i s t t a b l e 4 2 | h e a d - n 4 " ) . strip ( )
compare (
client . succeed ( " i p - - j s o n - 4 r o u t e l i s t t a b l e 4 2 " ) ,
[
{ " d s t " : " 1 9 2 . 1 6 8 . 2 . 0 / 2 4 " , " d e v " : " e t h 2 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 2 . 1 " } ,
{ " t y p e " : " l o c a l " , " d s t " : " 1 9 2 . 1 6 8 . 2 . 1 " , " d e v " : " e t h 2 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 2 . 1 " } ,
{ " t y p e " : " b r o a d c a s t " , " d e v " : " e t h 2 " , " p r e f s r c " : " 1 9 2 . 1 6 8 . 2 . 1 " , " d s t " : " 1 9 2 . 1 6 8 . 2 . 2 5 5 " }
]
)
# Ensure that other nodes are reachable via ICMP through the VRF.