Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
107
Merge Requests
107
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
c6967b1c
Commit
c6967b1c
authored
Apr 28, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/cloudooo: test cluster capabilities
parent
8dc22418
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
16 deletions
+77
-16
software/cloudooo/test/test.py
software/cloudooo/test/test.py
+77
-16
No files found.
software/cloudooo/test/test.py
View file @
c6967b1c
...
...
@@ -26,23 +26,42 @@
#
##############################################################################
import
csv
import
multiprocessing
import
os
import
json
import
six.moves.xmlrpc_client
as
xmlrpclib
import
six.moves.urllib.parse
as
urllib_parse
import
ssl
import
base64
import
io
import
requests
import
PyPDF2
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
setUpModule
,
CloudOooTestCase
=
makeModuleSetUpAndTestCaseClass
(
setUpModule
,
_
CloudOooTestCase
=
makeModuleSetUpAndTestCaseClass
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
# Cloudooo needs a lot of time before being available.
CloudOooTestCase
.
instance_max_retry
=
30
class
CloudOooTestCase
(
_CloudOooTestCase
):
# Cloudooo needs a lot of time before being available.
instance_max_retry
=
30
def
setUp
(
self
):
self
.
url
=
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
"_"
])[
'cloudooo'
]
# XXX ignore certificate errors
ssl_context
=
ssl
.
create_default_context
()
ssl_context
.
check_hostname
=
False
ssl_context
.
verify_mode
=
ssl
.
CERT_NONE
self
.
server
=
xmlrpclib
.
ServerProxy
(
self
.
url
,
context
=
ssl_context
,
allow_none
=
True
,
)
def
normalizeFontName
(
font_name
):
...
...
@@ -88,19 +107,6 @@ class HTMLtoPDFConversionFontTestMixin:
"""Convert the HTML source to pdf bytes.
"""
def
setUp
(
self
):
self
.
url
=
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
"_"
])[
'cloudooo'
]
# XXX ignore certificate errors
ssl_context
=
ssl
.
create_default_context
()
ssl_context
.
check_hostname
=
False
ssl_context
.
verify_mode
=
ssl
.
CERT_NONE
self
.
server
=
xmlrpclib
.
ServerProxy
(
self
.
url
,
context
=
ssl_context
,
allow_none
=
True
,
)
def
test
(
self
):
actual_font_mapping_mapping
=
{}
for
font
in
self
.
expected_font_mapping
:
...
...
@@ -237,3 +243,58 @@ class TestLibreoffice(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
'html'
,
'pdf'
,
).
encode
())
class
TestLibreOfficeCluster
(
CloudOooTestCase
):
__partition_reference__
=
'lc'
@
classmethod
def
getInstanceParameterDict
(
cls
):
return
{
'backend-count'
:
4
}
def
test_multiple_conversions
(
self
):
# make this function global so that it can be picked and use by multiprocessing
global
_convert_html_to_text
def
_convert_html_to_text
(
src_html
):
return
base64
.
decodestring
(
self
.
server
.
convertFile
(
base64
.
encodestring
(
src_html
.
encode
()).
decode
(),
'html'
,
'txt'
,
).
encode
())
pool
=
multiprocessing
.
Pool
(
5
)
# TODO py3: use with pool
converted
=
pool
.
map
(
_convert_html_to_text
,
[
'<html><body>hello</body></html>'
]
*
100
)
pool
.
terminate
()
pool
.
join
()
# XXX for some reason the converted text has some non-breakable space
self
.
assertEqual
(
converted
,
[
'
\
xef
\
xbb
\
xbf
hello
\
n
'
]
*
100
)
# haproxy stats are exposed
res
=
requests
.
get
(
urllib_parse
.
urljoin
(
self
.
url
,
'/haproxy;csv'
),
verify
=
False
,
stream
=
True
,
)
reader
=
csv
.
DictReader
(
res
.
raw
)
line_list
=
list
(
reader
)
# requests have been balanced
total_hrsp_2xx
=
{
line
[
'svname'
]:
int
(
line
[
'hrsp_2xx'
])
for
line
in
line_list
}
self
.
assertEqual
(
total_hrsp_2xx
[
'FRONTEND'
],
100
)
self
.
assertEqual
(
total_hrsp_2xx
[
'BACKEND'
],
100
)
for
backend
in
'cloudooo_1'
,
'cloudooo_2'
,
'cloudooo_3'
,
'cloudooo_4'
:
self
.
assertIn
(
total_hrsp_2xx
[
backend
],
(
24
,
25
,
26
))
# no errors
total_eresp
=
{
line
[
'svname'
]:
int
(
line
[
'eresp'
]
or
0
)
for
line
in
line_list
}
self
.
assertEqual
(
total_eresp
,
{
'FRONTEND'
:
0
,
'cloudooo_1'
:
0
,
'cloudooo_2'
:
0
,
'cloudooo_3'
:
0
,
'cloudooo_4'
:
0
,
'BACKEND'
:
0
,
})
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