From 8318b8ef7ed3248e628421bd6291eb600ef42234 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Wed, 25 Sep 2024 02:21:33 +0100 Subject: [PATCH] add test for #1237 --- etc/exabgp/api-rr.conf | 30 ++++++++++++++++++++ etc/exabgp/run/api-rr.run | 59 +++++++++++++++++++++++++++++++++++++++ qa/encoding/api-rr.ci | 1 + qa/encoding/api-rr.msg | 5 ++++ 4 files changed, 95 insertions(+) create mode 100644 etc/exabgp/api-rr.conf create mode 100755 etc/exabgp/run/api-rr.run create mode 100644 qa/encoding/api-rr.ci create mode 100644 qa/encoding/api-rr.msg diff --git a/etc/exabgp/api-rr.conf b/etc/exabgp/api-rr.conf new file mode 100644 index 000000000..f1a364c62 --- /dev/null +++ b/etc/exabgp/api-rr.conf @@ -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; + } + } +} diff --git a/etc/exabgp/run/api-rr.run b/etc/exabgp/run/api-rr.run new file mode 100755 index 000000000..8412c68e9 --- /dev/null +++ b/etc/exabgp/run/api-rr.run @@ -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 diff --git a/qa/encoding/api-rr.ci b/qa/encoding/api-rr.ci new file mode 100644 index 000000000..f75ddeb26 --- /dev/null +++ b/qa/encoding/api-rr.ci @@ -0,0 +1 @@ +api-rr.conf diff --git a/qa/encoding/api-rr.msg b/qa/encoding/api-rr.msg new file mode 100644 index 000000000..b5351f12b --- /dev/null +++ b/qa/encoding/api-rr.msg @@ -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