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
Commits
6f5da249
Commit
6f5da249
authored
8 months ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests for generate inventory function.
parent
ea2c0492
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!231
Added more steps in router termination including:
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/utils/test_helpers.py
+50
-1
50 additions, 1 deletion
test/utils/test_helpers.py
test/workflows/router/test_terminate_router.py
+2
-1
2 additions, 1 deletion
test/workflows/router/test_terminate_router.py
with
52 additions
and
2 deletions
test/utils/test_helpers.py
+
50
−
1
View file @
6f5da249
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.
This diff is collapsed.
Click to expand it.
test/workflows/router/test_terminate_router.py
+
2
−
1
View file @
6f5da249
...
...
@@ -3,6 +3,7 @@ from unittest.mock import patch
import
pytest
from
gso.products
import
Router
from
gso.products.product_blocks.router
import
RouterRole
from
test.workflows
import
assert_complete
,
assert_lso_interaction_success
,
extract_state
,
run_workflow
...
...
@@ -75,7 +76,7 @@ def test_terminate_p_router_full_success(
data_config_filename
,
):
# Prepare mock values and expected results
product_id
=
nokia_router_subscription_factory
(
router_role
=
"
p
"
)
product_id
=
nokia_router_subscription_factory
(
router_role
=
RouterRole
.
P
)
router_termination_input_form_data
=
{
"
tt_number
"
:
faker
.
tt_number
(),
"
remove_configuration
"
:
remove_configuration
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment