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
Jira
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
!83
Clean up the repo a bit, and add some unit tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Clean up the repo a bit, and add some unit tests
feature/add-unit-tests
into
develop
Overview
8
Commits
21
Pipelines
7
Changes
3
All threads resolved!
Hide all comments
Merged
Karel van Klink
requested to merge
feature/add-unit-tests
into
develop
1 year ago
Overview
8
Commits
21
Pipelines
7
Changes
3
All threads resolved!
Hide all comments
Expand
Add a bunch of unit tests for different workflows
Rework the different
util
modules and merge them where relevant
Resolve some TODO items in config.py (netmasks are now validated)
Add some
:term:
directives to docstrings
Resolve a pytest warning about an unregistered mark
@pytest.mask.workflow
0
0
Merge request reports
Viewing commit
162dc793
Prev
Next
Show latest version
3 files
+
132
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
162dc793
add (unfinished) unit test for iptrunk interface modification workflow
· 162dc793
Karel van Klink
authored
1 year ago
test/workflows/iptrunk/test_modify_trunk_interface.py
0 → 100644
+
128
−
0
Options
from
unittest.mock
import
patch
import
pytest
from
gso.products
import
Iptrunk
from
gso.products.product_blocks.iptrunk
import
IptrunkType
from
gso.utils.types.phy_port
import
PhyPortCapacity
from
test.workflows
import
(
assert_complete
,
assert_suspended
,
extract_state
,
resume_workflow
,
run_workflow
,
user_accept_and_assert_suspended
,
)
@pytest.mark.workflow
@patch
(
"
gso.workflows.iptrunk.modify_trunk_interface.provisioning_proxy.provision_ip_trunk
"
)
def
test_iptrunk_modify_trunk_interface_success
(
mock_provision_ip_trunk
,
iptrunk_subscription_factory
,
faker
,
):
# Set up mock return values
product_id
=
iptrunk_subscription_factory
()
new_sid
=
faker
.
geant_sid
()
new_description
=
faker
.
sentence
()
new_type
=
IptrunkType
.
LEASED
new_speed
=
PhyPortCapacity
.
FOUR_HUNDRED_GIGABIT_PER_SECOND
new_link_count
=
2
new_side_a_sid
=
faker
.
geant_sid
()
new_side_a_ae_members
=
[
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
]
new_side_a_ae_descriptions
=
[
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
]
new_side_b_sid
=
faker
.
geant_sid
()
new_side_b_ae_members
=
[
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
faker
.
network_interface
(),
]
new_side_b_ae_descriptions
=
[
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
faker
.
sentence
(),
]
# Run workflow
initial_iptrunk_data
=
[
{
"
subscription_id
"
:
product_id
},
{
"
tt_number
"
:
faker
.
tt_number
(),
"
geant_s_sid
"
:
new_sid
,
"
iptrunk_description
"
:
new_description
,
"
iptrunk_type
"
:
new_type
,
"
iptrunk_speed
"
:
new_speed
,
"
iptrunk_minimum_links
"
:
new_link_count
,
},
{
"
iptrunk_sideA_ae_geant_a_sid
"
:
new_side_a_sid
,
"
iptrunk_sideA_ae_members
"
:
new_side_a_ae_members
,
"
iptrunk_sideA_ae_members_descriptions
"
:
new_side_a_ae_descriptions
,
},
{
"
iptrunk_sideB_ae_geant_a_sid
"
:
new_side_b_sid
,
"
iptrunk_sideB_ae_members
"
:
new_side_b_ae_members
,
"
iptrunk_sideB_ae_members_descriptions
"
:
new_side_b_ae_descriptions
,
},
]
result
,
process_stat
,
step_log
=
run_workflow
(
"
modify_trunk_interface
"
,
initial_iptrunk_data
)
assert_suspended
(
result
)
lso_return
=
{
"
pp_run_results
"
:
{
"
status
"
:
"
ok
"
,
"
job_id
"
:
faker
.
uuid4
(),
"
output
"
:
"
parsed_output
"
,
"
return_code
"
:
0
,
},
"
confirm
"
:
"
ACCEPTED
"
,
}
result
,
step_log
=
user_accept_and_assert_suspended
(
process_stat
,
step_log
,
lso_return
)
result
,
step_log
=
user_accept_and_assert_suspended
(
process_stat
,
step_log
,
[{},
{}])
result
,
step_log
=
user_accept_and_assert_suspended
(
process_stat
,
step_log
,
lso_return
)
result
,
step_log
=
resume_workflow
(
process_stat
,
step_log
,
[{},
{}])
assert_complete
(
result
)
state
=
extract_state
(
result
)
subscription_id
=
state
[
"
subscription_id
"
]
subscription
=
Iptrunk
.
from_subscription
(
subscription_id
)
assert
"
active
"
==
subscription
.
status
assert
mock_provision_ip_trunk
.
call_count
==
2
# Assert all subscription properties have been updated correctly
assert
subscription
.
description
==
f
"
IP trunk, geant_s_sid:
{
new_sid
}
"
assert
subscription
.
iptrunk
.
geant_s_sid
==
new_sid
assert
subscription
.
iptrunk
.
iptrunk_description
==
new_description
assert
subscription
.
iptrunk
.
iptrunk_type
==
new_type
assert
subscription
.
iptrunk
.
iptrunk_speed
==
new_speed
assert
subscription
.
iptrunk
.
iptrunk_minimum_links
==
new_link_count
# FIXME: update assertions below when IPtrunk model is updated
# assert subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_geant_a_sid == new_side_a_sid
# assert subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members == new_side_a_ae_members
# assert subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members_description == new_side_a_ae_descriptions
# assert subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_geant_a_sid == new_side_b_sid
# assert subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members == new_side_b_ae_members
# assert subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members_description == new_side_b_ae_descriptions
Loading