Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
5f82bc97
Commit
5f82bc97
authored
Nov 26, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python3 tests
parent
6c3ce690
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
144 deletions
+157
-144
software/caddy-frontend/test/setup.py
software/caddy-frontend/test/setup.py
+1
-0
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+118
-115
software/slapos-master/test/test/__init__.py
software/slapos-master/test/test/__init__.py
+1
-0
software/slapos-master/test/test/test_balancer.py
software/slapos-master/test/test/test_balancer.py
+17
-15
software/slapos-master/test/test/test_erp5.py
software/slapos-master/test/test/test_erp5.py
+16
-12
software/slapos-master/test/test/test_mariadb.py
software/slapos-master/test/test/test_mariadb.py
+3
-2
software/slapos-master/test/test/test_wcfs.py
software/slapos-master/test/test/test_wcfs.py
+1
-0
No files found.
software/caddy-frontend/test/setup.py
View file @
5f82bc97
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
from
__future__
import
absolute_import
from
setuptools
import
setup
,
find_packages
from
setuptools
import
setup
,
find_packages
version
=
'0.0.1.dev0'
version
=
'0.0.1.dev0'
...
...
software/caddy-frontend/test/test.py
View file @
5f82bc97
This diff is collapsed.
Click to expand it.
software/slapos-master/test/test/__init__.py
View file @
5f82bc97
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#
#
##############################################################################
##############################################################################
from
__future__
import
absolute_import
import
json
import
json
import
os
import
os
...
...
software/slapos-master/test/test/test_balancer.py
View file @
5f82bc97
from
__future__
import
absolute_import
import
glob
import
glob
import
hashlib
import
hashlib
import
json
import
json
...
@@ -8,9 +9,9 @@ import shutil
...
@@ -8,9 +9,9 @@ import shutil
import
subprocess
import
subprocess
import
tempfile
import
tempfile
import
time
import
time
import
urllib
import
six.moves.urllib.request
,
six
.
moves
.
urllib
.
parse
,
six
.
moves
.
urllib
.
error
import
url
parse
import
six.moves.urllib.
parse
from
BaseHTTPServer
import
BaseHTTPRequestHandler
from
six.moves.
BaseHTTPServer
import
BaseHTTPRequestHandler
from
typing
import
Dict
from
typing
import
Dict
import
mock
import
mock
...
@@ -28,6 +29,7 @@ from slapos.testing.utils import (CrontabMixin, ManagedHTTPServer,
...
@@ -28,6 +29,7 @@ from slapos.testing.utils import (CrontabMixin, ManagedHTTPServer,
findFreeTCPPort
)
findFreeTCPPort
)
from
.
import
ERP5InstanceTestCase
,
setUpModule
from
.
import
ERP5InstanceTestCase
,
setUpModule
from
six.moves
import
range
setUpModule
# pyflakes
setUpModule
# pyflakes
...
@@ -214,7 +216,7 @@ class TestLog(BalancerTestCase, CrontabMixin):
...
@@ -214,7 +216,7 @@ class TestLog(BalancerTestCase, CrontabMixin):
def
test_access_log_format
(
self
):
def
test_access_log_format
(
self
):
# type: () -> None
# type: () -> None
requests
.
get
(
requests
.
get
(
url
parse
.
urljoin
(
self
.
default_balancer_url
,
'/url_path'
),
six
.
moves
.
urllib
.
parse
.
urljoin
(
self
.
default_balancer_url
,
'/url_path'
),
verify
=
False
,
verify
=
False
,
)
)
time
.
sleep
(.
5
)
# wait a bit more until access is logged
time
.
sleep
(.
5
)
# wait a bit more until access is logged
...
@@ -373,7 +375,7 @@ class TestBalancer(BalancerTestCase):
...
@@ -373,7 +375,7 @@ class TestBalancer(BalancerTestCase):
# if backend provides a "SERVERID" cookie, balancer will overwrite it with the
# if backend provides a "SERVERID" cookie, balancer will overwrite it with the
# backend selected by balancing algorithm
# backend selected by balancing algorithm
self
.
assertIn
(
self
.
assertIn
(
requests
.
get
(
url
parse
.
urljoin
(
self
.
default_balancer_url
,
'/set_cookie'
),
verify
=
False
).
cookies
[
'SERVERID'
],
requests
.
get
(
six
.
moves
.
urllib
.
parse
.
urljoin
(
self
.
default_balancer_url
,
'/set_cookie'
),
verify
=
False
).
cookies
[
'SERVERID'
],
(
'default-0'
,
'default-1'
),
(
'default-0'
,
'default-1'
),
)
)
...
@@ -427,18 +429,18 @@ class TestTestRunnerEntryPoints(BalancerTestCase):
...
@@ -427,18 +429,18 @@ class TestTestRunnerEntryPoints(BalancerTestCase):
)[
'default-test-runner-url-list'
]
)[
'default-test-runner-url-list'
]
url_0
,
url_1
,
url_2
=
test_runner_url_list
url_0
,
url_1
,
url_2
=
test_runner_url_list
self
.
assertEqual
(
self
.
assertEqual
(
url
parse
.
urlparse
(
url_0
).
netloc
,
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
,
url
parse
.
urlparse
(
url_1
).
netloc
)
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_1
).
netloc
)
self
.
assertEqual
(
self
.
assertEqual
(
url
parse
.
urlparse
(
url_0
).
netloc
,
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
,
url
parse
.
urlparse
(
url_2
).
netloc
)
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_2
).
netloc
)
path_0
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_0/something'
.
format
(
path_0
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_0/something'
.
format
(
netloc
=
url
parse
.
urlparse
(
url_0
).
netloc
)
netloc
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
)
path_1
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_1/something'
.
format
(
path_1
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_1/something'
.
format
(
netloc
=
url
parse
.
urlparse
(
url_0
).
netloc
)
netloc
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
)
path_2
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_2/something'
.
format
(
path_2
=
'/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_2/something'
.
format
(
netloc
=
url
parse
.
urlparse
(
url_0
).
netloc
)
netloc
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
)
self
.
assertEqual
(
self
.
assertEqual
(
{
{
...
@@ -516,7 +518,7 @@ class TestHTTP(BalancerTestCase):
...
@@ -516,7 +518,7 @@ class TestHTTP(BalancerTestCase):
session
.
get
(
self
.
default_balancer_url
).
raise_for_status
()
session
.
get
(
self
.
default_balancer_url
).
raise_for_status
()
new_conn
.
assert_not_called
()
new_conn
.
assert_not_called
()
parsed_url
=
url
parse
.
urlparse
(
self
.
default_balancer_url
)
parsed_url
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
self
.
default_balancer_url
)
# check that we have an open file for the ip connection
# check that we have an open file for the ip connection
self
.
assertTrue
([
self
.
assertTrue
([
c
for
c
in
psutil
.
Process
(
os
.
getpid
()).
connections
()
c
for
c
in
psutil
.
Process
(
os
.
getpid
()).
connections
()
...
@@ -588,7 +590,7 @@ class TestContentEncoding(BalancerTestCase):
...
@@ -588,7 +590,7 @@ class TestContentEncoding(BalancerTestCase):
'application/x-font-opentype'
,
'application/x-font-opentype'
,
'application/wasm'
,):
'application/wasm'
,):
resp
=
requests
.
get
(
resp
=
requests
.
get
(
url
parse
.
urljoin
(
self
.
default_balancer_url
,
content_type
),
six
.
moves
.
urllib
.
parse
.
urljoin
(
self
.
default_balancer_url
,
content_type
),
verify
=
False
,
verify
=
False
,
headers
=
{
"Accept-Encoding"
:
"gzip, deflate"
,})
headers
=
{
"Accept-Encoding"
:
"gzip, deflate"
,})
self
.
assertEqual
(
resp
.
headers
[
'Content-Type'
],
content_type
)
self
.
assertEqual
(
resp
.
headers
[
'Content-Type'
],
content_type
)
...
@@ -600,7 +602,7 @@ class TestContentEncoding(BalancerTestCase):
...
@@ -600,7 +602,7 @@ class TestContentEncoding(BalancerTestCase):
def
test_no_gzip_encoding
(
self
):
def
test_no_gzip_encoding
(
self
):
# type: () -> None
# type: () -> None
resp
=
requests
.
get
(
url
parse
.
urljoin
(
self
.
default_balancer_url
,
'/image/png'
),
verify
=
False
)
resp
=
requests
.
get
(
six
.
moves
.
urllib
.
parse
.
urljoin
(
self
.
default_balancer_url
,
'/image/png'
),
verify
=
False
)
self
.
assertNotIn
(
'Content-Encoding'
,
resp
.
headers
)
self
.
assertNotIn
(
'Content-Encoding'
,
resp
.
headers
)
self
.
assertEqual
(
resp
.
text
,
'OK'
)
self
.
assertEqual
(
resp
.
text
,
'OK'
)
...
...
software/slapos-master/test/test/test_erp5.py
View file @
5f82bc97
...
@@ -25,14 +25,15 @@
...
@@ -25,14 +25,15 @@
#
#
##############################################################################
##############################################################################
from
__future__
import
absolute_import
import
os
import
os
import
json
import
json
import
glob
import
glob
import
url
parse
import
six.moves.urllib.
parse
import
socket
import
socket
import
time
import
time
import
re
import
re
import
BaseHTTPServer
import
six.moves.
BaseHTTPServer
import
multiprocessing
import
multiprocessing
import
subprocess
import
subprocess
...
@@ -41,6 +42,9 @@ import requests
...
@@ -41,6 +42,9 @@ import requests
from
.
import
ERP5InstanceTestCase
from
.
import
ERP5InstanceTestCase
from
.
import
setUpModule
from
.
import
setUpModule
import
six
from
six.moves
import
map
from
six.moves
import
range
setUpModule
# pyflakes
setUpModule
# pyflakes
...
@@ -52,7 +56,7 @@ class TestPublishedURLIsReachableMixin(object):
...
@@ -52,7 +56,7 @@ class TestPublishedURLIsReachableMixin(object):
# We access ERP5 trough a "virtual host", which should make
# We access ERP5 trough a "virtual host", which should make
# ERP5 produce URLs using https://virtual-host-name:1234/virtual_host_root
# ERP5 produce URLs using https://virtual-host-name:1234/virtual_host_root
# as base.
# as base.
virtual_host_url
=
url
parse
.
urljoin
(
virtual_host_url
=
six
.
moves
.
urllib
.
parse
.
urljoin
(
base_url
,
base_url
,
'/VirtualHostBase/https/virtual-host-name:1234/{}/VirtualHostRoot/_vh_virtual_host_root/'
'/VirtualHostBase/https/virtual-host-name:1234/{}/VirtualHostRoot/_vh_virtual_host_root/'
.
format
(
site_id
))
.
format
(
site_id
))
...
@@ -80,7 +84,7 @@ class TestPublishedURLIsReachableMixin(object):
...
@@ -80,7 +84,7 @@ class TestPublishedURLIsReachableMixin(object):
# login page can be rendered and contain the text "ERP5"
# login page can be rendered and contain the text "ERP5"
r
=
session
.
get
(
r
=
session
.
get
(
url
parse
.
urljoin
(
base_url
,
'{}/login_form'
.
format
(
site_id
)),
six
.
moves
.
urllib
.
parse
.
urljoin
(
base_url
,
'{}/login_form'
.
format
(
site_id
)),
verify
=
verify
,
verify
=
verify
,
allow_redirects
=
False
,
allow_redirects
=
False
,
)
)
...
@@ -172,7 +176,7 @@ class TestApacheBalancerPorts(ERP5InstanceTestCase):
...
@@ -172,7 +176,7 @@ class TestApacheBalancerPorts(ERP5InstanceTestCase):
}
}
def
checkValidHTTPSURL
(
self
,
url
):
def
checkValidHTTPSURL
(
self
,
url
):
parsed
=
url
parse
.
urlparse
(
url
)
parsed
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url
)
self
.
assertEqual
(
parsed
.
scheme
,
'https'
)
self
.
assertEqual
(
parsed
.
scheme
,
'https'
)
self
.
assertTrue
(
parsed
.
hostname
)
self
.
assertTrue
(
parsed
.
hostname
)
self
.
assertTrue
(
parsed
.
port
)
self
.
assertTrue
(
parsed
.
port
)
...
@@ -291,7 +295,7 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
...
@@ -291,7 +295,7 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
storage
[
"storage"
]
=
"root"
storage
[
"storage"
]
=
"root"
storage
[
"server"
]
=
zeo_addr
storage
[
"server"
]
=
zeo_addr
with
open
(
'%s/etc/zope-%s.conf'
%
(
partition
,
zope
))
as
f
:
with
open
(
'%s/etc/zope-%s.conf'
%
(
partition
,
zope
))
as
f
:
conf
=
map
(
str
.
strip
,
f
.
readlines
(
))
conf
=
list
(
map
(
str
.
strip
,
f
.
readlines
()
))
i
=
conf
.
index
(
"<zodb_db root>"
)
+
1
i
=
conf
.
index
(
"<zodb_db root>"
)
+
1
conf
=
iter
(
conf
[
i
:
conf
.
index
(
"</zodb_db>"
,
i
)])
conf
=
iter
(
conf
[
i
:
conf
.
index
(
"</zodb_db>"
,
i
)])
for
line
in
conf
:
for
line
in
conf
:
...
@@ -300,23 +304,23 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
...
@@ -300,23 +304,23 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
if
line
==
'</zeoclient>'
:
if
line
==
'</zeoclient>'
:
break
break
checkParameter
(
line
,
storage
)
checkParameter
(
line
,
storage
)
for
k
,
v
in
s
torage
.
iteritems
(
):
for
k
,
v
in
s
ix
.
iteritems
(
storage
):
self
.
assertIsNone
(
v
,
k
)
self
.
assertIsNone
(
v
,
k
)
del
storage
del
storage
else
:
else
:
checkParameter
(
line
,
zodb
)
checkParameter
(
line
,
zodb
)
for
k
,
v
in
zodb
.
iteritems
(
):
for
k
,
v
in
six
.
iteritems
(
zodb
):
self
.
assertIsNone
(
v
,
k
)
self
.
assertIsNone
(
v
,
k
)
partition
=
self
.
getComputerPartitionPath
(
'zope-a'
)
partition
=
self
.
getComputerPartitionPath
(
'zope-a'
)
for
zope
in
x
range
(
3
):
for
zope
in
range
(
3
):
checkConf
({
checkConf
({
"cache-size-bytes"
:
"20MB"
,
"cache-size-bytes"
:
"20MB"
,
},
{
},
{
"cache-size"
:
"50MB"
,
"cache-size"
:
"50MB"
,
})
})
partition
=
self
.
getComputerPartitionPath
(
'zope-bb'
)
partition
=
self
.
getComputerPartitionPath
(
'zope-bb'
)
for
zope
in
x
range
(
5
):
for
zope
in
range
(
5
):
checkConf
({
checkConf
({
"cache-size-bytes"
:
"500MB"
if
zope
else
1
<<
20
,
"cache-size-bytes"
:
"500MB"
if
zope
else
1
<<
20
,
},
{
},
{
...
@@ -336,7 +340,7 @@ def popenCommunicate(command_list, input_=None, **kwargs):
...
@@ -336,7 +340,7 @@ def popenCommunicate(command_list, input_=None, **kwargs):
return
result
return
result
class
TestHandler
(
BaseHTTPServer
.
BaseHTTPRequestHandler
):
class
TestHandler
(
six
.
moves
.
BaseHTTPServer
.
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
def
do_GET
(
self
):
self
.
send_response
(
200
)
self
.
send_response
(
200
)
...
@@ -464,7 +468,7 @@ class TestDeploymentScriptInstantiation(ERP5InstanceTestCase):
...
@@ -464,7 +468,7 @@ class TestDeploymentScriptInstantiation(ERP5InstanceTestCase):
ip
,
port
=
re
.
search
(
ip
,
port
=
re
.
search
(
r'.*http:\
/
\/(.*):(\
d*)
\/.*'
,
portal_slap_line
).
groups
()
r'.*http:\
/
\/(.*):(\
d*)
\/.*'
,
portal_slap_line
).
groups
()
port
=
int
(
port
)
port
=
int
(
port
)
server
=
BaseHTTPServer
.
HTTPServer
((
ip
,
port
),
TestHandler
)
server
=
six
.
moves
.
BaseHTTPServer
.
HTTPServer
((
ip
,
port
),
TestHandler
)
server_process
=
multiprocessing
.
Process
(
server_process
=
multiprocessing
.
Process
(
target
=
server
.
serve_forever
,
name
=
'HTTPServer'
)
target
=
server
.
serve_forever
,
name
=
'HTTPServer'
)
server_process
.
start
()
server_process
.
start
()
...
...
software/slapos-master/test/test/test_mariadb.py
View file @
5f82bc97
...
@@ -26,10 +26,11 @@
...
@@ -26,10 +26,11 @@
#
#
##############################################################################
##############################################################################
from
__future__
import
absolute_import
import
os
import
os
import
json
import
json
import
glob
import
glob
import
url
parse
import
six.moves.urllib.
parse
import
socket
import
socket
import
sys
import
sys
import
time
import
time
...
@@ -80,7 +81,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
...
@@ -80,7 +81,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
def
getDatabaseConnection
(
self
):
def
getDatabaseConnection
(
self
):
connection_parameter_dict
=
json
.
loads
(
connection_parameter_dict
=
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])
db_url
=
url
parse
.
urlparse
(
connection_parameter_dict
[
'database-list'
][
0
])
db_url
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
connection_parameter_dict
[
'database-list'
][
0
])
self
.
assertEqual
(
'mysql'
,
db_url
.
scheme
)
self
.
assertEqual
(
'mysql'
,
db_url
.
scheme
)
self
.
assertTrue
(
db_url
.
path
.
startswith
(
'/'
))
self
.
assertTrue
(
db_url
.
path
.
startswith
(
'/'
))
...
...
software/slapos-master/test/test/test_wcfs.py
View file @
5f82bc97
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
# See COPYING file for full licensing terms.
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
# See https://www.nexedi.com/licensing for rationale and options.
from
__future__
import
absolute_import
import
json
import
json
import
os.path
import
os.path
import
unittest
import
unittest
...
...
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