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
Boxiang Sun
slapos.core
Commits
aaff5742
Commit
aaff5742
authored
Jun 14, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add/fix slapproxy tests about request()
parent
1b1b26b5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
5 deletions
+115
-5
slapos/tests/slapproxy.py
slapos/tests/slapproxy.py
+115
-5
No files found.
slapos/tests/slapproxy.py
View file @
aaff5742
...
@@ -251,28 +251,138 @@ class TestRequest(MasterMixin, unittest.TestCase):
...
@@ -251,28 +251,138 @@ class TestRequest(MasterMixin, unittest.TestCase):
Set of tests for requests
Set of tests for requests
"""
"""
def
test_request_
get
_connection_parameter
(
self
):
def
test_request_
empty
_connection_parameter
(
self
):
"""
"""
Test that
it is possible to fetch the correct parameters of an instance
.
Test that
we get empty connection parameter dict if it is not yet defined
.
"""
"""
self
.
add_free_partition
(
1
)
self
.
add_free_partition
(
1
)
# XXX-Cedric : this is crazy. I don't want to define any requested_by_stupid_thing.
# XXX-Cedric : this is crazy. I don't want to define any requested_by_stupid_thing.
requested_by_partition_id
=
'0'
requested_by_partition_id
=
'0'
partition_reference
=
'myinstance'
partition_reference
=
'myinstance'
connection_dict
=
{
'parameter'
:
'value'
}
software_release_url
=
'http://sr//'
# Request empty instance
# Request empty instance
partition
=
self
.
request
(
'http://sr//'
,
None
,
partition_reference
,
requested_by_partition_id
)
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
)
self
.
assertEquals
(
partition
.
getConnectionParameterDict
(),
{})
def
test_request_empty_instance_parameter
(
self
):
"""
Test that we get empty instance parameter dict if it is not defined.
"""
self
.
add_free_partition
(
1
)
# XXX-Cedric : this is crazy. I don't want to define any requested_by_stupid_thing.
requested_by_partition_id
=
'0'
partition_reference
=
'myinstance'
software_release_url
=
'http://sr//'
# Request empty instance
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
)
self
.
assertEquals
(
partition
.
getInstanceParameterDict
(),
{})
def
test_request_get_parameter
(
self
):
"""
Test that it is possible to fetch the correct parameters (connection
parameters, instance parameters) of an instance.
"""
self
.
add_free_partition
(
1
)
# XXX-Cedric : this is crazy. I don't want to define any requested_by_stupid_thing.
requested_by_partition_id
=
'0'
partition_reference
=
'myinstance'
software_release_url
=
'http://sr//'
partition_parameter_kw
=
{
'some_instance_parameter'
:
'some_instance_value'
}
connection_dict
=
{
'some_connection_parameter'
:
'some_connection_value'
}
# Request empty instance
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
,
partition_parameter_kw
=
partition_parameter_kw
)
# Simulate instance being deployed, set connection parameters
# Simulate instance being deployed, set connection parameters
self
.
setConnectionDict
(
partition
.
_partition_id
,
connection_dict
)
self
.
setConnectionDict
(
partition
.
_partition_id
,
connection_dict
)
# Fetch parameters, compare with sent parameters
# Fetch parameters, compare with sent parameters
partition
=
self
.
request
(
'http://sr//'
,
None
,
partition_reference
,
requested_by_partition_id
)
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
,
partition_parameter_kw
=
partition_parameter_kw
)
self
.
assertEqual
(
self
.
assertEqual
(
partition
.
getConnectionParameterDict
(),
partition
.
getConnectionParameterDict
(),
connection_dict
connection_dict
)
)
self
.
assertEqual
(
partition
.
getInstanceParameterDict
(),
partition_parameter_kw
)
def
test_request_get_state
(
self
):
"""
Test that it is possible to fetch the state from a partition got from
request().
"""
self
.
add_free_partition
(
1
)
# XXX-Cedric: this is crazy. I don't want to define any requested_by_stupid_thing.
requested_by_partition_id
=
'0'
partition_reference
=
'myinstance'
software_release_url
=
'http://sr//'
requested_state
=
'started'
# Request empty instance
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
,
state
=
requested_state
)
# Check that partition has all needed parameters
self
.
assertEqual
(
partition
.
getState
(),
requested_state
)
def
test_request_get_instance_guid
(
self
):
"""
Test that it is possible to fetch the instance_guid from a partition got from
request().
Note: in the slapproxy, the instance_guid should be equal to the
partition_id.
"""
self
.
add_free_partition
(
1
)
# XXX-Cedric: this is crazy. I don't want to define any requested_by_stupid_thing.
requested_by_partition_id
=
'0'
partition_reference
=
'myinstance'
software_release_url
=
'http://sr//'
# Request empty instance
partition
=
self
.
request
(
software_release_url
,
None
,
partition_reference
,
requested_by_partition_id
)
# Check that partition has all needed parameters
self
.
assertIsNotNone
(
partition
.
getInstanceGuid
())
self
.
assertEqual
(
partition
.
getInstanceGuid
(),
partition
.
getId
())
def
test_two_request_one_partition_free
(
self
):
def
test_two_request_one_partition_free
(
self
):
"""
"""
...
...
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