Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib, vtysh: fix 'show ip[v6] access-list ... json' formatting #15973

Merged
merged 1 commit into from May 14, 2024

Conversation

piotrsuchy
Copy link
Contributor

Similarly to recently fixed 'show ip[v6] prefix-list ...' - PR#15750, json output is not valid for 'show ip[v6] access-list ... json' commands, as it goes through all the running daemons and for each one it calls 'filter_show' creating a new json object. To aggreagate the output and create a valid json that can later be parsed, the commands were moved to vtysh and formatted accordingly

Before and after for json objects the same as here: PR#15750

Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also provide a topotest (in additional PR is also good) that verifies JSON integrity/validity for prefix-list, access-list, route-map (per-daemon).

vtysh/vtysh.c Show resolved Hide resolved
vtysh/vtysh.c Outdated Show resolved Hide resolved
vtysh/vtysh.c Outdated Show resolved Hide resolved
@piotrsuchy
Copy link
Contributor Author

Ok, I will prepare a topotest (in a separate PR, since I'm not sure when I'll have time for that) -> should be something simple like one frr instance, setting arbitrary ip prefix-list, ip access-list and route-map rules in configuration and later passing the whole output through a json validator / linter, right?

@ton31337
Copy link
Member

Yes

@ton31337
Copy link
Member

ci:rerun CI stuck

Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@ton31337
Copy link
Member

@Mergifyio rebase

Copy link

mergify bot commented May 14, 2024

rebase

✅ Branch has been successfully rebased

@ton31337
Copy link
Member

@piotrsuchy could you fix also the failing test?

diff --git a/tests/topotests/nb_config/test_nb_config.py b/tests/topotests/nb_config/test_nb_config.py
index 8def19ffd5..9099ef10b8 100644
--- a/tests/topotests/nb_config/test_nb_config.py
+++ b/tests/topotests/nb_config/test_nb_config.py
@@ -50,7 +50,7 @@ def test_access_list_config_ordering(tgen):
     output = r1.vtysh_cmd("show ip access-list test json")
     got = json.loads(output)
     expected = json.loads(
-        '{"ZEBRA":{"test":{"type":"Standard", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "address":"10.0.0.1", "mask":"0.0.0.0"}]}}}'
+        '{"zebra":{"test":{"type":"Standard", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "address":"10.0.0.1", "mask":"0.0.0.0"}]}}}'
     )
     result = json_cmp(got, expected)
     assert result is None
@@ -63,7 +63,7 @@ def test_access_list_config_ordering(tgen):
     output = r1.vtysh_cmd("show ip access-list test json")
     got = json.loads(output)
     expected = json.loads(
-        '{"ZEBRA":{"test":{"type":"Zebra", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "prefix":"10.0.0.0/8", "exact-match":false}]}}}'
+        '{"zebra":{"test":{"type":"Zebra", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "prefix":"10.0.0.0/8", "exact-match":false}]}}}'
     )
     result = json_cmp(got, expected)
     assert result is None

Similarly to recently fixed 'show ip[v6] prefix-list ...' - PR#15750,
json output is not valid for 'show ip[v6] access-list ... json' commands,
as it goes through all the running daemons and for each one it calls
'filter_show' creating a new json object. To aggreagate the output
and create a valid json that can later be parsed, the commands were
moved to vtysh and formatted accordingly

Signed-off-by: Piotr Suchy <[email protected]>
@riw777
Copy link
Member

riw777 commented May 14, 2024

most recent failure looks like

AssertionError: Expected padded packet with length 1497, got packet with length 97 assert 'Expected padded packet with length 1497, got packet with length 97' is True

not certain why this is related, trying to rerun just that test

@riw777 riw777 merged commit 94d0128 into FRRouting:master May 14, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants