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
0f7439d9
Verified
Commit
0f7439d9
authored
10 months ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Avoid race conditions in unit tests
parent
0ab46055
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!201
Add imported products
Pipeline
#86615
canceled
10 months ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cli/test_imports.py
+15
-2
15 additions, 2 deletions
test/cli/test_imports.py
with
15 additions
and
2 deletions
test/cli/test_imports.py
+
15
−
2
View file @
0f7439d9
import
json
import
time
from
pathlib
import
Path
import
pytest
...
...
@@ -191,6 +192,7 @@ def test_import_iptrunk_success(iptrunk_data):
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_IP_TRUNK
]))
==
0
assert
len
(
get_active_iptrunk_subscriptions
())
==
1
...
...
@@ -201,6 +203,7 @@ def test_import_site_success(site_data):
import_sites
(
mock_site_data
[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_SITE
]))
==
0
subscription
=
retrieve_subscription_by_subscription_instance_value
(
resource_type
=
"
site_name
"
,
value
=
mock_site_data
[
"
data
"
][
"
site_name
"
]
...
...
@@ -214,6 +217,7 @@ def test_import_site_twice(site_data, capfd):
# Second identical import should print ValidationError to stdout
import_sites
(
path_location
)
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
(
"""
Validation error: 4 validation errors for SiteImportModel
...
...
@@ -237,6 +241,7 @@ def test_import_site_with_invalid_data(site_data, capfd):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_sites
(
incorrect_site_data
[
"
path
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
(
"""
Validation error: 2 validation errors for SiteImportModel
...
...
@@ -252,6 +257,7 @@ site_longitude
def
test_import_router_success
(
site_subscription_factory
,
router_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_routers
(
router_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_active_router_subscriptions
())
==
1
...
...
@@ -259,6 +265,7 @@ def test_import_router_with_invalid_data(router_data, capfd):
broken_data
=
router_data
(
hostname
=
""
,
router_lo_ipv6_address
=
"
Not an IP address
"
)
import_routers
(
broken_data
[
"
path
"
])
# Only a Site has been added, no Router
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
1
out
,
_
=
capfd
.
readouterr
()
# The extra space at the end of the next line is required, and not dangling by accident.
...
...
@@ -273,6 +280,7 @@ def test_import_router_with_invalid_data(router_data, capfd):
def
test_import_iptrunk_successful
(
iptrunk_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
5
assert
len
(
get_active_iptrunk_subscriptions
())
==
1
...
...
@@ -280,6 +288,7 @@ def test_import_iptrunk_successful(iptrunk_data):
def
test_import_iptrunk_invalid_router_id_side_a_and_b
(
iptrunk_data
,
capfd
):
broken_data
=
iptrunk_data
(
side_a_node
=
"
Doesn
'
t exist
"
,
side_b_node
=
"
Also doesn
'
t exist
"
)
import_iptrunks
(
broken_data
[
"
path
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
...
...
@@ -299,8 +308,9 @@ def test_import_iptrunk_non_unique_members_side_a_and_b(iptrunk_data, faker, cap
side_b_members
=
[
duplicate_interface
for
_
in
range
(
5
)]
broken_data
=
iptrunk_data
(
side_a_members
=
side_a_members
,
side_b_members
=
side_b_members
)
import_iptrunks
(
broken_data
[
"
path
"
])
out
,
_
=
capfd
.
readouterr
()
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
assert
(
...
...
@@ -322,8 +332,9 @@ def test_import_iptrunk_side_a_member_count_mismatch(iptrunk_data, faker, capfd)
]
broken_data
=
iptrunk_data
(
side_a_members
=
side_a_members
,
side_b_members
=
side_b_members
)
import_iptrunks
(
broken_data
[
"
path
"
])
out
,
_
=
capfd
.
readouterr
(
)
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
assert
(
...
...
@@ -337,6 +348,7 @@ __root__
def
test_import_office_router_success
(
office_router_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_office_routers
(
office_router_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
2
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_OFFICE_ROUTER
]))
==
0
assert
len
(
get_subscriptions
([
ProductType
.
OFFICE_ROUTER
]))
==
1
...
...
@@ -345,6 +357,7 @@ def test_import_office_router_success(office_router_data):
def
test_import_super_pop_switch_success
(
super_pop_switch_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_super_pop_switches
(
super_pop_switch_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
2
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_SUPER_POP_SWITCH
]))
==
0
assert
len
(
get_subscriptions
([
ProductType
.
SUPER_POP_SWITCH
]))
==
1
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