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
be7d176d
Commit
be7d176d
authored
1 year ago
by
Karel van Klink
Committed by
Neda Moeini
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add unit test for router validation workflow
parent
76c9b5b2
No related branches found
No related tags found
1 merge request
!139
Feature/add validation workflows
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gso/workflows/router/validate_router.py
+14
-1
14 additions, 1 deletion
gso/workflows/router/validate_router.py
test/fixtures.py
+1
-0
1 addition, 0 deletions
test/fixtures.py
test/workflows/router/test_validate_router.py
+63
-0
63 additions, 0 deletions
test/workflows/router/test_validate_router.py
with
78 additions
and
1 deletion
gso/workflows/router/validate_router.py
+
14
−
1
View file @
be7d176d
...
...
@@ -3,14 +3,15 @@
import
json
from
orchestrator.targets
import
Target
from
orchestrator.utils.errors
import
ProcessFailureError
from
orchestrator.utils.json
import
json_dumps
from
orchestrator.workflow
import
StepList
,
done
,
init
,
step
,
workflow
from
orchestrator.workflows.steps
import
resync
,
store_process_subscription
,
unsync
from
orchestrator.workflows.utils
import
wrap_modify_initial_input_form
from
gso.products.product_types.router
import
Router
from
gso.services
import
infoblox
from
gso.services.provisioning_proxy
import
execute_playbook
,
pp_interaction
from
gso.workflows.router.create_router
import
verify_ipam_loopback
@step
(
"
Validate router configuration
"
)
...
...
@@ -26,6 +27,18 @@ def validate_router_config(subscription: Router, callback_route: str) -> None:
)
@step
(
"
Verify IPAM resources for loopback interface
"
)
def
verify_ipam_loopback
(
subscription
:
Router
)
->
None
:
"""
Validate the :term:`IPAM` resources for the loopback interface.
Raises an :class:`orchestrator.utils.errors.ProcessFailureError` if IPAM is configured incorrectly.
"""
host_record
=
infoblox
.
find_host_by_fqdn
(
f
"
lo0.
{
subscription
.
router
.
router_fqdn
}
"
)
if
not
host_record
or
str
(
subscription
.
subscription_id
)
not
in
host_record
.
comment
:
msg
=
"
Loopback record is incorrectly configured in IPAM, please investigate this manually!
"
raise
ProcessFailureError
(
msg
)
@workflow
(
"
Validate router configuration
"
,
target
=
Target
.
SYSTEM
,
...
...
This diff is collapsed.
Click to expand it.
test/fixtures.py
+
1
−
0
View file @
be7d176d
...
...
@@ -154,6 +154,7 @@ def nokia_router_subscription_factory(site_subscription_factory, faker, geant_pa
router_subscription
.
router
.
vendor
=
Vendor
.
NOKIA
router_subscription
=
SubscriptionModel
.
from_other_lifecycle
(
router_subscription
,
SubscriptionLifecycle
.
ACTIVE
)
router_subscription
.
insync
=
True
router_subscription
.
description
=
description
router_subscription
.
start_date
=
start_date
...
...
This diff is collapsed.
Click to expand it.
test/workflows/router/test_validate_router.py
0 → 100644
+
63
−
0
View file @
be7d176d
from
unittest.mock
import
patch
import
pytest
from
infoblox_client
import
objects
from
gso.products.product_types.router
import
Router
from
test.workflows
import
(
assert_complete
,
assert_pp_interaction_success
,
extract_state
,
run_workflow
,
)
@pytest.mark.workflow
()
@pytest.mark.parametrize
(
"
product_id
"
,
[
"
nokia_router_subscription_factory
"
,
"
juniper_router_subscription_factory
"
])
@patch
(
"
gso.services.infoblox.find_host_by_fqdn
"
)
@patch
(
"
gso.workflows.router.validate_router.execute_playbook
"
)
def
test_validate_router_success
(
mock_validate_router
,
mock_find_host_by_fqdn
,
product_id
,
faker
,
data_config_filename
,
request
,
):
# Run workflow
subscription_id
=
request
.
getfixturevalue
(
product_id
)()
mock_fqdn
=
Router
.
from_subscription
(
subscription_id
).
router
.
router_fqdn
mock_v4
=
faker
.
ipv4
()
mock_find_host_by_fqdn
.
return_value
=
objects
.
HostRecord
(
connector
=
None
,
aliases
=
[
mock_fqdn
],
comment
=
subscription_id
,
ipv4addrs
=
[
objects
.
IPv4
(
ipv4addr
=
str
(
mock_v4
),
configure_for_dhcp
=
False
,
mac
=
"
00:00:00:00:00:00
"
,
ip
=
str
(
mock_v4
),
host
=
f
"
lo0.
{
mock_fqdn
}
"
,
),
],
name
=
mock_fqdn
,
)
initial_router_data
=
[{
"
subscription_id
"
:
subscription_id
}]
result
,
process_stat
,
step_log
=
run_workflow
(
"
validate_router
"
,
initial_router_data
)
state
=
extract_state
(
result
)
subscription_id
=
state
[
"
subscription_id
"
]
result
,
step_log
=
assert_pp_interaction_success
(
result
,
process_stat
,
step_log
)
assert_complete
(
result
)
state
=
extract_state
(
result
)
subscription
=
Router
.
from_subscription
(
subscription_id
)
assert
subscription
.
status
==
"
active
"
assert
mock_validate_router
.
call_count
==
1
assert
mock_find_host_by_fqdn
.
call_count
==
1
assert
"
ipam_warning
"
not
in
state
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