Commit 4a447e6e authored by Matous Holinka's avatar Matous Holinka

Minor changes (inside the test-suit files) added

parent c62f20b4
......@@ -37,3 +37,8 @@ def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6", "primary")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -37,3 +37,9 @@ def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6", "primary")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -36,3 +36,10 @@ def test_bird_routes_ipv4(exp_devs: str):
def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6", "primary")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -37,3 +37,9 @@ def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -36,3 +36,10 @@ def test_bird_routes_ipv4(exp_devs: str):
def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6", "primary")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -37,3 +37,9 @@ def test_bird_routes_ipv6(exp_devs: str):
"""IPv6: get the content of BIRD tables and check it"""
tk.test_bird_routes("master6", exp_devs, "master6")
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
......@@ -13,12 +13,6 @@ def test_wait():
tk.wait(LIMIT)
@pytest.mark.parametrize("exp_devs", EXPECTED_DEVICES)
def test_logging(exp_devs: str):
"""Check the log files. There should only DBG, INFO and TRACE messages"""
tk.test_logs(exp_devs, [])
@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"""
......
......@@ -38,10 +38,8 @@ def save_krt_routes(key: str, dev: str, family: str,
)
def check_krt_routes_timeout(key: str, dev: str,
family: str, table: str) -> None:
timeout = 60
for _ in range(timeout):
def check_krt_routes_timeout(key: str, dev: str, family: str, table: str) -> None:
for _ in range(61):
if check_krt_routes(key, dev, family, table):
return
else:
......@@ -71,10 +69,8 @@ def save_bird_routes(key: str, dev: str, table: str,
""")
def check_bird_routes_timeout(key: str, dev: str,
table: str, opts: str) -> None:
timeout = 60
for _ in range(timeout):
def check_bird_routes_timeout(key: str, dev: str, table: str, opts: str) -> None:
for _ in range(61):
if check_bird_routes(key, dev, table, opts):
return
else:
......@@ -89,47 +85,8 @@ def check_bird_routes(key: str, dev: str, table: str, opts: str) -> bool:
return saved_table == current_table
def test_ospf_neighbors(**kwargs) -> None:
if cf.save:
save_available_neighbors(
kwargs["key"],
kwargs["dev"],
kwargs["protocol"]
)
else:
check_ospf_neighbors_timeout(
kwargs["key"],
kwargs["dev"],
kwargs["protocol"]
)
def save_available_neighbors(key: str, dev: str, protocol: str,
loc: str = cf.datadir) -> None:
os.system(f"""./tests/get_ospf_neighbors '{dev}' '{protocol}' \
> {loc}/{key}-{protocol}-{dev} """)
def check_ospf_neighbors_timeout(key: str, dev: str,
protocol: str, **kwargs) -> None:
for _ in range(kwargs.get("timeout", 60)):
if check_ospf_neighbors(key, dev, protocol):
return
else:
time.sleep(1)
raise Exception(f"FAILURE! Neighbors in save/check mode are different!")
def check_ospf_neighbors(key: str, dev: str, protocol: str) -> bool:
save_available_neighbors(key, dev, protocol, loc=cf.tempdir)
return read_file(f"{cf.datadir}/{key}-{protocol}-{dev}") \
== read_file(f"{cf.tempdir}/{key}-{protocol}-{dev}")
def test_logs(
dev: str, log_messages: List[str], filename: str = "bird.log"
dev: str, log_messages, filename: str = "bird.log"
) -> None:
pattern = "DBG|TRACE|INFO"
logfile = f"{dev}/{filename}"
......@@ -141,14 +98,37 @@ def test_logs(
elif log_messages:
pattern = f"{pattern}|{'|'.join(log_messages)}"
check_expected_logs_timeout(log_messages, logfile)
if not os.system(f"egrep -v '{pattern}' {logfile}"):
assert False, "Log file contains incorrect message"
def check_expected_logs_timeout(log_messages, logfile: str) -> None:
for _ in range(59):
if check_expected_logs(log_messages, logfile):
return
else:
time.sleep(1)
assert False, "Log file contains incorrect message"
def check_expected_logs(log_messages: List[str], logfile: str) -> bool:
"""
TRUE -> if there IS NOT variable `message` in variable `logfile`
FALSE -> if there IS variable `message` in variable `logfile`
"""
for message in log_messages:
if os.system(f"egrep '{message}' {logfile}"):
return False
return True
def test_bfd_sessions(**kwargs) -> None:
if cf.save:
save_bfd_sessions(kwargs["key"], kwargs["dev"], kwargs["opts"])
else:
check_saved_table(kwargs["key"], kwargs["dev"], kwargs["opts"] )
if not os.system(f"egrep -v '{pattern}' {logfile}"):
assert False, "Log file contains incorrect message"
def save_bfd_sessions(key: str, dev: str, opts: str,
loc: str = cf.datadir) -> None:
......
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