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
105
Merge Requests
105
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
123ce0ba
Commit
123ce0ba
authored
Apr 28, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/cloudooo: test cluster capabilities
parent
9fb24fe2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
software/cloudooo/test/setup.py
software/cloudooo/test/setup.py
+1
-0
software/cloudooo/test/test.py
software/cloudooo/test/test.py
+65
-0
No files found.
software/cloudooo/test/setup.py
View file @
123ce0ba
...
...
@@ -44,6 +44,7 @@ setup(name=name,
'slapos.core'
,
'slapos.cookbook'
,
'slapos.libnetworkcache'
,
'requests'
'six'
,
'PyPDF2'
,
],
...
...
software/cloudooo/test/test.py
View file @
123ce0ba
...
...
@@ -27,13 +27,17 @@
##############################################################################
import
codecs
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
...
...
@@ -256,3 +260,64 @@ class TestLibreOfficeTextConversion(CloudOooTestCase):
).
encode
()),
codecs
.
BOM_UTF8
+
b'h
\
xc3
\
xa9
h
\
xc3
\
xa9
\
n
'
,
)
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 used 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
()
self
.
assertEqual
(
converted
,
[
codecs
.
BOM_UTF8
+
b'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