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
982d6389
Commit
982d6389
authored
1 year ago
by
JORGE SASIAIN
Browse files
Options
Downloads
Patches
Plain Diff
NAT-199: add tests for delete host in IPAM
parent
551aa18c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!27
Merge develop into NAT-185
,
!15
Nat 185
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/ipam.py
+6
-1
6 additions, 1 deletion
gso/services/ipam.py
test/test_ipam.py
+93
-0
93 additions, 0 deletions
test/test_ipam.py
with
99 additions
and
1 deletion
gso/services/ipam.py
+
6
−
1
View file @
982d6389
...
...
@@ -73,7 +73,12 @@ def delete_service_host(
cname_aliases
=
[],
service_type
=
''
)
->
HostAddresses
:
return
None
return
_ipam
.
delete_service_host
(
hostname
=
hostname
,
host_addresses
=
host_addresses
,
cname_aliases
=
cname_aliases
,
service_type
=
service_type
)
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
test/test_ipam.py
+
93
−
0
View file @
982d6389
...
...
@@ -315,3 +315,96 @@ def test_delete_service_network(data_config_filename):
service_type
=
'
TRUNK
'
)
assert
service_network
is
None
@responses.activate
def
test_delete_service_host
(
data_config_filename
):
responses
.
add
(
method
=
responses
.
GET
,
url
=
re
.
compile
(
r
'
.*/wapi.*record:host.*
'
),
json
=
[
{
'
_ref
'
:
'
record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lmdzby5oYV9sbw:ha_lo.gso/default
'
,
# noqa: E501
'
ipv4addrs
'
:
[
{
'
_ref
'
:
'
record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuZ3NvLmhhX2xvLjEwLjI1NS4yNTUuMS40.255.255.1/ha_lo.gso/default
'
,
# noqa: E501
'
configure_for_dhcp
'
:
False
,
'
host
'
:
'
ha_lo.gso
'
,
'
ipv4addr
'
:
'
10.255.255.1
'
}
],
'
ipv6addrs
'
:
[
{
'
_ref
'
:
'
record:host_ipv6addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuZvLmhhX2xvLmRlYWQ6YmVlZjo6MS4:dead%3Abeef%3A%3A1/ha_lo.gso/default
'
,
# noqa: E501
'
configure_for_dhcp
'
:
False
,
'
host
'
:
'
ha_lo.gso
'
,
'
ipv6addr
'
:
'
dead:beef::1
'
}
],
'
name
'
:
'
ha_lo.gso
'
,
'
view
'
:
'
default
'
}
]
)
responses
.
add
(
method
=
responses
.
GET
,
url
=
re
.
compile
(
r
'
.*/wapi.*record:cname.*
'
),
json
=
[
{
'
_ref
'
:
'
record:cname/ZG5zLmJpbmRfY25hbWUkLl9kZWZhdWx0Lmdzby5oYS5hbGlhczE:alias1.ha.gso/default
'
,
# noqa: E501
'
canonical
'
:
'
hA_LO.lo
'
,
'
name
'
:
'
alias1.ha.lo
'
,
'
view
'
:
'
default
'
},
{
'
_ref
'
:
'
record:cname/5zLmJpbmRfY25hbWUkLl9kZWZhdWx0Lmdzby5oYS5hbGlhczI:alias2.ha.gso/default
'
,
# noqa: E501
'
canonical
'
:
'
hA_LO.lo
'
,
'
name
'
:
'
alias2.ha.lo
'
,
'
view
'
:
'
default
'
}
]
)
responses
.
add
(
method
=
responses
.
DELETE
,
url
=
re
.
compile
(
r
'
.*/wapi.*record:host.*
'
),
body
=
'
record:host/ZG5zLmhvc3QkLl9kZWZhdWx0Lmdzby5oYl9sbw:hb_lo.gso/default
'
# noqa: E501
)
responses
.
add
(
method
=
responses
.
DELETE
,
url
=
re
.
compile
(
r
'
.*/wapi.*record:cname.*
'
),
body
=
'
record:cname/ZG5zLmJpbmRfY25hbWUkLl9kZWZhdWx0Lmdzby5oYi5hbGlhczE:alias1.hb.gso/default
'
# noqa: E501
)
input_host_addresses
=
ipam
.
HostAddresses
(
v4
=
ipaddress
.
ip_address
(
'
10.255.255.1
'
),
v6
=
ipaddress
.
ip_address
(
'
dead:beef::1
'
)
)
host_addresses
=
ipam
.
delete_service_host
(
hostname
=
'
ha_lo
'
,
host_addresses
=
input_host_addresses
,
cname_aliases
=
[
'
alias1.ha
'
,
'
alias2.ha
'
],
service_type
=
'
LO
'
)
assert
host_addresses
==
ipam
.
HostAddresses
(
v4
=
ipaddress
.
ip_address
(
'
10.255.255.1
'
),
v6
=
ipaddress
.
ip_address
(
'
dead:beef::1
'
)
)
# Fail because missing CNAME
with
pytest
.
raises
(
AssertionError
):
host_addresses
=
ipam
.
delete_service_host
(
hostname
=
'
ha_lo
'
,
host_addresses
=
input_host_addresses
,
cname_aliases
=
[
'
alias1.ha
'
],
service_type
=
'
LO
'
)
assert
host_addresses
is
None
# Fail because non-matching CNAME
with
pytest
.
raises
(
AssertionError
):
host_addresses
=
ipam
.
delete_service_host
(
hostname
=
'
ha_lo
'
,
host_addresses
=
input_host_addresses
,
cname_aliases
=
[
'
alias1.ha
'
,
'
alias2.ha
'
,
'
alias3.ha
'
],
service_type
=
'
LO
'
)
assert
host_addresses
is
None
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