Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SlapOS Develop
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
Eric Zheng
SlapOS Develop
Commits
7f6ff2d4
Commit
7f6ff2d4
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
70 additions
and
0 deletions
+70
-0
software/cloudooo/test/setup.py
software/cloudooo/test/setup.py
+1
-0
software/cloudooo/test/test.py
software/cloudooo/test/test.py
+69
-0
No files found.
software/cloudooo/test/setup.py
View file @
7f6ff2d4
...
...
@@ -44,6 +44,7 @@ setup(name=name,
'slapos.core'
,
'slapos.cookbook'
,
'slapos.libnetworkcache'
,
'requests'
,
'six'
,
'PyPDF2'
,
],
...
...
software/cloudooo/test/test.py
View file @
7f6ff2d4
...
...
@@ -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,68 @@ 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'
:
# ideally there should be 25% of requests on each backend, because we use
# round robin scheduling, but it can happen that some backend take longer
# to start, so we are tolerant here and just check that each backend
# process at least 15% of requests.
self
.
assertGreater
(
total_hrsp_2xx
[
backend
],
15
)
# 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