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
378c07f2
Commit
378c07f2
authored
1 year ago
by
JORGE SASIAIN
Browse files
Options
Downloads
Patches
Plain Diff
NAT-152 / NAT-198: update tests and add some tests for fail cases
parent
4e5878d5
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
test/conftest.py
+6
-3
6 additions, 3 deletions
test/conftest.py
test/test_ipam.py
+45
-3
45 additions, 3 deletions
test/test_ipam.py
with
51 additions
and
6 deletions
test/conftest.py
+
6
−
3
View file @
378c07f2
...
...
@@ -36,7 +36,8 @@ def configuration_data():
"
networks
"
:
[
"
dead:beef::/80
"
],
"
mask
"
:
128
},
"
domain_name
"
:
"
.lo
"
"
domain_name
"
:
"
.lo
"
,
"
dns_view
"
:
"
default
"
},
"
TRUNK
"
:
{
"
V4
"
:
{
...
...
@@ -49,7 +50,8 @@ def configuration_data():
"
networks
"
:
[],
"
mask
"
:
126
},
"
domain_name
"
:
"
.trunk
"
"
domain_name
"
:
"
.trunk
"
,
"
dns_view
"
:
"
default
"
},
"
GEANT_IP
"
:
{
"
V4
"
:
{
...
...
@@ -62,7 +64,8 @@ def configuration_data():
"
networks
"
:
[],
"
mask
"
:
126
},
"
domain_name
"
:
"
.geantip
"
"
domain_name
"
:
"
.geantip
"
,
"
dns_view
"
:
"
default
"
}
},
"
PROVISIONING_PROXY
"
:
{
...
...
This diff is collapsed.
Click to expand it.
test/test_ipam.py
+
45
−
3
View file @
378c07f2
import
ipaddress
import
pytest
import
re
import
responses
...
...
@@ -32,6 +33,11 @@ def test_new_service_networks(data_config_filename):
v6
=
ipaddress
.
ip_network
(
'
dead:beef::18/128
'
)
)
# should fail because this service type has networks instead of containers
with
pytest
.
raises
(
AssertionError
):
service_networks
=
ipam
.
new_service_networks
(
service_type
=
'
LO
'
)
assert
service_networks
is
None
@responses.activate
def
test_new_service_host
(
data_config_filename
):
...
...
@@ -56,7 +62,7 @@ def test_new_service_host(data_config_filename):
responses
.
add
(
method
=
responses
.
GET
,
url
=
re
.
compile
(
r
'
.*/wapi.*/network.*
'
),
url
=
re
.
compile
(
r
'
.*/wapi.*/network.*
10.255.255.*
'
),
json
=
[
{
"
_ref
"
:
"
network/ZG5zLm5ldHdvcmskMTAuMjU1LjI1NS4yMC8zMi8w:10.255.255.20/32/default
"
,
# noqa: E501
...
...
@@ -67,6 +73,19 @@ def test_new_service_host(data_config_filename):
)
responses
.
add
(
method
=
responses
.
GET
,
url
=
re
.
compile
(
r
'
.*/wapi.*/network.*10.255.254.*
'
),
json
=
[
{
"
_ref
"
:
"
network/ZG5zLm5Gd0VHQkRQUjMzLjMwNzIuMzE1LzAyLzI:10.255.254.20/32/default
"
,
# noqa: E501
"
network
"
:
"
10.255.254.20/32
"
,
"
network_view
"
:
"
default
"
}
]
)
responses
.
add
(
method
=
responses
.
GET
,
url
=
re
.
compile
(
r
'
.*/wapi.*/ipv6network.*
'
),
...
...
@@ -81,13 +100,20 @@ def test_new_service_host(data_config_filename):
responses
.
add
(
method
=
responses
.
POST
,
url
=
re
.
compile
(
r
'
.*/wapi.*/network.*
/
.*?_function=next_available_ip&num=1$
'
),
# noqa: E501
url
=
re
.
compile
(
r
'
.*/wapi.*/network
/
.*
10.255.255
.*?_function=next_available_ip&num=1$
'
),
# noqa: E501
json
=
{
'
ips
'
:
[
'
10.255.255.20
'
]}
)
responses
.
add
(
method
=
responses
.
POST
,
url
=
re
.
compile
(
r
'
.*/wapi.*/ipv6network.*/.*?_function=next_available_ip&num=1$
'
),
# noqa: E501
url
=
re
.
compile
(
r
'
.*/wapi.*/network/.*10.255.254.*?_function=next_available_ip&num=1$
'
),
# noqa: E501
body
=
"
Cannot find 1 available IP address(es) in this network
"
,
status
=
400
)
responses
.
add
(
method
=
responses
.
POST
,
url
=
re
.
compile
(
r
'
.*/wapi.*/ipv6network/.*?_function=next_available_ip&num=1$
'
),
# noqa: E501
json
=
{
'
ips
'
:
[
'
dead:beef::18
'
]}
)
...
...
@@ -109,6 +135,7 @@ def test_new_service_host(data_config_filename):
}
)
# test host creation by IP addresses
service_hosts
=
ipam
.
new_service_host
(
hostname
=
'
test
'
,
service_type
=
'
TRUNK
'
,
...
...
@@ -122,6 +149,7 @@ def test_new_service_host(data_config_filename):
v6
=
ipaddress
.
ip_address
(
'
dead:beef::18
'
)
)
# test host creation by network addresses
service_hosts
=
ipam
.
new_service_host
(
hostname
=
'
test
'
,
service_type
=
'
TRUNK
'
,
...
...
@@ -135,6 +163,7 @@ def test_new_service_host(data_config_filename):
v6
=
ipaddress
.
ip_address
(
'
dead:beef::18
'
)
)
# test host creation by just service_type when service cfg uses networks
service_hosts
=
ipam
.
new_service_host
(
hostname
=
'
test
'
,
service_type
=
'
LO
'
...
...
@@ -144,6 +173,7 @@ def test_new_service_host(data_config_filename):
v6
=
ipaddress
.
ip_address
(
'
dead:beef::18
'
)
)
# test host creation by just service_type when service cfg uses containers
service_hosts
=
ipam
.
new_service_host
(
hostname
=
'
test
'
,
service_type
=
'
TRUNK
'
...
...
@@ -152,3 +182,15 @@ def test_new_service_host(data_config_filename):
v4
=
ipaddress
.
ip_address
(
'
10.255.255.20
'
),
v6
=
ipaddress
.
ip_address
(
'
dead:beef::18
'
)
)
# test host creation that should return a no available IP error
with
pytest
.
raises
(
AssertionError
):
service_hosts
=
ipam
.
new_service_host
(
hostname
=
'
test
'
,
service_type
=
'
TRUNK
'
,
service_networks
=
ipam
.
ServiceNetworks
(
v4
=
ipaddress
.
ip_network
(
'
10.255.254.20/32
'
),
v6
=
ipaddress
.
ip_network
(
'
dead:beef::18/128
'
)
)
)
assert
service_hosts
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