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
Titouan Soulard
slapos.core
Commits
d399a281
Commit
d399a281
authored
Mar 16, 2023
by
Cédric Le Ninivin
Committed by
Titouan Soulard
Mar 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio_api_style: Improve Software Installation search and add tests
parent
8f8d0fdf
Changes
3
Hide 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 @
d399a281
...
@@ -88,11 +88,6 @@
...
@@ -88,11 +88,6 @@
"const": "Software Installation",\n
"const": "Software Installation",\n
"type": "string"\n
"type": "string"\n
},\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
"api_revision": {\n
"title": "API Revision",\n
"title": "API Revision",\n
"type": "string",\n
"type": "string",\n
...
...
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchSoftwareInstallation.py
View file @
d399a281
import
urllib
# Hardcoded
# Hardcoded
limit
=
1000
limit
=
1000
web_section
=
context
.
getWebSectionValue
()
web_section
=
context
.
getWebSectionValue
()
...
@@ -7,13 +9,12 @@ search_kw = {
...
@@ -7,13 +9,12 @@ search_kw = {
"portal_type"
:
"Software Installation"
,
"portal_type"
:
"Software Installation"
,
"validation_state"
:
"validated"
,
"validation_state"
:
"validated"
,
"jio_api_revision.web_section"
:
web_section
,
"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"
),
"sort_on"
:
(
"jio_api_revision.revision"
,
"ASC"
),
"limit"
:
limit
,
"limit"
:
limit
,
}
}
if
"software_release_uri"
in
data_dict
:
if
"software_release_uri"
in
data_dict
:
import
urllib
search_kw
[
"url_string"
]
=
urllib
.
unquote
(
data_dict
[
"software_release_uri"
])
search_kw
[
"url_string"
]
=
urllib
.
unquote
(
data_dict
[
"software_release_uri"
])
if
"compute_node_id"
in
data_dict
:
if
"compute_node_id"
in
data_dict
:
search_kw
[
"strict_aggregate_reference"
]
=
data_dict
[
"compute_node_id"
]
search_kw
[
"strict_aggregate_reference"
]
=
data_dict
[
"compute_node_id"
]
...
@@ -22,7 +23,7 @@ if "from_api_revision" in data_dict:
...
@@ -22,7 +23,7 @@ if "from_api_revision" in data_dict:
result_list
=
[{
result_list
=
[{
"get_parameters"
:
{
"get_parameters"
:
{
"software_release_uri"
:
x
.
url_string
,
"software_release_uri"
:
urllib
.
quote
(
x
.
url_string
)
,
"compute_node_id"
:
x
.
aggregate_reference
,
"compute_node_id"
:
x
.
aggregate_reference
,
"portal_type"
:
x
.
portal_type
,
"portal_type"
:
x
.
portal_type
,
},
},
...
@@ -31,7 +32,6 @@ result_list = [{
...
@@ -31,7 +32,6 @@ result_list = [{
"state"
:
"available"
if
x
.
slap_state
==
"start_requested"
else
"destroyed"
,
"state"
:
"available"
if
x
.
slap_state
==
"start_requested"
else
"destroyed"
,
"api_revision"
:
x
.
revision
,
"api_revision"
:
x
.
revision
,
"portal_type"
:
x
.
portal_type
,
"portal_type"
:
x
.
portal_type
,
"processing_timestamp"
:
int
(
x
.
slap_date
),
}
for
x
in
context
.
getPortalObject
().
portal_catalog
(
**
search_kw
)]
}
for
x
in
context
.
getPortalObject
().
portal_catalog
(
**
search_kw
)]
if
result_list
:
if
result_list
:
...
...
master/bt5/slapos_jio_api_style/TestTemplateItem/portal_components/test.erp5.testSlapOSJIOAPI.py
View file @
d399a281
...
@@ -188,7 +188,7 @@ class TestSlapOSJIOAPIMixin(SlapOSTestCaseMixin):
...
@@ -188,7 +188,7 @@ class TestSlapOSJIOAPIMixin(SlapOSTestCaseMixin):
self
.
_cleaupREQUEST
()
self
.
_cleaupREQUEST
()
class
TestSlapOSSlapToolComputeNodeAccess
(
TestSlapOSJIOAPIMixin
):
class
TestSlapOSSlapToolComputeNodeAccess
(
TestSlapOSJIOAPIMixin
):
def
test_01_getFullComputerInformation
(
self
):
def
test_01_getFullComputerInformation
InstanceList
(
self
):
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
_makeComplexComputeNode
(
with_slave
=
True
)
self
.
callUpdateRevisionAndTic
()
self
.
callUpdateRevisionAndTic
()
...
@@ -275,6 +275,72 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJIOAPIMixin):
...
@@ -275,6 +275,72 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSJIOAPIMixin):
"portal_type"
:
instance
.
getPortalType
(),
"portal_type"
:
instance
.
getPortalType
(),
},
instance_dict
)
},
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
):
def
test_02_computerBang
(
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