Skip to content

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roverflow committed Sep 16, 2024
1 parent 81e2910 commit f05f920
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelogs/fragments/ios_static_routes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
bugfixes:
- ios_static_routes - Fixes an issue where metric_distance is being populated in the forward_router_address attribute.
- ios_static_routes - Fix processing of metric_distance as it was wrongly populated under the forward_router_address attribute.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def __init__(self, lines=None, module=None):
(\s(?P<dest>\S+))
(\s(?P<netmask>\S+))
(\s(?P<interface>(ACR|ATM-ACR|Analysis-Module|AppNav-Compress|AppNav-UnCompress|Async|Auto-Template|BD-VIF|BDI|BVI|Bluetooth|CDMA-Ix|CEM-ACR|CEM-PG|CTunnel|Container|Dialer|EsconPhy|Ethernet-Internal|Fcpa|Filter|Filtergroup|GigabitEthernet|TenGigabitEthernet|IMA-ACR|LongReachEthernet|Loopback|Lspvif|MFR|Multilink|NVI|Null|PROTECTION_GROUP|Port-channel|Portgroup|Pos-channel|SBC|SDH_ACR|SERIAL-ACR|SONET_ACR|SSLVPN-VIF|SYSCLOCK|Serial-PG|Service-Engine|TLS-VIF|Tunnel|VPN|Vif|Vir-cem-ACR|Virtual-PPP|Virtual-TokenRing)\S+))?
# Had to add ip validation due to it picking up numbers as forward_router_address and negate just numbers
(\s(?P<forward_router_address>(?!multicast|dhcp|global|tag|track|permanent|name)(?!(?<!\d\.)\b\d+\b(?!\.\d))(\d{1,3}(\.\d{1,3}){3}|\S+)))?
(\s(?P<distance_metric>\d+))?
(\stag\s(?P<tag>\d+))?
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/modules/network/ios/test_ios_static_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2258,3 +2258,48 @@ def test_ios_static_route_gathered_2(self):
]
result = self.execute_module(changed=False)
self.assertEqual(sorted(result["gathered"]), sorted(gathered))

def test_ios_static_route_overridden_2(self):
self.execute_show_command.return_value = dedent(
"""\
ip route 198.51.100.0 255.255.255.0 198.51.101.1 175 tag 70 name replaced_route multicast
ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/1.22 10.0.0.1 tag 30
""",
)
set_module_args(dict(config=[
{
"address_families": [
{
"afi": "ipv4",
"routes": [
{
"next_hops": [
{
"forward_router_address": "198.51.101.20",
"distance_metric": 175,
"tag": 70,
"name": "replaced_route",
"track": 150,
},
{
"forward_router_address": "198.51.101.3",
"name": "merged_route_3",
},
],
"dest": "198.51.100.0/24",
},
],
},
],
},
],
state="overridden"
))
commands = [
'ip route 198.51.100.0 255.255.255.0 198.51.101.20 175 tag 70 name replaced_route track 150',
'ip route 198.51.100.0 255.255.255.0 198.51.101.3 name merged_route_3',
'no ip route 198.51.100.0 255.255.255.0 198.51.101.1 175 tag 70 name replaced_route multicast',
'no ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/1.22 10.0.0.1 tag 30'
]
result = self.execute_module(changed=True)
self.assertEqual(sorted(result["commands"]), sorted(commands))

0 comments on commit f05f920

Please sign in to comment.