Skip to content
Snippets Groups Projects

Added more steps in router termination including:

Merged Neda Moeini requested to merge feature/NAT-578-update-ibgp-mesh-on-terminating-router into develop
2 files
+ 52
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 50
1
from unittest.mock import patch
import pytest
from orchestrator.types import SubscriptionLifecycle
from gso.products import Router
from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock
from gso.utils.helpers import available_interfaces_choices_including_current_members, validate_tt_number
from gso.products.product_blocks.router import RouterRole
from gso.utils.helpers import (
available_interfaces_choices_including_current_members,
generate_inventory_for_active_routers,
validate_tt_number,
)
from gso.utils.shared_enums import Vendor
@@ -90,3 +97,45 @@ def test_tt_number(generate_tt_numbers):
with pytest.raises(ValueError, match=err_msg):
validate_tt_number(tt_number)
def test_generate_inventory_for_active_routers_with_single_active_router(nokia_router_subscription_factory):
"""Test the generation of inventory for a single active P router."""
router = Router.from_subscription(nokia_router_subscription_factory(router_role=RouterRole.P))
expected_result = {
"all": {
"hosts": {
router.router.router_fqdn: {
"lo4": str(router.router.router_lo_ipv4_address),
"lo6": str(router.router.router_lo_ipv6_address),
"vendor": str(router.router.vendor),
}
}
}
}
assert generate_inventory_for_active_routers(RouterRole.P) == expected_result
def test_generate_inventory_for_active_routers_with_multiple_routers(nokia_router_subscription_factory):
"""Test the generation of inventory for multiple active P and PE routers"""
for _ in range(5):
nokia_router_subscription_factory(router_role=RouterRole.P)
for _ in range(3):
nokia_router_subscription_factory(router_role=RouterRole.PE)
nokia_router_subscription_factory(status=SubscriptionLifecycle.TERMINATED)
nokia_router_subscription_factory(status=SubscriptionLifecycle.INITIAL)
# Test the generation of inventory for multiple active P routers.
inventory = generate_inventory_for_active_routers(RouterRole.P)
assert len(inventory["all"]["hosts"]) == 5
inventory = generate_inventory_for_active_routers(RouterRole.PE)
assert len(inventory["all"]["hosts"]) == 3
def test_generate_inventory_for_active_routers_with_excluded_router(nokia_router_subscription_factory):
"""Test the generation of inventory for active P routers with an excluded router."""
for _ in range(5):
nokia_router_subscription_factory(router_role=RouterRole.P)
router = nokia_router_subscription_factory(router_role=RouterRole.P)
excluded_routers = [Router.from_subscription(router).router.router_fqdn]
inventory = generate_inventory_for_active_routers(RouterRole.P, exclude_routers=excluded_routers)
assert len(inventory["all"]["hosts"]) == 5 # 6 P routers, the last one is excluded, so 5 P routers are left.
Loading