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
d4d0bc2b
Commit
d4d0bc2b
authored
1 year ago
by
Hakan Calim
Committed by
Neda Moeini
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
NAT-329: completed all 4 scenarios for migrate tests
parent
4d4d4260
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!125
Feature/nat 329 validate interface names for migrate
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/workflows/iptrunk/test_migrate_iptrunk.py
+51
-18
51 additions, 18 deletions
test/workflows/iptrunk/test_migrate_iptrunk.py
with
51 additions
and
18 deletions
test/workflows/iptrunk/test_migrate_iptrunk.py
+
51
−
18
View file @
d4d0bc2b
"""
in this test four scenarios are tested for the migrate workflow
1. Nokia will be migrated to Juniper
2. Juniper will be migrated to Nokia
3. Juniper will be migrade to Juniper
4. Nokia will be migrate to Nokia
For all scenarios side [0] is used to simplify the validation.
Actually only netbox validations for Nokia router are performed.
"""
from
os
import
PathLike
from
unittest.mock
import
patch
import
pytest
from
gso.products
import
Iptrunk
from
gso.products.product_types.router
import
Router
from
gso.products.product_blocks.router
import
RouterVendor
from
gso.products.product_types.router
import
Router
from
test
import
USER_CONFIRM_EMPTY_FORM
from
test.conftest
import
UseJuniperSide
from
test.workflows
import
(
...
...
@@ -31,7 +41,7 @@ def migrate_form_input(
use_juniper
=
getattr
(
request
,
"
param
"
,
UseJuniperSide
.
NONE
)
if
use_juniper
==
UseJuniperSide
.
SIDE_A
:
#
Both side Nokia -> side A will be
Juniper
#
Nokia ->
Juniper
product_id
=
iptrunk_subscription_factory
()
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
new_router
=
juniper_router_subscription_factory
()
...
...
@@ -39,15 +49,19 @@ def migrate_form_input(
new_side_ae_members
=
faker
.
generate_juniper_members_list
()[
0
:
2
]
lag_name
=
"
ae1
"
elif
use_juniper
==
UseJuniperSide
.
SIDE_B
:
# Both side are Nokia -> side b will be Juniper
product_id
=
iptrunk_subscription_factory
()
# Juniper -> Nokia
old_side_a_node
=
juniper_router_subscription_factory
()
old_side_a_node
=
iptrunk_side_subscription_factory
(
iptrunk_side_node
=
old_side_a_node
)
old_side_b_node
=
juniper_router_subscription_factory
()
old_side_b_node
=
iptrunk_side_subscription_factory
(
iptrunk_side_node
=
old_side_b_node
)
product_id
=
iptrunk_subscription_factory
(
iptrunk_sides
=
[
old_side_a_node
,
old_side_b_node
])
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
new_router
=
juniper
_router_subscription_factory
()
new_router
=
nokia
_router_subscription_factory
()
replace_side
=
str
(
old_subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_node
.
subscription
.
subscription_id
)
new_side_ae_members
=
faker
.
generate_
juniper
_members_list
()[
0
:
2
]
lag_name
=
"
ae
1
"
new_side_ae_members
=
faker
.
generate_
nokia
_members_list
()[
0
:
2
]
lag_name
=
"
LAG
1
"
elif
use_juniper
==
UseJuniperSide
.
SIDE_BOTH
:
#
Both side are Juniper -> side A will be new
Juniper
#
Juniper ->
Juniper
old_side_a_node
=
juniper_router_subscription_factory
()
old_side_a_node
=
iptrunk_side_subscription_factory
(
iptrunk_side_node
=
old_side_a_node
)
old_side_b_node
=
juniper_router_subscription_factory
()
...
...
@@ -55,11 +69,11 @@ def migrate_form_input(
product_id
=
iptrunk_subscription_factory
(
iptrunk_sides
=
[
old_side_a_node
,
old_side_b_node
])
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
new_router
=
juniper_router_subscription_factory
()
replace_side
=
str
(
old_subscription
.
iptrunk
.
iptrunk_sides
[
1
].
iptrunk_side_node
.
subscription
.
subscription_id
)
replace_side
=
str
(
old_subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_node
.
subscription
.
subscription_id
)
new_side_ae_members
=
faker
.
generate_juniper_members_list
()[
0
:
2
]
lag_name
=
"
ae1
"
else
:
#
Both side are Nokia -> side a will be
Nokia
#
Nokia ->
Nokia
product_id
=
iptrunk_subscription_factory
()
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
new_router
=
nokia_router_subscription_factory
()
...
...
@@ -83,6 +97,20 @@ def migrate_form_input(
]
def
interface_lists_are_equal
(
list1
,
list2
):
if
len
(
list1
)
!=
len
(
list2
):
return
False
for
item1
in
list1
:
if
not
any
(
item1
.
interface_name
==
item2
.
interface_name
and
item1
.
interface_description
==
item2
.
interface_description
for
item2
in
list2
):
return
False
return
True
@pytest.mark.parametrize
(
"
migrate_form_input
"
,
[
UseJuniperSide
.
NONE
,
UseJuniperSide
.
SIDE_A
,
UseJuniperSide
.
SIDE_B
,
UseJuniperSide
.
SIDE_BOTH
],
...
...
@@ -154,8 +182,10 @@ def test_migrate_iptrunk_success(
new_router
=
migrate_form_input
[
2
][
"
new_node
"
]
new_lag_interface
=
migrate_form_input
[
3
][
"
new_lag_interface
"
]
replace_side
=
migrate_form_input
[
1
][
"
replace_side
"
]
new_lag_member_interfaces
=
migrate_form_input
[
3
][
"
new_lag_member_interfaces
"
]
# Get vendor for the migrated node
# Get vendor for the new and old migrated node
vendor_old
=
Router
.
from_subscription
(
replace_side
).
router
.
vendor
vendor_new
=
Router
.
from_subscription
(
new_router
).
router
.
vendor
# Only Nokia will be checked on netbox
...
...
@@ -163,19 +193,22 @@ def test_migrate_iptrunk_success(
num_nokia_reserved
=
2
*
(
vendor_new
==
RouterVendor
.
NOKIA
)
num_nokia_attached
=
2
*
(
vendor_new
==
RouterVendor
.
NOKIA
)
# Only interfaces lag delete for nokia node is tested
num_nokia_lag_del
=
1
*
(
vendor_old
==
RouterVendor
.
NOKIA
)
# Only free interfaces when node was nokia
num_nokia_free
=
2
*
(
vendor_old
==
RouterVendor
.
NOKIA
)
# Assert all Netbox calls have been made
# This test case is for migrating Nokia to Nokia, juniper to nokia and juniper to juniper.
# Therefore, the netbox counts need to set correctly
assert
mocked_create_interface
.
call_count
==
num_nokia_lags
# once for creating the LAG on the newly replaced side:
assert
mocked_reserve_interface
.
call_count
==
num_nokia_reserved
# Twice for the new interfaces
assert
mocked_attach_interface_to_lag
.
call_count
==
num_nokia_attached
# Twice for the new interfaces
assert
mocked_allocate_interface
.
call_count
==
num_nokia_attached
# Twice for the new interfaces
assert
mocked_free_interface
.
call_count
==
num_nokia_
attached
# Twice for the old interfaces
assert
mocked_delete_interface
.
call_count
==
num_nokia_lag
s
# once for deleting the LAG on the old replaced side
assert
mocked_free_interface
.
call_count
==
num_nokia_
free
# Twice for the old interfaces
assert
mocked_delete_interface
.
call_count
==
num_nokia_lag
_del
# once for deleting the LAG on the old replaced side
# Assert the new side is replaced
assert
str
(
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_node
.
subscription
.
subscription_id
)
==
new_router
assert
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_iface
==
new_lag_interface
assert
len
(
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
)
==
2
assert
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
[
0
].
interface_name
==
"
Interface0
"
assert
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
[
1
].
interface_name
==
"
Interface1
"
existing_members
=
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
assert
interface_lists_are_equal
(
new_lag_member_interfaces
,
existing_members
)
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