Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
TFS
controller
Commits
25d28216
Commit
25d28216
authored
6 months ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Updated test code
parent
0c9ec644
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!172
Resolve "(CTTC) Extend gNMI-OpenConfig SBI driver"
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tests/eucnc24/tests/test_functional_service_ietf.py
+40
-79
40 additions, 79 deletions
src/tests/eucnc24/tests/test_functional_service_ietf.py
src/tests/eucnc24/tests/test_functional_service_tfs.py
+2
-2
2 additions, 2 deletions
src/tests/eucnc24/tests/test_functional_service_tfs.py
with
42 additions
and
81 deletions
src/tests/eucnc24/tests/test_functional_service_ietf.py
+
40
−
79
View file @
25d28216
...
...
@@ -16,18 +16,11 @@ import json, logging, os, pytest
from
typing
import
Dict
from
common.Constants
import
DEFAULT_CONTEXT_NAME
from
common.proto.context_pb2
import
ContextId
,
ServiceStatusEnum
,
ServiceTypeEnum
from
common.tools.descriptor.Loader
import
(
DescriptorLoader
,
check_descriptor_load_results
)
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
common.tools.object_factory.Context
import
json_context_id
from
context.client.ContextClient
import
ContextClient
from
device.client.DeviceClient
import
DeviceClient
from
service.client.ServiceClient
import
ServiceClient
from
tests.Fixtures
import
context_client
,
device_client
,
service_client
# pylint: disable=unused-import
from
.Tools
import
(
do_rest_delete_request
,
do_rest_get_request
,
do_rest_post_request
,
)
from
tests.Fixtures
import
context_client
# pylint: disable=unused-import
from
.Tools
import
do_rest_delete_request
,
do_rest_get_request
,
do_rest_post_request
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -41,10 +34,8 @@ def storage() -> Dict:
yield
dict
()
# pylint: disable=redefined-outer-name, unused-argument
def
test_service_creation
_ietf
(
def
test_service_
ietf_
creation
(
context_client
:
ContextClient
,
device_client
:
DeviceClient
,
service_client
:
ServiceClient
,
storage
:
Dict
):
# Issue service creation request
...
...
@@ -52,7 +43,8 @@ def test_service_creation_ietf(
svc1_data
=
json
.
load
(
f
)
URL
=
'
/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services
'
do_rest_post_request
(
URL
,
body
=
svc1_data
,
logger
=
LOGGER
,
expected_status_codes
=
{
201
})
storage
[
'
svc-uuid
'
]
=
svc1_data
[
'
ietf-l3vpn-svc:l3vpn-svc
'
][
'
vpn-services
'
][
'
vpn-service
'
][
0
][
'
vpn-id
'
]
service_uuid
=
svc1_data
[
'
ietf-l3vpn-svc:l3vpn-svc
'
][
'
vpn-services
'
][
'
vpn-service
'
][
0
][
'
vpn-id
'
]
storage
[
'
svc-uuid
'
]
=
service_uuid
# Verify service was created
response
=
context_client
.
GetContext
(
ADMIN_CONTEXT_ID
)
...
...
@@ -68,6 +60,7 @@ def test_service_creation_ietf(
for
service
in
response
.
services
:
service_id
=
service
.
service_id
assert
service_id
.
service_uuid
.
uuid
==
service_uuid
assert
service
.
service_status
.
service_status
==
ServiceStatusEnum
.
SERVICESTATUS_ACTIVE
assert
service
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
...
...
@@ -80,61 +73,35 @@ def test_service_creation_ietf(
# pylint: disable=redefined-outer-name, unused-argument
def
test_get_state_svc1
(
storage
:
Dict
):
assert
'
svc-uuid
'
in
storage
service_uuid
=
storage
[
'
svc-uuid
'
]
URL
=
'
/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services/vpn-service={:s}/
'
.
format
(
service_uuid
)
do_rest_get_request
(
URL
,
logger
=
LOGGER
,
expected_status_codes
=
{
200
})
def
test_service_ietf_retrieval
(
context_client
:
ContextClient
,
# pylint: disable=redefined-outer-name
storage
:
Dict
):
# Verify the scenario has 1 service and 0 slices
response
=
context_client
.
GetContext
(
ADMIN_CONTEXT_ID
)
assert
len
(
response
.
service_ids
)
==
1
assert
len
(
response
.
slice_ids
)
==
0
# Check there are no slices
response
=
context_client
.
ListSlices
(
ADMIN_CONTEXT_ID
)
LOGGER
.
warning
(
'
Slices[{:d}] = {:s}
'
.
format
(
len
(
response
.
slices
),
grpc_message_to_json_string
(
response
)))
assert
len
(
response
.
slices
)
==
0
# Check there is 1 service
response
=
context_client
.
ListServices
(
ADMIN_CONTEXT_ID
)
LOGGER
.
warning
(
'
Services[{:d}] = {:s}
'
.
format
(
len
(
response
.
services
),
grpc_message_to_json_string
(
response
)))
assert
len
(
response
.
services
)
==
1
# pylint: disable=redefined-outer-name, unused-argument
def
test_delete_svc1
(
storage
:
Dict
):
assert
'
svc-uuid
'
in
storage
service_uuid
=
storage
[
'
svc-uuid
'
]
URL
=
'
/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services/vpn-service={:s}/
'
.
format
(
service_uuid
)
do_rest_delete_request
(
URL
,
logger
=
LOGGER
,
expected_status_codes
=
{
204
})
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
logging
from
typing
import
Set
,
Tuple
from
common.Constants
import
DEFAULT_CONTEXT_NAME
from
common.proto.context_pb2
import
ContextId
,
ServiceId
,
ServiceStatusEnum
,
ServiceTypeEnum
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
common.tools.object_factory.Context
import
json_context_id
from
common.tools.object_factory.Service
import
json_service_id
from
context.client.ContextClient
import
ContextClient
from
service.client.ServiceClient
import
ServiceClient
from
tests.Fixtures
import
context_client
,
service_client
# pylint: disable=unused-import
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
.
setLevel
(
logging
.
DEBUG
)
do_rest_get_request
(
URL
,
logger
=
LOGGER
,
expected_status_codes
=
{
200
})
ADMIN_CONTEXT_ID
=
ContextId
(
**
json_context_id
(
DEFAULT_CONTEXT_NAME
))
def
test_service_removal_bidir
(
# pylint: disable=redefined-outer-name, unused-argument
def
test_service_ietf_removal
(
context_client
:
ContextClient
,
# pylint: disable=redefined-outer-name
s
ervice_client
:
ServiceClient
,
# pylint: disable=redefined-outer-name
s
torage
:
Dict
):
# Verify the scenario has 1 service and 0 slices
response
=
context_client
.
GetContext
(
ADMIN_CONTEXT_ID
)
...
...
@@ -151,30 +118,24 @@ def test_service_removal_bidir(
LOGGER
.
warning
(
'
Services[{:d}] = {:s}
'
.
format
(
len
(
response
.
services
),
grpc_message_to_json_string
(
response
)))
assert
len
(
response
.
services
)
==
1
context_service_uuids
:
Set
[
Tuple
[
str
,
str
]]
=
set
()
assert
'
svc-uuid
'
in
storage
service_uuid
=
storage
[
'
svc-uuid
'
]
for
service
in
response
.
services
:
service_id
=
service
.
service_id
assert
service_id
.
service_uuid
.
uuid
==
service_uuid
assert
service
.
service_status
.
service_status
==
ServiceStatusEnum
.
SERVICESTATUS_ACTIVE
assert
service
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
response
=
context_client
.
ListConnections
(
service_id
)
LOGGER
.
warning
(
'
ServiceId[{:s}] => Connections[{:d}] = {:s}
'
.
format
(
grpc_message_to_json_string
(
service_id
),
len
(
response
.
connections
),
grpc_message_to_json_string
(
response
)))
if
service
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_OPTICAL_CONNECTIVITY
:
assert
len
(
response
.
connections
)
==
2
context_uuid
=
service_id
.
context_id
.
context_uuid
.
uuid
service_uuid
=
service_id
.
service_uuid
.
uuid
context_service_uuids
.
add
((
context_uuid
,
service_uuid
))
else
:
str_service
=
grpc_message_to_json_string
(
service
)
raise
Exception
(
'
Unexpected ServiceType: {:s}
'
.
format
(
str_service
))
# Identify service to delete
assert
len
(
context_service_uuids
)
==
1
context_uuid
,
service_uuid
=
set
(
context_service_uuids
).
pop
()
# Delete Service
service_client
.
DeleteService
(
ServiceId
(
**
json_service_id
(
service_uuid
,
json_context_id
(
context_uuid
))))
grpc_message_to_json_string
(
service_id
),
len
(
response
.
connections
),
grpc_message_to_json_string
(
response
)
))
assert
len
(
response
.
connections
)
==
1
URL
=
'
/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services/vpn-service={:s}/
'
.
format
(
service_uuid
)
do_rest_delete_request
(
URL
,
logger
=
LOGGER
,
expected_status_codes
=
{
204
})
# Verify the scenario has no services/slices
response
=
context_client
.
GetContext
(
ADMIN_CONTEXT_ID
)
...
...
This diff is collapsed.
Click to expand it.
src/tests/eucnc24/tests/test_functional_service_tfs.py
+
2
−
2
View file @
25d28216
...
...
@@ -31,7 +31,7 @@ LOGGER.setLevel(logging.DEBUG)
DESCRIPTOR_FILE
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'
..
'
,
'
data
'
,
'
tfs-service.json
'
)
ADMIN_CONTEXT_ID
=
ContextId
(
**
json_context_id
(
DEFAULT_CONTEXT_NAME
))
def
test_service_creation
_tfs
(
def
test_service_
tfs_
creation
(
context_client
:
ContextClient
,
# pylint: disable=redefined-outer-name
device_client
:
DeviceClient
,
# pylint: disable=redefined-outer-name
service_client
:
ServiceClient
,
# pylint: disable=redefined-outer-name
...
...
@@ -75,7 +75,7 @@ def test_service_creation_tfs(
))
assert
len
(
response
.
connections
)
==
1
def
test_service_removal
_tfs
(
def
test_service_
tfs_
removal
(
context_client
:
ContextClient
,
# pylint: disable=redefined-outer-name
service_client
:
ServiceClient
,
# pylint: disable=redefined-outer-name
):
...
...
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