Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos.core
Commits
7ba3ec4f
Commit
7ba3ec4f
authored
Sep 20, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapproxy: Add test for forwarded requests entries
parent
61d0e497
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
2 deletions
+54
-2
slapos/tests/test_slapproxy.py
slapos/tests/test_slapproxy.py
+54
-2
No files found.
slapos/tests/test_slapproxy.py
View file @
7ba3ec4f
...
...
@@ -1781,7 +1781,7 @@ database_uri = %(rootdir)s/lib/external_proxy.db
"""
Test there is no instance on local proxy.
Test there is instance on external proxy.
Test there is instance reference in external table of databse of local proxy.
Test there is instance reference in external table of datab
a
se of local proxy.
"""
# Adjust name to match forwarding prefix
name
=
'%s_%s'
%
(
requester
or
'user'
,
name
)
...
...
@@ -1853,7 +1853,7 @@ database_uri = %(rootdir)s/lib/external_proxy.db
def
testForwardToMasterInList
(
self
):
"""
Test that explicit
e
ly asking a master_url in SLA causes
Test that explicitly asking a master_url in SLA causes
proxy to forward request to this master.
"""
dummy_parameter_dict
=
{
'foo'
:
'bar'
}
...
...
@@ -1871,6 +1871,32 @@ database_uri = %(rootdir)s/lib/external_proxy.db
self
.
external_master_url
)
def
testForwardToMasterInList_NoDuplicates
(
self
):
"""
Test that multiple explicitly forwarded requests for the same instance
do not result in duplicate entries in the proxy database.
"""
dummy_parameter_dict
=
{
'foo'
:
'bar'
}
instance_reference
=
'MyFirstInstance'
self
.
format_for_number_of_partitions
(
1
)
self
.
external_proxy_format_for_number_of_partitions
(
1
)
filter_kw
=
{
'master_url'
:
self
.
external_master_url
}
for
_
in
range
(
2
):
partition
=
self
.
request
(
self
.
software_release_not_in_list
,
None
,
instance_reference
,
'slappart0'
,
filter_kw
=
filter_kw
,
partition_parameter_kw
=
dummy_parameter_dict
)
# Explicitly do the relevant test, even if _checkInstanceIsFowarded does it too
entries
=
slapos
.
proxy
.
views
.
execute_db
(
'forwarded_partition_request'
,
'SELECT * from %s'
,
db
=
self
.
db
)
self
.
assertEqual
(
len
(
entries
),
1
)
self
.
_checkInstanceIsFowarded
(
instance_reference
,
'slappart0'
,
dummy_parameter_dict
,
self
.
software_release_not_in_list
)
self
.
assertEqual
(
partition
.
_master_url
,
self
.
external_master_url
)
def
testForwardToMasterNotInList
(
self
):
"""
Test that explicitely asking a master_url in SLA causes
...
...
@@ -1904,6 +1930,32 @@ database_uri = %(rootdir)s/lib/external_proxy.db
self
.
assertEqual
(
self
.
external_software_release
,
partition
.
getSoftwareRelease
())
self
.
assertEqual
({},
partition
.
getConnectionParameterDict
())
def
testForwardRequest_SoftwareReleaseList_NoDuplicates
(
self
):
"""
Test that multiple automatically forwarded requests for the same instance
do not result in duplicate entries in the proxy database.
"""
dummy_parameter_dict
=
{
'foo'
:
'bar'
}
instance_reference
=
'MyFirstInstance'
self
.
format_for_number_of_partitions
(
1
)
self
.
external_proxy_format_for_number_of_partitions
(
1
)
for
_
in
range
(
2
):
partition
=
self
.
request
(
self
.
external_software_release
,
None
,
instance_reference
,
'slappart0'
,
partition_parameter_kw
=
dummy_parameter_dict
)
# Explicitly do the relevant test, even if _checkInstanceIsFowarded does it too
entries
=
slapos
.
proxy
.
views
.
execute_db
(
'forwarded_partition_request'
,
'SELECT * from %s'
,
db
=
self
.
db
)
self
.
assertEqual
(
len
(
entries
),
1
)
self
.
_checkInstanceIsFowarded
(
instance_reference
,
'slappart0'
,
dummy_parameter_dict
,
self
.
external_software_release
)
instance_parameter_dict
=
partition
.
getInstanceParameterDict
()
instance_parameter_dict
.
pop
(
'timestamp'
)
self
.
assertEqual
(
dummy_parameter_dict
,
instance_parameter_dict
)
self
.
assertEqual
(
self
.
external_software_release
,
partition
.
getSoftwareRelease
())
self
.
assertEqual
({},
partition
.
getConnectionParameterDict
())
def
testForwardRequestFromPartition
(
self
):
"""
Test that instance request is forwarded and requested from computer partition.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment