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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
281f5093
Commit
281f5093
authored
Dec 31, 2024
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_json_rpc_api: one more test
parent
0bf35983
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
65 deletions
+66
-65
master/bt5/slapos_json_rpc_api/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py
...rtal_skins/slapos_jio_api/jIOWebSection_searchInstance.py
+9
-7
master/bt5/slapos_json_rpc_api/TestTemplateItem/portal_components/test.erp5.testSlapOSJsonRpc.py
...lateItem/portal_components/test.erp5.testSlapOSJsonRpc.py
+57
-58
No files found.
master/bt5/slapos_json_rpc_api/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py
View file @
281f5093
...
...
@@ -23,9 +23,11 @@ if portal_type == "Software Instance":
search_kw
=
{
"portal_type"
:
"Software Instance"
,
"validation_state"
:
"validated"
,
"jio_api_revision.web_section"
:
web_section
,
"select_list"
:
(
"title"
,
"reference"
,
"portal_type"
,
"slap_state"
,
"aggregate_reference"
,
"url_string"
,
"jio_api_revision.revision"
),
"sort_on"
:
(
"jio_api_revision.revision"
,
"ASC"
),
#"jio_api_revision.web_section": web_section,
"select_list"
:
(
"title"
,
"reference"
,
"portal_type"
,
"slap_state"
,
"aggregate_reference"
,
"url_string"
),
#, "jio_api_revision.revision"),
#"sort_on": ("jio_api_revision.revision", "ASC"),
# XXX Sorting is slow
"sort_on"
:
[(
"reference"
,
"ASC"
)],
"limit"
:
limit
}
...
...
@@ -48,7 +50,7 @@ if portal_type == "Software Instance":
"state"
:
slap_state_dict
.
get
(
x
.
slap_state
,
""
),
"compute_partition_id"
:
x
.
aggregate_reference
,
"software_release_uri"
:
x
.
url_string
,
"api_revision"
:
x
.
revision
,
#
"api_revision": x.revision,
"get_parameters"
:
{
"portal_type"
:
x
.
portal_type
,
"reference"
:
x
.
reference
,
...
...
@@ -90,7 +92,7 @@ elif portal_type == "Shared Instance":
"portal_type"
:
"Software Instance"
,
"state"
:
slap_state_dict
.
get
(
x
.
slap_state
,
""
),
"compute_partition_id"
:
x
.
aggregate_reference
,
"api_revision"
:
x
.
revision
,
#
"api_revision": x.revision,
"get_parameters"
:
{
"portal_type"
:
"Software Instance"
,
"reference"
:
x
.
reference
,
...
...
@@ -105,8 +107,8 @@ else:
error_message
=
"You Reached code that was not recheable"
,
)
if
result_list
:
data_dict
[
"from_api_revision"
]
=
result_list
[
-
1
][
"api_revision"
]
#
if result_list:
#
data_dict["from_api_revision"] = result_list[-1]["api_revision"]
return
{
# "$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema",
...
...
master/bt5/slapos_json_rpc_api/TestTemplateItem/portal_components/test.erp5.testSlapOSJsonRpc.py
View file @
281f5093
...
...
@@ -170,37 +170,17 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin):
instance_1
=
self
.
compute_node
.
partition1
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
instance_2
=
self
.
compute_node
.
partition2
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
instance_3
=
self
.
compute_node
.
partition3
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
response
=
self
.
callJsonRpcWebService
(
'slapos.allDocs.slapos_jio_api_search_instance'
,
{
"compute_node_id"
:
self
.
compute_node_id
,
"portal_type"
:
"Software Instance"
,
},
self
.
compute_node_user_id
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
self
.
assertEqual
(
byteify
(
json
.
loads
(
response
.
getBody
())),
{
'current_page_full'
:
False
,
'next_page_request'
:
{
'compute_node_id'
:
self
.
compute_node
.
getReference
(),
'portal_type'
:
'Software Instance'
},
'result_list'
:
[]
})
self
.
assertEqual
(
response
.
getStatus
(),
200
)
instance_list_response
=
json
.
loads
(
response
.
getBody
())
# self.assertTrue(instance_list_response["$schema"].endswith("jIOWebSection_searchInstanceFromJSON/getOutputJSONSchema"))
result_list
=
instance_list_response
[
"result_list"
]
self
.
assertEqual
(
3
,
len
(
result_list
))
instance_4
=
self
.
compute_node
.
partition4
.
getAggregateRelatedValue
(
portal_type
=
'Software Instance'
)
# This is the expected instance list, it is sorted by api_revision
instance_list
=
[
instance_1
,
instance_2
,
instance_3
]
instance_list
.
sort
(
key
=
lambda
x
:
x
.
getJIOAPIRevision
(
self
.
connector
.
getRelativeUrl
()))
instance_list
=
[
instance_1
,
instance_2
,
instance_3
,
instance_4
]
#
instance_list.sort(key=lambda x: x.getJIOAPIRevision(self.connector.getRelativeUrl()))
# Check result_list match instance_list=
expected_instance_list
=
[]
for
instance
in
instance_list
:
expected_instance_list
.
append
({
"api_revision"
:
instance
.
getJIOAPIRevision
(
self
.
connector
.
getRelativeUrl
()),
#
"api_revision": instance.getJIOAPIRevision(self.connector.getRelativeUrl()),
"compute_partition_id"
:
instance
.
getAggregateReference
(),
"get_parameters"
:
{
"portal_type"
:
"Software Instance"
,
...
...
@@ -212,48 +192,67 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJsonRpcMixin):
"state"
:
self
.
getAPIStateFromSlapState
(
instance
.
getSlapState
()),
"title"
:
instance
.
getTitle
(),
})
self
.
assertEqual
(
expected_instance_list
,
instance_list_response
[
"result_list"
])
response
=
self
.
callJsonRpcWebService
(
'slapos.allDocs.slapos_jio_api_search_instance'
,
{
"compute_node_id"
:
self
.
compute_node_id
,
"portal_type"
:
"Software Instance"
,
},
self
.
compute_node_user_id
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
instance_list_response
=
byteify
(
json
.
loads
(
response
.
getBody
()))
# self.assertTrue(instance_list_response["$schema"].endswith("jIOWebSection_searchInstanceFromJSON/getOutputJSONSchema"))
self
.
assertEqual
(
instance_list_response
,
{
'current_page_full'
:
False
,
'next_page_request'
:
{
'compute_node_id'
:
self
.
compute_node
.
getReference
(),
'portal_type'
:
'Software Instance'
},
'result_list'
:
expected_instance_list
})
self
.
assertEqual
(
response
.
getStatus
(),
200
)
for
i
in
range
(
len
(
expected_instance_list
)):
instance_resut_dict
=
expected_instance_list
[
i
]
instance
=
instance_list
[
i
]
# Get instance as "user"
self
.
login
(
self
.
compute_node_user_id
)
response
=
self
.
callJsonRpcWebService
(
"slapos.get.slapos_jio_api_get_software_instance"
,
instance_resut_dict
[
"get_parameters"
])
instance_dict
=
json
.
loads
(
response
.
getBody
())
if
200
!=
response
.
getStatus
():
raise
ValueError
(
"Unexpected Result %s"
%
instance_dict
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
# Check Data is correct
partition
=
instance
.
getAggregateValue
(
portal_type
=
"Compute Partition"
)
self
.
assertEqual
({
"$schema"
:
instance
.
getJSONSchemaUrl
(),
"title"
:
instance
.
getTitle
(),
"reference"
:
instance
.
getReference
(),
"software_release_uri"
:
instance
.
getUrlString
(),
"software_type"
:
instance
.
getSourceReference
(),
"state"
:
self
.
getAPIStateFromSlapState
(
instance
.
getSlapState
()),
"connection_parameters"
:
instance
.
getConnectionXmlAsDict
(),
"parameters"
:
instance
.
getInstanceXmlAsDict
(),
"shared"
:
False
,
"root_instance_title"
:
instance
.
getSpecialiseValue
().
getTitle
(),
"ip_list"
:
[
response
=
self
.
callJsonRpcWebService
(
'slapos.get.slapos_jio_api_get_software_instance'
,
instance_resut_dict
[
"get_parameters"
],
self
.
compute_node_user_id
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
self
.
assertEqual
(
byteify
(
json
.
loads
(
response
.
getBody
())),
{
#"$schema": instance.getJSONSchemaUrl(),
"title"
:
instance
.
getTitle
(),
"reference"
:
instance
.
getReference
(),
"software_release_uri"
:
instance
.
getUrlString
(),
"software_type"
:
instance
.
getSourceReference
(),
"state"
:
self
.
getAPIStateFromSlapState
(
instance
.
getSlapState
()),
"connection_parameters"
:
instance
.
getConnectionXmlAsDict
(),
"parameters"
:
instance
.
getInstanceXmlAsDict
(),
"shared"
:
False
,
"root_instance_title"
:
instance
.
getSpecialiseValue
().
getTitle
(),
"ip_list"
:
[
x
.
getNetworkInterface
(
''
),
x
.
getIpAddress
()
]
for
x
in
partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
)
],
"full_ip_list"
:
[],
"sla_parameters"
:
instance
.
getSlaXmlAsDict
(),
"compute_node_id"
:
partition
.
getParentValue
().
getReference
(),
"compute_partition_id"
:
partition
.
getReference
(),
"processing_timestamp"
:
instance
.
getSlapTimestamp
(),
"access_status_message"
:
instance
.
getTextAccessStatus
(),
"api_revision"
:
instance
.
getJIOAPIRevision
(
self
.
connector
.
getRelativeUrl
()),
"portal_type"
:
instance
.
getPortalType
(),
},
instance_dict
)
[
x
.
getNetworkInterface
(
''
),
x
.
getIpAddress
()
]
for
x
in
partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
)
],
"full_ip_list"
:
[],
"sla_parameters"
:
instance
.
getSlaXmlAsDict
(),
"compute_node_id"
:
partition
.
getParentValue
().
getReference
(),
"compute_partition_id"
:
partition
.
getReference
(),
"processing_timestamp"
:
instance
.
getSlapTimestamp
(),
"access_status_message"
:
instance
.
getTextAccessStatus
(),
#"api_revision": instance.getJIOAPIRevision(self.connector.getRelativeUrl()),
"portal_type"
:
instance
.
getPortalType
(),
})
self
.
assertEqual
(
response
.
getStatus
(),
200
)
def
test_ComputeNodeAccess_01_bis_getFullComputerInformationSoftwareList
(
self
):
self
.
_makeComplexComputeNode
(
self
.
project
,
with_slave
=
True
)
...
...
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