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
Lisa Casino
slapos.core
Commits
fbb680f5
Commit
fbb680f5
authored
Sep 20, 2012
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved slapproxy tests
parent
bcac5a39
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
33 deletions
+30
-33
slapos/tests/slapproxy.py
slapos/tests/slapproxy.py
+30
-33
No files found.
slapos/tests/slapproxy.py
View file @
fbb680f5
...
@@ -214,30 +214,13 @@ class MasterMixin(BasicMixin):
...
@@ -214,30 +214,13 @@ class MasterMixin(BasicMixin):
'_parameter_dict'
,
None
)
'_parameter_dict'
,
None
)
return
computer_partition
return
computer_partition
def
setComputerPartitionConnectionXml
(
self
,
instance
):
def
setConnectionDict
(
self
,
partition_id
,
"""
connection_dict
,
slave_reference
=
None
):
Will send instance connection information to server
self
.
app
.
post
(
'/setComputerPartitionConnectionXml'
,
data
=
{
including from slaves in this partition
'computer_id'
:
self
.
computer_id
,
"""
'computer_partition_id'
:
partition_id
,
# Will post information about slaves
'connection_xml'
:
xml_marshaller
.
xml_marshaller
.
dumps
(
connection_dict
),
for
slave
in
instance
.
_parameter_dict
[
'slave_instance_list'
]:
'slave_reference'
:
slave_reference
})
request_dict
=
{
'slave_reference'
:
slave
[
'slave_reference'
],
'computer_partition_id'
:
instance
.
_partition_id
,
'connection_xml'
:
xml_marshaller
.
xml_marshaller
.
dumps
(
instance
.
_connection_dict
),
}
self
.
app
.
post
(
'/setComputerPartitionConnectionXml'
,
data
=
request_dict
)
# Will post information about instance
request_dict
=
{
'slave_reference'
:
None
,
'computer_partition_id'
:
instance
.
_partition_id
,
'connection_xml'
:
xml_marshaller
.
xml_marshaller
.
dumps
(
instance
.
_connection_dict
),
}
self
.
app
.
post
(
'/setComputerPartitionConnectionXml'
,
data
=
request_dict
)
class
TestRequest
(
MasterMixin
,
unittest
.
TestCase
):
class
TestRequest
(
MasterMixin
,
unittest
.
TestCase
):
...
@@ -311,18 +294,23 @@ class TestRequest (MasterMixin, unittest.TestCase):
...
@@ -311,18 +294,23 @@ class TestRequest (MasterMixin, unittest.TestCase):
"""
"""
Successfull request slave instance follow these steps:
Successfull request slave instance follow these steps:
1. Provide one corresponding partition
1. Provide one corresponding partition
2. Ask for Slave instance.
Error is raise because it is not ready
2. Ask for Slave instance.
But no connection parameters
But slave is added to Master Instance slave list
But slave is added to Master Instance slave list
3. Master Instance get updated information (including slave list)
3. Master Instance get updated information (including slave list)
4. Master instance post information about slave
s and itself
4. Master instance post information about slave
connection parameters
5. Ask for slave instance is successfull and return a computer instance
5. Ask for slave instance is successfull and return a computer instance
"""
"""
self
.
add_free_partition
(
6
)
self
.
add_free_partition
(
6
)
# Provide partition
# Provide partition
master_partition_id
=
self
.
request
(
'http://sr//'
,
None
,
master_partition_id
=
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart4'
).
_partition_id
'Maria'
,
'slappart4'
).
_partition_id
# Failed request of slave instance
# First request of slave instance
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart2'
,
shared
=
True
)
name
=
'Maria'
requester
=
'slappart2'
our_slave
=
self
.
request
(
'http://sr//'
,
None
,
name
,
requester
,
shared
=
True
)
self
.
assertIsInstance
(
our_slave
,
slapos
.
slap
.
ComputerPartition
)
self
.
assertEqual
(
our_slave
.
_connection_dict
,{})
# Get updated information for master partition
# Get updated information for master partition
rv
=
self
.
app
.
get
(
'/getFullComputerInformation?computer_id='
rv
=
self
.
app
.
get
(
'/getFullComputerInformation?computer_id='
+
self
.
computer_id
)
+
self
.
computer_id
)
...
@@ -331,8 +319,17 @@ class TestRequest (MasterMixin, unittest.TestCase):
...
@@ -331,8 +319,17 @@ class TestRequest (MasterMixin, unittest.TestCase):
if
instance
.
_partition_id
==
master_partition_id
:
if
instance
.
_partition_id
==
master_partition_id
:
master_partition
=
instance
master_partition
=
instance
# Send information about slave
# Send information about slave
self
.
setComputerPartitionConnectionXml
(
master_partition
)
for
slave
in
master_partition
.
_parameter_dict
.
get
(
'slave_instance_list'
):
# Successfull slave request
print
slave
self
.
assertIsInstance
(
slave_reference
=
slave
.
get
(
'slave_reference'
)
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart2'
,
shared
=
True
),
# Check we got the right slave
slapos
.
slap
.
ComputerPartition
)
if
requester
and
name
in
slave_reference
:
slave_address
=
{
'url'
:
'%s.master.com'
%
slave_reference
}
self
.
setConnectionDict
(
partition_id
=
master_partition
.
_partition_id
,
connection_dict
=
slave_address
,
slave_reference
=
slave_reference
)
# Successfull slave request with connection parameters
our_slave
=
self
.
request
(
'http://sr//'
,
None
,
name
,
requester
,
shared
=
True
)
self
.
assertIsInstance
(
our_slave
,
slapos
.
slap
.
ComputerPartition
)
self
.
assertEqual
(
slave_address
,
our_slave
.
_connection_dict
)
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