summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-12-02 17:07:14 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2024-12-02 18:44:53 +0100
commitd1301f1c2a891704df8a2af56fbd4bbc7c08562b (patch)
tree67c298a5b010a9b0720b0104afefc4425e6b551f
parenttests: save bmp pcap in logdir instead of /tmp (diff)
downloadfrr-d1301f1c2a891704df8a2af56fbd4bbc7c08562b.tar.xz
frr-d1301f1c2a891704df8a2af56fbd4bbc7c08562b.zip
topotests: save bgp_bmp json temp files to bmp log folder instead of /tmp
Some temporary files are hardwritten in /tmp folder. Use the bmp log folder instead. Replace the bmp log file argument with bmp log folder. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
-rw-r--r--tests/topotests/bgp_bmp/bgpbmp.py33
-rw-r--r--tests/topotests/bgp_bmp/test_bgp_bmp_1.py2
-rw-r--r--tests/topotests/bgp_bmp/test_bgp_bmp_2.py2
3 files changed, 28 insertions, 9 deletions
diff --git a/tests/topotests/bgp_bmp/bgpbmp.py b/tests/topotests/bgp_bmp/bgpbmp.py
index 950ffef2f..41995e2b5 100644
--- a/tests/topotests/bgp_bmp/bgpbmp.py
+++ b/tests/topotests/bgp_bmp/bgpbmp.py
@@ -49,11 +49,19 @@ def bmp_update_seq(bmp_collector, bmp_log_file):
def bmp_update_expected_files(
- bmp_actual, expected_prefixes, bmp_log_type, policy, step, bmp_client
+ bmp_actual,
+ expected_prefixes,
+ bmp_log_type,
+ policy,
+ step,
+ bmp_client,
+ bmp_log_folder,
):
tgen = get_topogen()
- with open(f"/tmp/bmp-{bmp_log_type}-{policy}-step{step}.json", "w") as json_file:
+ with open(
+ f"{bmp_log_folder}/tmp/bmp-{bmp_log_type}-{policy}-step{step}.json", "w"
+ ) as json_file:
json.dump(bmp_actual, json_file, indent=4)
out = bmp_client.vtysh_cmd("show bgp vrf vrf1 ipv4 json", isjson=True)
@@ -70,8 +78,10 @@ def bmp_update_expected_files(
continue
filtered_out["routes"][pfx] = None
- # ls /tmp/show*json | while read file; do egrep -v 'prefix|network|metric|ocPrf|version|weight|peerId|vrf|Version|valid|Reason|fe80' $file >$(basename $file); echo >> $(basename $file); done
- with open(f"/tmp/show-bgp-ipv4-{bmp_log_type}-step{step}.json", "w") as json_file:
+ # ls {bmp_log_folder}/tmp/show*json | while read file; do egrep -v 'prefix|network|metric|ocPrf|version|weight|peerId|vrf|Version|valid|Reason|fe80' $file >$(basename $file); echo >> $(basename $file); done
+ with open(
+ f"{bmp_log_folder}/tmp/show-bgp-ipv4-{bmp_log_type}-step{step}.json", "w"
+ ) as json_file:
json.dump(filtered_out, json_file, indent=4)
out = tgen.gears["r1"].vtysh_cmd("show bgp vrf vrf1 ipv6 json", isjson=True)
@@ -88,7 +98,9 @@ def bmp_update_expected_files(
continue
filtered_out["routes"][pfx] = None
- with open(f"/tmp/show-bgp-ipv6-{bmp_log_type}-step{step}.json", "w") as json_file:
+ with open(
+ f"{bmp_log_folder}/tmp/show-bgp-ipv6-{bmp_log_type}-step{step}.json", "w"
+ ) as json_file:
json.dump(filtered_out, json_file, indent=4)
@@ -98,7 +110,7 @@ def bmp_check_for_prefixes(
policy,
step,
bmp_collector,
- bmp_log_file,
+ bmp_log_folder,
bmp_client,
expected_json_path,
update_expected_json,
@@ -111,6 +123,7 @@ def bmp_check_for_prefixes(
"""
global SEQ
+ bmp_log_file = f"{bmp_log_folder}/bmp.log"
# we care only about the new messages
messages = [
m
@@ -173,7 +186,13 @@ def bmp_check_for_prefixes(
== set(expected_prefixes)
):
bmp_update_expected_files(
- actual, expected_prefixes, bmp_log_type, policy, step, bmp_client
+ actual,
+ expected_prefixes,
+ bmp_log_type,
+ policy,
+ step,
+ bmp_client,
+ bmp_log_folder,
)
return topotest.json_cmp(actual, expected, exact=True)
diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_1.py b/tests/topotests/bgp_bmp/test_bgp_bmp_1.py
index 9fc8e1277..614286344 100644
--- a/tests/topotests/bgp_bmp/test_bgp_bmp_1.py
+++ b/tests/topotests/bgp_bmp/test_bgp_bmp_1.py
@@ -158,7 +158,7 @@ def _test_prefixes(policy, vrf=None, step=0):
policy,
step,
tgen.gears["bmp1"],
- os.path.join(tgen.logdir, "bmp1", "bmp.log"),
+ os.path.join(tgen.logdir, "bmp1"),
tgen.gears["r1"],
f"{CWD}/bmp1",
UPDATE_EXPECTED_JSON,
diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_2.py b/tests/topotests/bgp_bmp/test_bgp_bmp_2.py
index 21e4ce8ab..b45452e7c 100644
--- a/tests/topotests/bgp_bmp/test_bgp_bmp_2.py
+++ b/tests/topotests/bgp_bmp/test_bgp_bmp_2.py
@@ -166,7 +166,7 @@ def _test_prefixes(policy, step=1):
policy,
step,
tgen.gears["bmp1vrf"],
- os.path.join(tgen.logdir, "bmp1vrf", "bmp.log"),
+ os.path.join(tgen.logdir, "bmp1vrf"),
tgen.gears["r1vrf"],
f"{CWD}/bmp1vrf",
UPDATE_EXPECTED_JSON,