Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Merge requests
!231
Added more steps in router termination including:
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Added more steps in router termination including:
feature/NAT-578-update-ibgp-mesh-on-terminating-router
into
develop
Overview
6
Commits
11
Pipelines
12
Changes
2
Merged
Neda Moeini
requested to merge
feature/NAT-578-update-ibgp-mesh-on-terminating-router
into
develop
9 months ago
Overview
6
Commits
11
Pipelines
12
Changes
2
Expand
Remove the terminated router from iGEANT/iGEANT6 on all the PEs
Remove the terminated router from iGEANT_P_ONLY/iGEANT_P_ONLY_6 on all Ps
Remove router from LibreNMS
0
0
Merge request reports
Viewing commit
d46123a2
Show latest version
2 files
+
52
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
d46123a2
Added unit tests for generate inventory function.
· d46123a2
Neda Moeini
authored
9 months ago
test/utils/test_helpers.py
+
50
−
1
Options
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