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
Léo-Paul Géneau
slapos.core
Commits
c93293cd
Commit
c93293cd
authored
Feb 24, 2023
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP slapos_jio_api_style: Continue Testing, this time instance interaction
parent
71d64127
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
190 additions
and
545 deletions
+190
-545
master/bt5/slapos_jio_api_style/TestTemplateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
...plateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
+190
-545
No files found.
master/bt5/slapos_jio_api_style/TestTemplateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
View file @
c93293cd
...
@@ -546,541 +546,173 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJIOAPIMixin):
...
@@ -546,541 +546,173 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJIOAPIMixin):
self
.
assertEqual
(
expected_dict
,
software_dict
)
self
.
assertEqual
(
expected_dict
,
software_dict
)
class
TestSlapOSSlapToolInstanceAccess
(
TestSlapOSJIOAPIMixin
):
class
TestSlapOSSlapToolInstanceAccess
(
TestSlapOSJIOAPIMixin
):
def
deactivated_test
_getComputerPartitionCertificate
(
self
):
def
test_10
_getComputerPartitionCertificate
(
self
):
self
.
_makeComplexComputeNode
()
self
.
_makeComplexComputeNode
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
self
.
callUpdateRevisionAndTic
()
portal_type
=
'Compute Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
response
=
self
.
portal_slap
.
getComputerPartitionCertificate
(
self
.
compute_node_id
,
partition_id
)
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
'public, max-age=0, must-revalidate'
,
response
.
headers
.
get
(
'cache-control'
))
self
.
assertEqual
(
'REMOTE_USER'
,
response
.
headers
.
get
(
'vary'
))
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<string>certificate</string>
<string>%(instance_certificate)s</string>
<string>key</string>
<string>%(instance_key)s</string>
</dictionary>
</marshal>
"""
%
dict
(
instance_certificate
=
self
.
start_requested_software_instance
.
getSslCertificate
(),
instance_key
=
self
.
start_requested_software_instance
.
getSslKey
()
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
deactivated_test_getFullComputerInformation
(
self
):
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
response
=
self
.
portal_slap
.
getFullComputerInformation
(
self
.
compute_node_id
)
certificate_dict
=
self
.
getToApi
({
self
.
assertEqual
(
200
,
response
.
status
)
"portal_type"
:
"Software Instance Certificate Record"
,
self
.
assertEqual
(
'public, max-age=1, stale-if-error=604800'
,
"reference"
:
self
.
start_requested_software_instance
.
getReference
(),
response
.
headers
.
get
(
'cache-control'
))
})
self
.
assertEqual
(
'REMOTE_USER'
,
response
=
self
.
portal
.
REQUEST
.
RESPONSE
response
.
headers
.
get
(
'vary'
))
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertFalse
(
'etag'
in
response
.
headers
)
self
.
assertEqual
(
'application/json'
,
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
response
.
headers
.
get
(
'content-type'
))
# check returned XML
self
.
assertTrue
(
xml_fp
=
StringIO
.
StringIO
()
certificate_dict
.
pop
(
"$schema"
).
endswith
(
"SoftwareInstanceCertificateRecord_getFromJSON/getOutputJSONSchema"
)
)
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
self
.
assertEqual
(
certificate_dict
,
{
stream
=
xml_fp
)
"key"
:
self
.
start_requested_software_instance
.
getSslKey
(),
xml_fp
.
seek
(
0
)
"certificate"
:
self
.
start_requested_software_instance
.
getSslCertificate
(),
got_xml
=
xml_fp
.
read
()
"portal_type"
:
"Software Instance Certificate Record"
,
expected_xml
=
"""
\
"reference"
:
self
.
start_requested_software_instance
.
getReference
(),
<?xml version='1.0' encoding='UTF-8'?>
})
<marshal>
<object id='i2' module='slapos.slap.slap' class='Computer'>
<tuple>
<string>%(compute_node_id)s</string>
</tuple>
<dictionary id='i3'>
<string>_computer_id</string>
<string>%(compute_node_id)s</string>
<string>_computer_partition_list</string>
<list id='i4'>
<object id='i5' module='slapos.slap.slap' class='ComputerPartition'>
<tuple>
<string>%(compute_node_id)s</string>
<string>partition1</string>
</tuple>
<dictionary id='i6'>
<string>_access_status</string>
<string>%(access_status)s</string>
<string>_computer_id</string>
<string>%(compute_node_id)s</string>
<string>_connection_dict</string>
<dictionary id='i7'/>
<string>_filter_dict</string>
<dictionary id='i8'>
<string>paramé</string>
<string>%(sla)s</string>
</dictionary>
<string>_instance_guid</string>
<string>%(instance_guid)s</string>
<string>_need_modification</string>
<int>1</int>
<string>_parameter_dict</string>
<dictionary id='i9'>
<string>full_ip_list</string>
<list id='i10'/>
<string>instance_title</string>
<string>%(instance_title)s</string>
<string>ip_list</string>
<list id='i11'>
<tuple>
<string/>
<string>ip_address_1</string>
</tuple>
</list>
<string>paramé</string>
<string>%(param)s</string>
<string>root_instance_short_title</string>
<string/>
<string>root_instance_title</string>
<string>%(root_instance_title)s</string>
<string>slap_computer_id</string>
<string>%(compute_node_id)s</string>
<string>slap_computer_partition_id</string>
<string>partition1</string>
<string>slap_software_release_url</string>
<string>%(software_release_url)s</string>
<string>slap_software_type</string>
<string>%(software_type)s</string>
<string>slave_instance_list</string>
<list id='i12'>
<dictionary id='i13'>
<string>paramé</string>
<string>%(slave_1_param)s</string>
<string>slap_software_type</string>
<string>%(slave_1_software_type)s</string>
<string>slave_reference</string>
<string>%(slave_1_instance_guid)s</string>
<string>slave_title</string>
<string>%(slave_1_title)s</string>
<string>timestamp</string>
<int>%(timestamp)s</int>
</dictionary>
</list>
<string>timestamp</string>
<string>%(timestamp)s</string>
</dictionary>
<string>_partition_id</string>
<string>partition1</string>
<string>_request_dict</string>
<none/>
<string>_requested_state</string>
<string>started</string>
<string>_software_release_document</string>
<object id='i14' module='slapos.slap.slap' class='SoftwareRelease'>
<tuple>
<string>%(software_release_url)s</string>
<string>%(compute_node_id)s</string>
</tuple>
<dictionary id='i15'>
<string>_computer_guid</string>
<string>%(compute_node_id)s</string>
<string>_software_instance_list</string>
<list id='i16'/>
<string>_software_release</string>
<string>%(software_release_url)s</string>
</dictionary>
</object>
</dictionary>
</object>
</list>
<string>_software_release_list</string>
<list id='i17'/>
</dictionary>
</object>
</marshal>
"""
%
dict
(
compute_node_id
=
self
.
compute_node_id
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
instance_title
=
self
.
start_requested_software_instance
.
getTitle
(),
root_instance_title
=
self
.
start_requested_software_instance
.
getSpecialiseValue
().
getTitle
(),
software_release_url
=
self
.
start_requested_software_instance
.
getUrlString
(),
software_type
=
self
.
start_requested_software_instance
.
getSourceReference
(),
param
=
self
.
start_requested_software_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
sla
=
self
.
start_requested_software_instance
.
getSlaXmlAsDict
()[
'paramé'
],
timestamp
=
int
(
self
.
start_requested_software_instance
.
getModificationDate
()),
slave_1_param
=
self
.
start_requested_slave_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
slave_1_software_type
=
self
.
start_requested_slave_instance
.
getSourceReference
(),
slave_1_instance_guid
=
self
.
start_requested_slave_instance
.
getReference
(),
slave_1_title
=
self
.
start_requested_slave_instance
.
getTitle
(),
access_status
=
"#error no data found for %s"
%
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
deactivated_test_getComputerPartitionStatus
(
self
):
def
test_11_getFullComputerInformationWithSharedInstance
(
self
,
with_slave
=
True
):
self
.
_makeComplexComputeNode
()
self
.
_makeComplexComputeNode
(
with_slave
=
with_slave
)
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
self
.
callUpdateRevisionAndTic
()
portal_type
=
'Compute Partition'
).
getReference
()
instance
=
self
.
start_requested_software_instance
created_at
=
rfc1123_date
(
DateTime
())
self
.
login
(
instance
.
getUserId
())
since
=
created_at
instance_list_response
=
self
.
allDocsToApi
({
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
"compute_node_id"
:
self
.
compute_node_id
,
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
compute_node_id
,
"portal_type"
:
"Software Instance"
,
partition_id
)
})
self
.
assertEqual
(
200
,
response
.
status
)
response
=
self
.
portal
.
REQUEST
.
RESPONSE
self
.
assertEqual
(
'public, max-age=60, stale-if-error=604800'
,
self
.
assertEqual
(
200
,
response
.
getStatus
())
response
.
headers
.
get
(
'cache-control'
))
self
.
assertEqual
(
'application/json'
,
self
.
assertEqual
(
'REMOTE_USER'
,
response
.
headers
.
get
(
'vary'
))
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
response
.
headers
.
get
(
'content-type'
))
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
self
.
assertTrue
(
instance_list_response
[
"$schema"
].
endswith
(
"jIOWebSection_searchInstanceFromJSON/getOutputJSONSchema"
))
stream
=
xml_fp
)
result_list
=
instance_list_response
[
"result_list"
]
xml_fp
.
seek
(
0
)
self
.
assertEqual
(
1
,
len
(
result_list
))
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<string>created_at</string>
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
<string/>
<string>text</string>
<string>#error no data found for %(instance_guid)s</string>
<string>user</string>
<string>SlapOS Master</string>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
since
=
since
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
deactivated_test_getComputerPartitionStatus_visited
(
self
):
self
.
login
()
self
.
_makeComplexComputeNode
()
# Check result_list match instance_list=
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
expected_instance_list
=
[{
portal_type
=
'Compute Partition'
).
getReference
()
"api_revision"
:
instance
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
()),
created_at
=
rfc1123_date
(
DateTime
())
"compute_partition_id"
:
instance
.
getAggregateReference
(),
since
=
created_at
"get_parameters"
:
{
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
"portal_type"
:
"Software Instance"
,
self
.
portal_slap
.
registerComputerPartition
(
self
.
compute_node_id
,
partition_id
)
"reference"
:
instance
.
getReference
(),
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
compute_node_id
,
},
partition_id
)
"portal_type"
:
"Software Instance"
,
self
.
assertEqual
(
200
,
response
.
status
)
"reference"
:
instance
.
getReference
(),
self
.
assertEqual
(
'public, max-age=60, stale-if-error=604800'
,
"software_release_uri"
:
instance
.
getUrlString
(),
response
.
headers
.
get
(
'cache-control'
))
"state"
:
self
.
getAPIStateFromSlapState
(
instance
.
getSlapState
()),
self
.
assertEqual
(
'REMOTE_USER'
,
"title"
:
instance
.
getTitle
(),
response
.
headers
.
get
(
'vary'
))
}]
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
expected_instance_list
,
instance_list_response
[
"result_list"
])
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
instance_resut_dict
=
expected_instance_list
[
0
]
# Get instance as "user"
self
.
login
(
instance
.
getUserId
())
instance_dict
=
self
.
getToApi
(
instance_resut_dict
[
"get_parameters"
])
response
=
self
.
portal
.
REQUEST
.
RESPONSE
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
response
.
headers
.
get
(
'content-type'
))
# check returned XML
# Check Data is correct
xml_fp
=
StringIO
.
StringIO
()
self
.
login
()
partition
=
instance
.
getAggregateValue
(
portal_type
=
"Compute Partition"
)
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
self
.
assertEqual
({
stream
=
xml_fp
)
"$schema"
:
instance
.
getJSONSchemaUrl
(),
xml_fp
.
seek
(
0
)
"title"
:
instance
.
getTitle
(),
got_xml
=
xml_fp
.
read
()
"reference"
:
instance
.
getReference
(),
expected_xml
=
"""
\
"software_release_uri"
:
instance
.
getUrlString
(),
<?xml version='1.0' encoding='UTF-8'?>
"software_type"
:
instance
.
getSourceReference
(),
<marshal>
"state"
:
self
.
getAPIStateFromSlapState
(
instance
.
getSlapState
()),
<dictionary id='i2'>
"connection_parameters"
:
instance
.
getConnectionXmlAsDict
(),
<string>created_at</string>
"parameters"
:
instance
.
getInstanceXmlAsDict
(),
<string>%(created_at)s</string>
"shared"
:
False
,
<string>no_data</string>
"root_instance_title"
:
instance
.
getSpecialiseValue
().
getTitle
(),
<int>1</int>
"ip_list"
:
<string>since</string>
[
<string>%(since)s</string>
[
<string>state</string>
x
.
getNetworkInterface
(
''
),
<string/>
x
.
getIpAddress
()
<string>text</string>
]
for
x
in
partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
)
<string>#error no data found for %(instance_guid)s</string>
],
<string>user</string>
"full_ip_list"
:
[],
<string>SlapOS Master</string>
"sla_parameters"
:
instance
.
getSlaXmlAsDict
(),
</dictionary>
"compute_node_id"
:
partition
.
getParentValue
().
getReference
(),
</marshal>
"compute_partition_id"
:
partition
.
getReference
(),
"""
%
dict
(
"processing_timestamp"
:
instance
.
getSlapTimestamp
(),
created_at
=
created_at
,
"access_status_message"
:
instance
.
getTextAccessStatus
(),
since
=
since
,
"api_revision"
:
instance
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
()),
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
"portal_type"
:
instance
.
getPortalType
(),
compute_node_id
=
self
.
compute_node_id
,
},
instance_dict
)
partition_id
=
partition_id
)
def
test_11_bis_getFullComputerInformationNoSharedInstance
(
self
):
self
.
assertEqual
(
expected_xml
,
got_xml
,
self
.
test_11_getFullComputerInformationWithSharedInstance
(
with_slave
=
False
)
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
deactivated_test_registerComputerPartition_withSlav
e
(
self
):
def
test_12_getSharedInstanc
e
(
self
):
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
self
.
callUpdateRevisionAndTic
()
portal_type
=
'Compute Partition'
).
getReference
()
instance
=
self
.
start_requested_software_instance
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
# Check Slaves
response
=
self
.
portal_slap
.
registerComputerPartition
(
self
.
compute_node_id
,
partition_id
)
self
.
login
(
instance
.
getUserId
())
self
.
assertEqual
(
200
,
response
.
status
)
# XXX It should be the same portal_type
self
.
assertEqual
(
'public, max-age=1, stale-if-error=604800'
,
shared_instance_list_response
=
self
.
allDocsToApi
({
response
.
headers
.
get
(
'cache-control'
))
"host_instance_reference"
:
instance
.
getReference
(),
self
.
assertEqual
(
'REMOTE_USER'
,
"portal_type"
:
"Shared Instance"
,
response
.
headers
.
get
(
'vary'
))
})
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
maxDiff
=
None
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
=
self
.
portal
.
REQUEST
.
RESPONSE
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
response
.
headers
.
get
(
'content-type'
))
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
self
.
assertTrue
(
stream
=
xml_fp
)
shared_instance_list_response
.
pop
(
"$schema"
).
endswith
(
"jIOWebSection_searchInstanceFromJSON/getOutputJSONSchema"
)
xml_fp
.
seek
(
0
)
)
got_xml
=
xml_fp
.
read
()
shared_instance
=
self
.
start_requested_slave_instance
expected_xml
=
"""
\
shared_instance_revision
=
shared_instance
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
())
<?xml version='1.0' encoding='UTF-8'?>
self
.
assertEqual
(
shared_instance_list_response
,
<marshal>
{
<object id='i2' module='slapos.slap.slap' class='ComputerPartition'>
'current_page_full'
:
False
,
<tuple>
'next_page_request'
:
{
'from_api_revision'
:
shared_instance_revision
,
<string>%(compute_node_id)s</string>
'host_instance_reference'
:
instance
.
getReference
(),
<string>partition1</string>
'portal_type'
:
'Shared Instance'
},
</tuple>
'result_list'
:
[{
'api_revision'
:
shared_instance_revision
,
<dictionary id='i3'>
'compute_partition_id'
:
'partition1'
,
<string>_computer_id</string>
'get_parameters'
:
{
'portal_type'
:
'Software Instance'
,
<string>%(compute_node_id)s</string>
'reference'
:
shared_instance
.
getReference
()},
<string>_connection_dict</string>
'portal_type'
:
'Software Instance'
,
<dictionary id='i4'/>
'reference'
:
shared_instance
.
getReference
(),
<string>_filter_dict</string>
'state'
:
'started'
,
<dictionary id='i5'>
'title'
:
shared_instance
.
getTitle
()}]
<string>paramé</string>
})
<string>%(sla)s</string>
</dictionary>
<string>_instance_guid</string>
<string>%(instance_guid)s</string>
<string>_need_modification</string>
<int>1</int>
<string>_parameter_dict</string>
<dictionary id='i6'>
<string>full_ip_list</string>
<list id='i7'/>
<string>instance_title</string>
<string>%(instance_title)s</string>
<string>ip_list</string>
<list id='i8'>
<tuple>
<string/>
<string>ip_address_1</string>
</tuple>
</list>
<string>paramé</string>
<string>%(param)s</string>
<string>root_instance_short_title</string>
<string/>
<string>root_instance_title</string>
<string>%(root_instance_title)s</string>
<string>slap_computer_id</string>
<string>%(compute_node_id)s</string>
<string>slap_computer_partition_id</string>
<string>partition1</string>
<string>slap_software_release_url</string>
<string>%(software_release_url)s</string>
<string>slap_software_type</string>
<string>%(software_type)s</string>
<string>slave_instance_list</string>
<list id='i9'>
<dictionary id='i10'>
<string>connection-parameter-hash</string>
<string>4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945</string>
<string>paramé</string>
<string>%(slave_1_param)s</string>
<string>slap_software_type</string>
<string>%(slave_1_software_type)s</string>
<string>slave_reference</string>
<string>%(slave_1_instance_guid)s</string>
<string>slave_title</string>
<string>%(slave_1_title)s</string>
<string>timestamp</string>
<int>%(timestamp)s</int>
</dictionary>
</list>
<string>timestamp</string>
<string>%(timestamp)s</string>
</dictionary>
<string>_partition_id</string>
<string>partition1</string>
<string>_request_dict</string>
<none/>
<string>_requested_state</string>
<string>started</string>
<string>_software_release_document</string>
<object id='i11' module='slapos.slap.slap' class='SoftwareRelease'>
<tuple>
<string>%(software_release_url)s</string>
<string>%(compute_node_id)s</string>
</tuple>
<dictionary id='i12'>
<string>_computer_guid</string>
<string>%(compute_node_id)s</string>
<string>_software_instance_list</string>
<list id='i13'/>
<string>_software_release</string>
<string>%(software_release_url)s</string>
</dictionary>
</object>
<string>_synced</string>
<bool>1</bool>
</dictionary>
</object>
</marshal>
"""
%
dict
(
compute_node_id
=
self
.
compute_node_id
,
param
=
self
.
start_requested_software_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
sla
=
self
.
start_requested_software_instance
.
getSlaXmlAsDict
()[
'paramé'
],
software_release_url
=
self
.
start_requested_software_instance
.
getUrlString
(),
timestamp
=
int
(
self
.
start_requested_software_instance
.
getModificationDate
()),
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
instance_title
=
self
.
start_requested_software_instance
.
getTitle
(),
root_instance_title
=
self
.
start_requested_software_instance
.
getSpecialiseValue
().
getTitle
(),
software_type
=
self
.
start_requested_software_instance
.
getSourceReference
(),
slave_1_param
=
self
.
start_requested_slave_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
slave_1_software_type
=
self
.
start_requested_slave_instance
.
getSourceReference
(),
slave_1_instance_guid
=
self
.
start_requested_slave_instance
.
getReference
(),
slave_1_title
=
self
.
start_requested_slave_instance
.
getTitle
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
deactivated_test_registerComputerPartition
(
self
):
instance_dict
=
self
.
getToApi
(
shared_instance_list_response
[
"result_list"
][
0
][
"get_parameters"
])
self
.
_makeComplexComputeNode
()
response
=
self
.
portal
.
REQUEST
.
RESPONSE
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
self
.
assertEqual
(
200
,
response
.
getStatus
())
portal_type
=
'Compute Partition'
).
getReference
()
self
.
assertEqual
(
'application/json'
,
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
response
=
self
.
portal_slap
.
registerComputerPartition
(
self
.
compute_node_id
,
partition_id
)
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
'public, max-age=1, stale-if-error=604800'
,
response
.
headers
.
get
(
'cache-control'
))
self
.
assertEqual
(
'REMOTE_USER'
,
response
.
headers
.
get
(
'vary'
))
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
response
.
headers
.
get
(
'content-type'
))
# check returned XML
# Check Data is correct
xml_fp
=
StringIO
.
StringIO
()
self
.
login
()
partition
=
instance
.
getAggregateValue
(
portal_type
=
"Compute Partition"
)
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
self
.
assertEqual
({
stream
=
xml_fp
)
"$schema"
:
instance
.
getJSONSchemaUrl
(),
xml_fp
.
seek
(
0
)
"title"
:
shared_instance
.
getTitle
(),
got_xml
=
xml_fp
.
read
()
"reference"
:
shared_instance
.
getReference
(),
expected_xml
=
"""
\
"software_release_uri"
:
shared_instance
.
getUrlString
(),
<?xml version='1.0' encoding='UTF-8'?>
"software_type"
:
shared_instance
.
getSourceReference
(),
<marshal>
"state"
:
self
.
getAPIStateFromSlapState
(
shared_instance
.
getSlapState
()),
<object id='i2' module='slapos.slap.slap' class='ComputerPartition'>
"connection_parameters"
:
shared_instance
.
getConnectionXmlAsDict
(),
<tuple>
"parameters"
:
shared_instance
.
getInstanceXmlAsDict
(),
<string>%(compute_node_id)s</string>
"shared"
:
False
,
<string>partition1</string>
"root_instance_title"
:
shared_instance
.
getSpecialiseValue
().
getTitle
(),
</tuple>
"ip_list"
:
[],
<dictionary id='i3'>
"full_ip_list"
:
[],
<string>_computer_id</string>
"sla_parameters"
:
shared_instance
.
getSlaXmlAsDict
(),
<string>%(compute_node_id)s</string>
"compute_node_id"
:
partition
.
getParentValue
().
getReference
(),
<string>_connection_dict</string>
"compute_partition_id"
:
partition
.
getReference
(),
<dictionary id='i4'/>
"processing_timestamp"
:
shared_instance
.
getSlapTimestamp
(),
<string>_filter_dict</string>
"access_status_message"
:
shared_instance
.
getTextAccessStatus
(),
<dictionary id='i5'>
"api_revision"
:
shared_instance_revision
,
<string>paramé</string>
"portal_type"
:
"Slave Instance"
,
<string>%(sla)s</string>
},
instance_dict
)
</dictionary>
<string>_instance_guid</string>
<string>%(instance_guid)s</string>
<string>_need_modification</string>
<int>1</int>
<string>_parameter_dict</string>
<dictionary id='i6'>
<string>full_ip_list</string>
<list id='i7'/>
<string>instance_title</string>
<string>%(instance_title)s</string>
<string>ip_list</string>
<list id='i8'>
<tuple>
<string/>
<string>ip_address_1</string>
</tuple>
</list>
<string>paramé</string>
<string>%(param)s</string>
<string>root_instance_short_title</string>
<string/>
<string>root_instance_title</string>
<string>%(root_instance_title)s</string>
<string>slap_computer_id</string>
<string>%(compute_node_id)s</string>
<string>slap_computer_partition_id</string>
<string>partition1</string>
<string>slap_software_release_url</string>
<string>%(software_release_url)s</string>
<string>slap_software_type</string>
<string>%(software_type)s</string>
<string>slave_instance_list</string>
<list id='i9'/>
<string>timestamp</string>
<string>%(timestamp)s</string>
</dictionary>
<string>_partition_id</string>
<string>partition1</string>
<string>_request_dict</string>
<none/>
<string>_requested_state</string>
<string>started</string>
<string>_software_release_document</string>
<object id='i10' module='slapos.slap.slap' class='SoftwareRelease'>
<tuple>
<string>%(software_release_url)s</string>
<string>%(compute_node_id)s</string>
</tuple>
<dictionary id='i11'>
<string>_computer_guid</string>
<string>%(compute_node_id)s</string>
<string>_software_instance_list</string>
<list id='i12'/>
<string>_software_release</string>
<string>%(software_release_url)s</string>
</dictionary>
</object>
<string>_synced</string>
<bool>1</bool>
</dictionary>
</object>
</marshal>
"""
%
dict
(
compute_node_id
=
self
.
compute_node_id
,
param
=
self
.
start_requested_software_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
sla
=
self
.
start_requested_software_instance
.
getSlaXmlAsDict
()[
'paramé'
],
software_release_url
=
self
.
start_requested_software_instance
.
getUrlString
(),
timestamp
=
int
(
self
.
start_requested_software_instance
.
getModificationDate
()),
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
instance_title
=
self
.
start_requested_software_instance
.
getTitle
(),
root_instance_title
=
self
.
start_requested_software_instance
.
getSpecialiseValue
().
getTitle
(),
software_type
=
self
.
start_requested_software_instance
.
getSourceReference
()
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
assertInstanceUpdateConnectionSimulator
(
self
,
args
,
kwargs
):
def
assertInstanceUpdateConnectionSimulator
(
self
,
args
,
kwargs
):
stored
=
eval
(
open
(
self
.
instance_update_connection_simulator
).
read
())
#pylint: disable=eval-used
stored
=
eval
(
open
(
self
.
instance_update_connection_simulator
).
read
())
#pylint: disable=eval-used
...
@@ -1090,39 +722,52 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
...
@@ -1090,39 +722,52 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJIOAPIMixin):
[{
'recargs'
:
args
,
'reckwargs'
:
kwargs
,
[{
'recargs'
:
args
,
'reckwargs'
:
kwargs
,
'recmethod'
:
'updateConnection'
}])
'recmethod'
:
'updateConnection'
}])
def
deactivated_test_setConnectionXml_withSlave
(
self
):
def
test_13_setConnectionXml_withSlave
(
self
):
# XXX CLN No idea how to deal with ascii
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
self
.
callUpdateRevisionAndTic
()
portal_type
=
'Compute Partition'
).
getReference
()
connection_parameters_dict
=
{
slave_reference
=
self
.
start_requested_slave_instance
.
getReference
()
"p1e"
:
"v1e"
,
connection_xml
=
"""<marshal>
"p2e"
:
"v2e"
,
<dictionary id="i2">
}
<string>p1é</string>
<string>v1é</string>
<string>p2é</string>
<string>v2é</string>
</dictionary>
</marshal>"""
stored_xml
=
"""<?xml version='1.0' encoding='utf-8'?>
stored_xml
=
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id="p
1é">v1é
</parameter>
<parameter id="p
2e">v2e
</parameter>
<parameter id="p
2é">v2é
</parameter>
<parameter id="p
1e">v1e
</parameter>
</instance>
</instance>
"""
"""
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
self
.
called_update_connection_kw
=
""
def
calledupdateConnection
(
*
args
,
**
kw
):
self
.
called_update_connection_kw
=
kw
start_date
=
DateTime
().
HTML4
()
self
.
instance_update_connection_simulator
=
tempfile
.
mkstemp
()[
1
]
try
:
try
:
self
.
start_requested_slave_instance
.
updateConnection
=
Simulator
(
updateConnection
=
self
.
start_requested_slave_instance
.
__class__
.
updateConnection
self
.
instance_update_connection_simulator
,
'updateConnection'
)
self
.
start_requested_slave_instance
.
__class__
.
updateConnection
=
calledupdateConnection
response
=
self
.
portal_slap
.
setComputerPartitionConnectionXml
(
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
self
.
compute_node_id
,
partition_id
,
connection_xml
,
slave_reference
)
response_dict
=
self
.
putToApi
({
self
.
assertEqual
(
'None'
,
response
)
"reference"
:
self
.
start_requested_slave_instance
.
getReference
(),
self
.
assertInstanceUpdateConnectionSimulator
((),
"portal_type"
:
"Software Instance"
,
{
'connection_xml'
:
stored_xml
})
"connection_parameters"
:
connection_parameters_dict
,
})
self
.
maxDiff
=
None
self
.
tic
()
response
=
self
.
portal
.
REQUEST
.
RESPONSE
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
self
.
assertTrue
(
response_dict
.
pop
(
"$schema"
).
endswith
(
"SoftwareInstance_updateFromJSON/getOutputJSONSchema"
))
self
.
assertTrue
(
DateTime
(
response_dict
.
pop
(
"date"
))
>=
DateTime
(
start_date
))
self
.
assertEqual
(
self
.
called_update_connection_kw
,
{
"connection_xml"
:
stored_xml
})
self
.
assertEqual
(
response_dict
,
{
"reference"
:
self
.
start_requested_slave_instance
.
getReference
(),
"portal_type"
:
"Software Instance"
,
"success"
:
"Done"
})
finally
:
finally
:
if
os
.
path
.
exists
(
self
.
instance_update_connection_simulator
):
self
.
start_requested_slave_instance
.
__class__
.
updateConnection
=
updateConnection
os
.
unlink
(
self
.
instance_update_connection_simulator
)
def
deactivated_test_setConnectionXml
(
self
):
def
deactivated_test_setConnectionXml
(
self
):
self
.
_makeComplexComputeNode
()
self
.
_makeComplexComputeNode
()
...
...
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