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
4d4d4260
Commit
4d4d4260
authored
1 year ago
by
Hakan Calim
Committed by
Neda Moeini
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
NAT-329 mostly all issues fixed only count for free netbox interfaces need to solved
parent
b43444fe
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
+21
-17
21 additions, 17 deletions
test/workflows/iptrunk/test_migrate_iptrunk.py
with
21 additions
and
17 deletions
test/workflows/iptrunk/test_migrate_iptrunk.py
+
21
−
17
View file @
4d4d4260
...
@@ -4,7 +4,8 @@ from unittest.mock import patch
...
@@ -4,7 +4,8 @@ from unittest.mock import patch
import
pytest
import
pytest
from
gso.products
import
Iptrunk
from
gso.products
import
Iptrunk
from
gso.utils.helpers
import
LAGMember
from
gso.products.product_types.router
import
Router
from
gso.products.product_blocks.router
import
RouterVendor
from
test
import
USER_CONFIRM_EMPTY_FORM
from
test
import
USER_CONFIRM_EMPTY_FORM
from
test.conftest
import
UseJuniperSide
from
test.conftest
import
UseJuniperSide
from
test.workflows
import
(
from
test.workflows
import
(
...
@@ -16,7 +17,6 @@ from test.workflows import (
...
@@ -16,7 +17,6 @@ from test.workflows import (
run_workflow
,
run_workflow
,
)
)
from
test.workflows.iptrunk.test_create_iptrunk
import
MockedNetboxClient
from
test.workflows.iptrunk.test_create_iptrunk
import
MockedNetboxClient
from
gso.products.product_blocks.router
import
RouterVendor
@pytest.fixture
()
@pytest.fixture
()
...
@@ -43,7 +43,7 @@ def migrate_form_input(
...
@@ -43,7 +43,7 @@ def migrate_form_input(
product_id
=
iptrunk_subscription_factory
()
product_id
=
iptrunk_subscription_factory
()
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
old_subscription
=
Iptrunk
.
from_subscription
(
product_id
)
new_router
=
juniper_router_subscription_factory
()
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
]
new_side_ae_members
=
faker
.
generate_juniper_members_list
()[
0
:
2
]
lag_name
=
"
ae1
"
lag_name
=
"
ae1
"
elif
use_juniper
==
UseJuniperSide
.
SIDE_BOTH
:
elif
use_juniper
==
UseJuniperSide
.
SIDE_BOTH
:
...
@@ -82,6 +82,7 @@ def migrate_form_input(
...
@@ -82,6 +82,7 @@ def migrate_form_input(
},
},
]
]
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"
migrate_form_input
"
,
"
migrate_form_input
"
,
[
UseJuniperSide
.
NONE
,
UseJuniperSide
.
SIDE_A
,
UseJuniperSide
.
SIDE_B
,
UseJuniperSide
.
SIDE_BOTH
],
[
UseJuniperSide
.
NONE
,
UseJuniperSide
.
SIDE_A
,
UseJuniperSide
.
SIDE_B
,
UseJuniperSide
.
SIDE_BOTH
],
...
@@ -154,24 +155,27 @@ def test_migrate_iptrunk_success(
...
@@ -154,24 +155,27 @@ def test_migrate_iptrunk_success(
new_lag_interface
=
migrate_form_input
[
3
][
"
new_lag_interface
"
]
new_lag_interface
=
migrate_form_input
[
3
][
"
new_lag_interface
"
]
replace_side
=
migrate_form_input
[
1
][
"
replace_side
"
]
replace_side
=
migrate_form_input
[
1
][
"
replace_side
"
]
# Only Nokia interfaces will checked
# Get vendor for the migrated node
vendor_side_a
=
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_node
.
vendor
vendor_new
=
Router
.
from_subscription
(
new_router
).
router
.
vendor
vendor_side_b
=
subscription
.
iptrunk
.
iptrunk_sides
[
1
].
iptrunk_side_node
.
vendor
# Only Nokia will be checked on netbox
num_nokia_lags
=
1
if
vendor_new
==
RouterVendor
.
NOKIA
else
0
num_nokia_reserved
=
2
*
(
vendor_new
==
RouterVendor
.
NOKIA
)
num_nokia_attached
=
2
*
(
vendor_new
==
RouterVendor
.
NOKIA
)
# Assert all Netbox calls have been made
# Assert all Netbox calls have been made
# This test case is only for migrating Nokia to Nokia.
# This test case is for migrating Nokia to Nokia, juniper to nokia and juniper to juniper.
# For Juniper to Nokia and Nokia to Juniper, the workflow is different.
# Therefore, the netbox counts need to set correctly
if
(
vendor_side_a
==
RouterVendor
.
NOKIA
and
vendor_side_b
==
RouterVendor
.
NOKIA
):
assert
mocked_create_interface
.
call_count
==
num_nokia_lags
# once for creating the LAG on the newly replaced side:
assert
mocked_create_interface
.
call_count
==
1
# 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_reserve_interface
.
call_count
==
2
# Twice for the new interfaces
assert
mocked_attach_interface_to_lag
.
call_count
==
num_nokia_attached
# Twice for the new interfaces
assert
mocked_attach_interface_to_lag
.
call_count
==
2
# Twice for the new interfaces
assert
mocked_allocate_interface
.
call_count
==
num_nokia_attached
# Twice for the new interfaces
assert
mocked_allocate_interface
.
call_count
==
2
# Twice for the new interfaces
assert
mocked_free_interface
.
call_count
==
num_nokia_attached
# Twice for the old interfaces
assert
mocked_free_interface
.
call_count
==
2
# Twice for the old interfaces
assert
mocked_delete_interface
.
call_count
==
num_nokia_lags
# once for deleting the LAG on the old replaced side
assert
mocked_delete_interface
.
call_count
==
1
# once for deleting the LAG on the old replaced side
# Assert the new side is replaced
# Assert the new side is replaced
assert
str
(
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_node
.
subscription
.
subscription_id
)
==
new_router
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
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
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
[
0
].
interface_name
==
"
Interface0
"
assert
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
[
1
].
interface_name
==
"
Interface1
"
assert
subscription
.
iptrunk
.
iptrunk_sides
[
0
].
iptrunk_side_ae_members
[
1
].
interface_name
==
"
Interface1
"
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