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
37935769
Commit
37935769
authored
Mar 16, 2023
by
Cédric Le Ninivin
Committed by
Cédric Le Ninivin
Mar 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio_api_style: Improve Software Installation search and add tests
parent
18368070
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
10 deletions
+71
-10
master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchSoftwareInstallationFromJSON.xml
...bles/jIOWebSection_searchSoftwareInstallationFromJSON.xml
+0
-5
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchSoftwareInstallation.py
...lapos_jio_api/jIOWebSection_searchSoftwareInstallation.py
+4
-4
master/bt5/slapos_jio_api_style/TestTemplateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
...plateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
+67
-1
No files found.
master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchSoftwareInstallationFromJSON.xml
View file @
37935769
...
...
@@ -88,11 +88,6 @@
"const": "Software Installation",\n
"type": "string"\n
},\n
"processing_timestamp": {\n
"title": "Processing Timestamp",\n
"type": "number",\n
"description": "Timestamp set by the master node to mark when it was last processed in the master node. If it has been processed on master, it needs reprocessing on the compute node."\n
},\n
"api_revision": {\n
"title": "API Revision",\n
"type": "string",\n
...
...
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchSoftwareInstallation.py
View file @
37935769
import
urllib
# Hardcoded
limit
=
1000
web_section
=
context
.
getWebSectionValue
()
...
...
@@ -7,13 +9,12 @@ search_kw = {
"portal_type"
:
"Software Installation"
,
"validation_state"
:
"validated"
,
"jio_api_revision.web_section"
:
web_section
,
"select_list"
:
(
"aggregate_reference"
,
"url_string"
,
"slap_state"
,
"portal_type"
,
"
slap_date"
,
"
jio_api_revision.revision"
),
"select_list"
:
(
"aggregate_reference"
,
"url_string"
,
"slap_state"
,
"portal_type"
,
"jio_api_revision.revision"
),
"sort_on"
:
(
"jio_api_revision.revision"
,
"ASC"
),
"limit"
:
limit
,
}
if
"software_release_uri"
in
data_dict
:
import
urllib
search_kw
[
"url_string"
]
=
urllib
.
unquote
(
data_dict
[
"software_release_uri"
])
if
"compute_node_id"
in
data_dict
:
search_kw
[
"strict_aggregate_reference"
]
=
data_dict
[
"compute_node_id"
]
...
...
@@ -22,7 +23,7 @@ if "from_api_revision" in data_dict:
result_list
=
[{
"get_parameters"
:
{
"software_release_uri"
:
x
.
url_string
,
"software_release_uri"
:
urllib
.
quote
(
x
.
url_string
)
,
"compute_node_id"
:
x
.
aggregate_reference
,
"portal_type"
:
x
.
portal_type
,
},
...
...
@@ -31,7 +32,6 @@ result_list = [{
"state"
:
"available"
if
x
.
slap_state
==
"start_requested"
else
"destroyed"
,
"api_revision"
:
x
.
revision
,
"portal_type"
:
x
.
portal_type
,
"processing_timestamp"
:
int
(
x
.
slap_date
),
}
for
x
in
context
.
getPortalObject
().
portal_catalog
(
**
search_kw
)]
if
result_list
:
...
...
master/bt5/slapos_jio_api_style/TestTemplateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
View file @
37935769
...
...
@@ -188,7 +188,7 @@ class TestSlapOSJIOAPIMixin(SlapOSTestCaseMixin):
self
.
_cleaupREQUEST
()
class
TestSlapOSSlapToolComputeNodeAccess
(
TestSlapOSJIOAPIMixin
):
def
test_01_getFullComputerInformation
(
self
):
def
test_01_getFullComputerInformation
InstanceList
(
self
):
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
callUpdateRevisionAndTic
()
...
...
@@ -275,6 +275,72 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJIOAPIMixin):
"portal_type"
:
instance
.
getPortalType
(),
},
instance_dict
)
def
test_01_bis_getFullComputerInformationSoftwareList
(
self
):
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
callUpdateRevisionAndTic
()
self
.
login
(
self
.
compute_node_user_id
)
software_list_response
=
self
.
allDocsToApi
({
"compute_node_id"
:
self
.
compute_node_id
,
"portal_type"
:
"Software Installation"
,
})
response
=
self
.
portal
.
REQUEST
.
RESPONSE
if
200
!=
response
.
getStatus
():
raise
ValueError
(
"Unexpected Result %s"
%
software_list_response
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
self
.
assertTrue
(
software_list_response
[
"$schema"
].
endswith
(
"jIOWebSection_searchSoftwareInstallationFromJSON/getOutputJSONSchema"
))
result_list
=
software_list_response
[
"result_list"
]
self
.
assertEqual
(
2
,
len
(
result_list
))
software_list
=
[
self
.
start_requested_software_installation
,
self
.
destroy_requested_software_installation
]
# This is the expected instance list, it is sorted by api_revision
software_list
.
sort
(
key
=
lambda
x
:
x
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
()))
# Check result_list match instance_list=
expected_software_list
=
[]
for
software
in
software_list
:
expected_software_list
.
append
({
"api_revision"
:
software
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
()),
"get_parameters"
:
{
"portal_type"
:
"Software Installation"
,
"software_release_uri"
:
urllib
.
quote
(
software
.
getUrlString
()),
"compute_node_id"
:
self
.
compute_node_id
},
"portal_type"
:
"Software Installation"
,
"software_release_uri"
:
software
.
getUrlString
(),
"state"
:
"available"
if
software
.
getSlapState
()
==
"start_requested"
else
"destroyed"
,
"compute_node_id"
:
self
.
compute_node_id
,
})
self
.
assertEqual
(
expected_software_list
,
software_list_response
[
"result_list"
])
for
i
in
range
(
len
(
expected_software_list
)):
software_resut_dict
=
expected_software_list
[
i
]
software
=
software_list
[
i
]
# Get instance as "user"
self
.
login
(
self
.
compute_node_user_id
)
software_dict
=
self
.
getToApi
(
software_resut_dict
[
"get_parameters"
])
response
=
self
.
portal
.
REQUEST
.
RESPONSE
if
200
!=
response
.
getStatus
():
raise
ValueError
(
"Unexpected Result %s"
%
software_dict
)
self
.
assertEqual
(
'application/json'
,
response
.
headers
.
get
(
'content-type'
))
# Check Data is correct
self
.
maxDiff
=
None
status_dict
=
software
.
getAccessStatus
()
self
.
assertEqual
({
"$schema"
:
software
.
getJSONSchemaUrl
(),
"api_revision"
:
software
.
getJIOAPIRevision
(
self
.
web_site
.
api
.
getRelativeUrl
()),
"portal_type"
:
"Software Installation"
,
"software_release_uri"
:
software
.
getUrlString
(),
"state"
:
"available"
if
software
.
getSlapState
()
==
"start_requested"
else
"destroyed"
,
"compute_node_id"
:
self
.
compute_node_id
,
"reported_state"
:
status_dict
.
get
(
"state"
),
"status_message"
:
status_dict
.
get
(
"text"
),
},
software_dict
)
def
test_02_computerBang
(
self
):
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