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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos
Commits
d0bb606d
Commit
d0bb606d
authored
Aug 30, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/slapos-master/test: port the tests to python3
parent
b833c90e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
151 additions
and
140 deletions
+151
-140
software/slapos-master/test/test/test_balancer.py
software/slapos-master/test/test/test_balancer.py
+74
-65
software/slapos-master/test/test/test_erp5.py
software/slapos-master/test/test/test_erp5.py
+65
-64
software/slapos-master/test/test/test_mariadb.py
software/slapos-master/test/test/test_mariadb.py
+11
-10
software/slapos-master/test/test/test_wcfs.py
software/slapos-master/test/test/test_wcfs.py
+1
-1
No files found.
software/slapos-master/test/test/test_balancer.py
View file @
d0bb606d
This diff is collapsed.
Click to expand it.
software/slapos-master/test/test/test_erp5.py
View file @
d0bb606d
This diff is collapsed.
Click to expand it.
software/slapos-master/test/test/test_mariadb.py
View file @
d0bb606d
##############################################################################
# coding: utf-8
#
# Copyright (c) 2018 Nexedi SA and Contributors. All Rights Reserved.
#
...
...
@@ -29,7 +28,7 @@
import
os
import
json
import
glob
import
urlparse
import
url
lib.
parse
import
socket
import
sys
import
time
...
...
@@ -38,7 +37,7 @@ import datetime
import
subprocess
import
gzip
from
backports
import
lzma
import
lzma
import
MySQLdb
from
slapos.testing.utils
import
CrontabMixin
...
...
@@ -80,7 +79,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
def
getDatabaseConnection
(
self
):
connection_parameter_dict
=
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])
db_url
=
urlparse
.
urlparse
(
connection_parameter_dict
[
'database-list'
][
0
])
db_url
=
url
lib
.
parse
.
urlparse
(
connection_parameter_dict
[
'database-list'
][
0
])
self
.
assertEqual
(
'mysql'
,
db_url
.
scheme
)
self
.
assertTrue
(
db_url
.
path
.
startswith
(
'/'
))
...
...
@@ -91,6 +90,8 @@ class MariaDBTestCase(ERP5InstanceTestCase):
host
=
db_url
.
hostname
,
port
=
db_url
.
port
,
db
=
database_name
,
use_unicode
=
True
,
charset
=
'utf8mb4'
)
...
...
@@ -106,7 +107,7 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin):
'mariadb-full'
,
'20500101000000.sql.gz'
,
),
'r'
)
as
dump
:
'r
t
'
)
as
dump
:
self
.
assertIn
(
'CREATE TABLE'
,
dump
.
read
())
def
test_logrotate_and_slow_query_digest
(
self
):
...
...
@@ -148,7 +149,7 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin):
'slowquery_digest'
,
'slowquery_digest.txt-2050-01-01.xz'
,
)
with
lzma
.
open
(
slow_query_report
,
'r'
)
as
f
:
with
lzma
.
open
(
slow_query_report
,
'r
t
'
)
as
f
:
# this is the hash for our "select sleep(n)" slow query
self
.
assertIn
(
"ID 0xF9A57DD5A41825CA"
,
f
.
read
())
...
...
@@ -170,7 +171,7 @@ class TestCrontabs(MariaDBTestCase, CrontabMixin):
subprocess
.
check_output
(
'faketime 2050-01-01 %s'
%
check_slow_query_promise_plugin
[
'command'
],
shell
=
True
)
self
.
assertEqual
(
error_context
.
exception
.
output
,
"""
\
b
"""
\
Threshold is lower than expected:
Expected total queries : 1.0 and current is: 2
Expected slowest query : 0.1 and current is: 3
...
...
@@ -220,7 +221,7 @@ class TestMroonga(MariaDBTestCase):
"""
SELECT mroonga_normalize("ABCDあぃうぇ㍑")
"""
)
self
.
assertEqual
(((
'abcdあぃうぇリットル'
,),),
self
.
assertEqual
(((
'abcdあぃうぇリットル'
.
encode
()
,),),
cnx
.
store_result
().
fetch_row
(
maxrows
=
2
))
if
0
:
...
...
@@ -233,7 +234,7 @@ class TestMroonga(MariaDBTestCase):
"""
SELECT mroonga_normalize("aBcDあぃウェ㍑", "NormalizerMySQLUnicodeCIExceptKanaCIKanaWithVoicedSoundMark")
"""
)
self
.
assertEqual
(((
'ABCDあぃうぇ㍑'
,),),
self
.
assertEqual
(((
'ABCDあぃうぇ㍑'
.
encode
()
,),),
cnx
.
store_result
().
fetch_row
(
maxrows
=
2
))
def
test_mroonga_full_text_normalizer
(
self
):
...
...
@@ -321,7 +322,7 @@ class TestMroonga(MariaDBTestCase):
cnx
=
self
.
getDatabaseConnection
()
with
contextlib
.
closing
(
cnx
):
cnx
.
query
(
"SELECT mroonga_command('register token_filters/stem')"
)
self
.
assertEqual
(((
'true'
,),),
cnx
.
store_result
().
fetch_row
(
maxrows
=
2
))
self
.
assertEqual
(((
b
'true'
,),),
cnx
.
store_result
().
fetch_row
(
maxrows
=
2
))
cnx
.
query
(
"""
CREATE TABLE memos (
...
...
software/slapos-master/test/test/test_wcfs.py
View file @
d0bb606d
...
...
@@ -75,5 +75,5 @@ def lookupMount(zurl):
# readfile returns content of file @path.
def
readfile
(
path
):
with
open
(
path
,
'r'
)
as
f
:
with
open
(
path
)
as
f
:
return
f
.
read
()
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