@@ -129,6 +129,63 @@ def test_fpm_install_routes():
129129 assert success , "Unable to remove 10000 routes: {}" .format (result )
130130
131131
132+ def test_fpm_conneted_and_local_routes ():
133+ "Test that conneted and local routes"
134+
135+ tgen = get_topogen ()
136+ router = tgen .gears ["r1" ]
137+
138+ # Let's check added routes
139+ router_count = 1
140+ router .vtysh_cmd (
141+ """
142+ configure terminal
143+ interface r1-eth0
144+ ip address 10.10.10.10 peer 10.10.10.11/24
145+ """
146+ )
147+
148+ def check_r1_connected_routes ():
149+ output = router .run (
150+ "pkill -SIGUSR1 fpm_listener; grep '10.10.10.0/24' /tmp/fpm_test.data | wc -l"
151+ )
152+ return int (output )
153+
154+ def check_r1_local_routes ():
155+ output = router .run (
156+ "pkill -SIGUSR1 fpm_listener; grep '10.10.10.10/32' /tmp/fpm_test.data | wc -l"
157+ )
158+ return int (output )
159+
160+ success , result = topotest .run_and_expect (
161+ check_r1_connected_routes , router_count , count = 30 , wait = 1
162+ )
163+ assert success , f"Failed to find { result } connected routes"
164+ success , result = topotest .run_and_expect (
165+ check_r1_local_routes , router_count , count = 30 , wait = 1
166+ )
167+ assert success , f"Failed to find { result } local routes"
168+
169+ # Let's check removed routes
170+ router_count = 0
171+ router .vtysh_cmd (
172+ """
173+ configure terminal
174+ interface r1-eth0
175+ no ip address 10.10.10.10 peer 10.10.10.11/24
176+ """
177+ )
178+
179+ success , result = topotest .run_and_expect (
180+ check_r1_connected_routes , router_count , count = 30 , wait = 1
181+ )
182+ assert success , f"Failed to find { result } connected routes"
183+ success , result = topotest .run_and_expect (
184+ check_r1_local_routes , router_count , count = 30 , wait = 1
185+ )
186+ assert success , f"Failed to find { result } local routes"
187+
188+
132189if __name__ == "__main__" :
133190 args = ["-s" ] + sys .argv [1 :]
134191 sys .exit (pytest .main (args ))
0 commit comments