Commit 47c0305d authored by Matous Holinka's avatar Matous Holinka

mh-bird_tables: minor changes

parent 185d041b
......@@ -17,13 +17,13 @@ def test_wait():
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_krt_routes_ipv4(exp_devs: str):
"""IPv4: get the content of KERNEL tables and check it"""
tk.test_krt_routes("krt4", exp_devs)
tk.test_krt_routes("krt4", exp_devs, "IPv4")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_krt_routes_ipv6(exp_devs: str):
"""IPv6: get the content of KERNEL tables and check it"""
tk.test_krt_routes("krt6", exp_devs)
tk.test_krt_routes("krt6", exp_devs, "IPv6")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
......@@ -32,7 +32,7 @@ def test_bird_routes_ipv4(exp_devs: str):
tk.test_bird_routes("bird", exp_devs, "master4")
# @pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
# def test_bird_routes_ipv6(exp_devs: str):
# """IPv6: get the content of BIRD tables and check it"""
# tk.test_bird_routes("bird", exp_devs, "master6")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("bird", exp_devs, "master6")
#!/bin/sh
. tests/strip_output
strip_interfaces_dev | strip_addresses
\ No newline at end of file
if [ $1 = "IPv4" ]; then variant=4; fi
if [ $1 = "IPv6" ]; then variant=6; fi
ip "-$variant" route show $2 \
| strip_interfaces_dev \
| strip_addresses
\ No newline at end of file
......@@ -6,28 +6,28 @@ import subprocess
import tests.config as cf
def test_krt_routes(key: str, dev: str) -> None:
def test_krt_routes(key: str, dev: str, ip: str) -> None:
if cf.save:
save_krt_routes(key, dev, cf.datadir)
save_krt_routes(key, dev, ip, cf.datadir)
else:
check_krt_routes_timeout(key, dev)
check_krt_routes_timeout(key, dev, ip)
def save_krt_routes(key: str, dev: str, loc: str = "temp") -> None:
ip = 4 if key == "krt4" else 6
def save_krt_routes(key: str, dev: str, ip: str, loc: str = "temp") -> None:
os.system(
f"""\
ip netns exec {dev} ip -{ip} route show \
table main | ./tests/get_stdout_krt > \
ip netns exec {dev} \
./tests/get_stdout_krt '{ip}'\
'table main' > \
{loc}/{key}-{dev}
"""
)
def check_krt_routes_timeout(key: str, dev: str) -> None:
def check_krt_routes_timeout(key: str, dev: str, ip: str) -> None:
timeout = 60
for sec in range(timeout):
if check_krt_routes(key, dev):
if check_krt_routes(key, dev, ip):
assert 1
elif sec == timeout - 1:
assert 0
......@@ -35,8 +35,8 @@ def check_krt_routes_timeout(key: str, dev: str) -> None:
time.sleep(1)
def check_krt_routes(key: str, dev: str) -> None:
save_krt_routes(key, dev)
def check_krt_routes(key: str, dev: str, ip: str) -> None:
save_krt_routes(key, dev, ip)
current_table = read_file(f"temp/{key}-{dev}")
saved_table = read_file(f"{cf.datadir}/{key}-{dev}")
......@@ -55,7 +55,7 @@ def save_bird_routes(key: str, dev: str, table: str, loc: str = "temp") -> None:
os.system(
f"""\
./tests/get_stdout_bird '{dev}' \
{table} > {loc}/{key}-{dev}
{table} > {loc}/{table}-{dev}
"""
)
......@@ -73,8 +73,8 @@ def check_bird_routes_timeout(key: str, dev: str, table: str) -> None:
def check_bird_routes(key: str, dev: str, table: str) -> None:
save_bird_routes(key, dev, table)
current_table = read_file(f"temp/{key}-{dev}")
saved_table = read_file(f"{cf.datadir}/{key}-{dev}")
current_table = read_file(f"temp/{table}-{dev}")
saved_table = read_file(f"{cf.datadir}/{table}-{dev}")
for _ in current_table:
return saved_table == current_table
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment