Skip to content

Commit

Permalink
add test for #708
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Sep 25, 2024
1 parent 42553f1 commit 100c4c8
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
30 changes: 30 additions & 0 deletions etc/exabgp/api-rr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
process announce-routes {
run ./run/api-rr.run;
encoder json;
}

neighbor 127.0.0.1 {
router-id 1.2.3.4;
local-address 127.0.0.1;
local-as 1;
peer-as 1;
group-updates false;

family {
ipv4 unicast;
}

capability {
route-refresh;
}
api {
processes [ announce-routes ];
receive {
parsed;
update;
}
send {
packets;
}
}
}
59 changes: 59 additions & 0 deletions etc/exabgp/run/api-rr.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

import os
import sys
import time

def check_ok():
line = sys.stdin.readline().strip()
if line != 'done':
sys.stdout.write(f'debug expected "done" not "{line}"\n')
sys.stdout.write('announce route 255.255.255.255/32 next-hop 255.255.255.255\n')
sys.stdout.flush()

try:
time.sleep(0.2)

sys.stdout.write('announce route 192.168.0.0/32 next-hop 10.0.0.0\n')
sys.stdout.flush()
time.sleep(0.2)
check_ok()

sys.stdout.write('announce route 192.168.0.1/32 next-hop 10.0.0.1\n')
sys.stdout.flush()
time.sleep(0.2)
check_ok()

sys.stdout.write('announce route-refresh ipv4 unicast\n')
sys.stdout.flush()
time.sleep(0.2)
check_ok()

valid = True

rr = sys.stdin.readline()
if '"nlri": "192.168.0.0/32"' not in rr:
valid = False
sys.stdout.write("debug " + rr + '\n')
sys.stdout.flush()

rr = sys.stdin.readline()
if '"nlri": "192.168.0.1/32"' not in rr:
valid = False
sys.stdout.write("debug " + rr + '\n')
sys.stdout.flush()

if valid:
sys.stdout.write('announce route 192.168.0.2/32 next-hop 10.0.0.1\n')
else:
sys.stdout.write('announce route 255.255.255.255/32 next-hop 255.255.255.255\n')
sys.stdout.flush()

now = time.time()
while os.getppid() != 1 and time.time() < now + 15:
line = sys.stdin.readline().strip()
if not line or 'shutdown' in line:
break
time.sleep(1)
except IOError:
pass
1 change: 1 addition & 0 deletions qa/encoding/api-rr.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api-rr.conf
5 changes: 5 additions & 0 deletions qa/encoding/api-rr.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0017:02:00000000
2:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000004005040000006420C0A80000
2:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000014005040000006420C0A80001
3:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0017:05:00010001
4:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0031:02:00000015400101004002004003040A0000014005040000006420C0A80002

0 comments on commit 100c4c8

Please sign in to comment.