diff options
| author | Russ White <russ@riw.us> | 2025-03-18 11:02:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-18 11:02:28 -0400 |
| commit | 4b6e0ba1a14a22a9b2b8fb4037a4466433494908 (patch) | |
| tree | 3005220e5bc1b6885c7f61ade4c263e9ab98a3f5 /tests | |
| parent | fe809f47d6d8a07f3ee328d3b93a457f19dd8aa0 (diff) | |
| parent | 50708524c0ee767266069d3006a2331d80d73ebb (diff) | |
Merge pull request #18349 from donaldsharp/more_yang_state
More yang state
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/topotests/zebra_operational_data/test_zebra_operational.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/topotests/zebra_operational_data/test_zebra_operational.py b/tests/topotests/zebra_operational_data/test_zebra_operational.py index c4ab5be973..bf70856d9a 100644 --- a/tests/topotests/zebra_operational_data/test_zebra_operational.py +++ b/tests/topotests/zebra_operational_data/test_zebra_operational.py @@ -56,6 +56,51 @@ def test_zebra_operationalr(tgen): logger.info("Ensuring that the max-multipath value is returned") assert "max-multipath" in output["frr-zebra:zebra"].keys() + logger.info("Checking IP forwarding states") + state = output["frr-zebra:zebra"]["state"] + assert "ip-forwarding" in state.keys(), "IPv4 forwarding state not found" + assert "ipv6-forwarding" in state.keys(), "IPv6 forwarding state not found" + assert "mpls-forwarding" in state.keys(), "MPLS forwarding state not found" + + # Verify the values are boolean + assert isinstance( + state["ip-forwarding"], bool + ), "IPv4 forwarding state should be boolean" + assert isinstance( + state["ipv6-forwarding"], bool + ), "IPv6 forwarding state should be boolean" + assert isinstance( + state["mpls-forwarding"], bool + ), "MPLS forwarding state should be boolean" + + # Test IPv6 forwarding state change + logger.info("Testing IPv6 forwarding state change") + # Store initial state + initial_ipv6_state = state["ipv6-forwarding"] + + # Turn off IPv6 forwarding + r1.vtysh_cmd("configure terminal\nno ipv6 forwarding\nexit") + + # Get updated state + output = json.loads(r1.vtysh_cmd("show mgmt get-data /frr-zebra:zebra")) + new_state = output["frr-zebra:zebra"]["state"] + + # Verify IPv6 forwarding is now off + assert ( + new_state["ipv6-forwarding"] is False + ), "IPv6 forwarding should be False after disabling" + + # Restore original state if it was enabled + if initial_ipv6_state: + r1.vtysh_cmd("configure terminal\nipv6 forwarding\nexit") + + # Verify state is restored + output = json.loads(r1.vtysh_cmd("show mgmt get-data /frr-zebra:zebra")) + final_state = output["frr-zebra:zebra"]["state"] + assert ( + final_state["ipv6-forwarding"] is True + ), "IPv6 forwarding should be restored to True" + if __name__ == "__main__": # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli |
