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
550f1417
Commit
550f1417
authored
Nov 26, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python3 tests
parent
39377bee
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
258 additions
and
122 deletions
+258
-122
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
+219
-93
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 @
550f1417
...
...
@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
__future__
import
absolute_import
from
setuptools
import
setup
,
find_packages
version
=
'0.0.1.dev0'
...
...
software/caddy-frontend/test/test.py
View file @
550f1417
This diff is collapsed.
Click to expand it.
software/slapos-master/test/test/__init__.py
View file @
550f1417
...
...
@@ -25,6 +25,7 @@
#
##############################################################################
from
__future__
import
absolute_import
import
json
import
os
...
...
software/slapos-master/test/test/test_balancer.py
View file @
550f1417
from
__future__
import
absolute_import
import
glob
import
hashlib
import
json
...
...
@@ -8,9 +9,9 @@ import shutil
import
subprocess
import
tempfile
import
time
import
urllib
import
url
parse
from
BaseHTTPServer
import
BaseHTTPRequestHandler
import
six.moves.urllib.request
,
six
.
moves
.
urllib
.
parse
,
six
.
moves
.
urllib
.
error
import
six.moves.urllib.
parse
from
six.moves.
BaseHTTPServer
import
BaseHTTPRequestHandler
from
typing
import
Dict
import
mock
...
...
@@ -28,6 +29,7 @@ from slapos.testing.utils import (CrontabMixin, ManagedHTTPServer,
findFreeTCPPort
)
from
.
import
ERP5InstanceTestCase
,
setUpModule
from
six.moves
import
range
setUpModule
# pyflakes
...
...
@@ -214,7 +216,7 @@ class TestLog(BalancerTestCase, CrontabMixin):
def
test_access_log_format
(
self
):
# type: () -> None
requests
.
get
(
url
parse
.
urljoin
(
self
.
default_balancer_url
,
'/url_path'
),
six
.
moves
.
urllib
.
parse
.
urljoin
(
self
.
default_balancer_url
,
'/url_path'
),
verify
=
False
,
)
time
.
sleep
(.
5
)
# wait a bit more until access is logged
...
...
@@ -373,7 +375,7 @@ class TestBalancer(BalancerTestCase):
# if backend provides a "SERVERID" cookie, balancer will overwrite it with the
# backend selected by balancing algorithm
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'
),
)
...
...
@@ -427,18 +429,18 @@ class TestTestRunnerEntryPoints(BalancerTestCase):
)[
'default-test-runner-url-list'
]
url_0
,
url_1
,
url_2
=
test_runner_url_list
self
.
assertEqual
(
url
parse
.
urlparse
(
url_0
).
netloc
,
url
parse
.
urlparse
(
url_1
).
netloc
)
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
,
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_1
).
netloc
)
self
.
assertEqual
(
url
parse
.
urlparse
(
url_0
).
netloc
,
url
parse
.
urlparse
(
url_2
).
netloc
)
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
,
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_2
).
netloc
)
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
(
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
(
netloc
=
url
parse
.
urlparse
(
url_0
).
netloc
)
netloc
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url_0
).
netloc
)
self
.
assertEqual
(
{
...
...
@@ -516,7 +518,7 @@ class TestHTTP(BalancerTestCase):
session
.
get
(
self
.
default_balancer_url
).
raise_for_status
()
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
self
.
assertTrue
([
c
for
c
in
psutil
.
Process
(
os
.
getpid
()).
connections
()
...
...
@@ -588,7 +590,7 @@ class TestContentEncoding(BalancerTestCase):
'application/x-font-opentype'
,
'application/wasm'
,):
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
,
headers
=
{
"Accept-Encoding"
:
"gzip, deflate"
,})
self
.
assertEqual
(
resp
.
headers
[
'Content-Type'
],
content_type
)
...
...
@@ -600,7 +602,7 @@ class TestContentEncoding(BalancerTestCase):
def
test_no_gzip_encoding
(
self
):
# 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
.
assertEqual
(
resp
.
text
,
'OK'
)
...
...
software/slapos-master/test/test/test_erp5.py
View file @
550f1417
...
...
@@ -25,14 +25,15 @@
#
##############################################################################
from
__future__
import
absolute_import
import
os
import
json
import
glob
import
url
parse
import
six.moves.urllib.
parse
import
socket
import
time
import
re
import
BaseHTTPServer
import
six.moves.
BaseHTTPServer
import
multiprocessing
import
subprocess
...
...
@@ -41,6 +42,9 @@ import requests
from
.
import
ERP5InstanceTestCase
from
.
import
setUpModule
import
six
from
six.moves
import
map
from
six.moves
import
range
setUpModule
# pyflakes
...
...
@@ -52,7 +56,7 @@ class TestPublishedURLIsReachableMixin(object):
# We access ERP5 trough a "virtual host", which should make
# ERP5 produce URLs using https://virtual-host-name:1234/virtual_host_root
# as base.
virtual_host_url
=
url
parse
.
urljoin
(
virtual_host_url
=
six
.
moves
.
urllib
.
parse
.
urljoin
(
base_url
,
'/VirtualHostBase/https/virtual-host-name:1234/{}/VirtualHostRoot/_vh_virtual_host_root/'
.
format
(
site_id
))
...
...
@@ -80,7 +84,7 @@ class TestPublishedURLIsReachableMixin(object):
# login page can be rendered and contain the text "ERP5"
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
,
allow_redirects
=
False
,
)
...
...
@@ -172,7 +176,7 @@ class TestApacheBalancerPorts(ERP5InstanceTestCase):
}
def
checkValidHTTPSURL
(
self
,
url
):
parsed
=
url
parse
.
urlparse
(
url
)
parsed
=
six
.
moves
.
urllib
.
parse
.
urlparse
(
url
)
self
.
assertEqual
(
parsed
.
scheme
,
'https'
)
self
.
assertTrue
(
parsed
.
hostname
)
self
.
assertTrue
(
parsed
.
port
)
...
...
@@ -291,7 +295,7 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
storage
[
"storage"
]
=
"root"
storage
[
"server"
]
=
zeo_addr
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
conf
=
iter
(
conf
[
i
:
conf
.
index
(
"</zodb_db>"
,
i
)])
for
line
in
conf
:
...
...
@@ -300,23 +304,23 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
if
line
==
'</zeoclient>'
:
break
checkParameter
(
line
,
storage
)
for
k
,
v
in
s
torage
.
iteritems
(
):
for
k
,
v
in
s
ix
.
iteritems
(
storage
):
self
.
assertIsNone
(
v
,
k
)
del
storage
else
:
checkParameter
(
line
,
zodb
)
for
k
,
v
in
zodb
.
iteritems
(
):
for
k
,
v
in
six
.
iteritems
(
zodb
):
self
.
assertIsNone
(
v
,
k
)
partition
=
self
.
getComputerPartitionPath
(
'zope-a'
)
for
zope
in
x
range
(
3
):
for
zope
in
range
(
3
):
checkConf
({
"cache-size-bytes"
:
"20MB"
,
},
{
"cache-size"
:
"50MB"
,
})
partition
=
self
.
getComputerPartitionPath
(
'zope-bb'
)
for
zope
in
x
range
(
5
):
for
zope
in
range
(
5
):
checkConf
({
"cache-size-bytes"
:
"500MB"
if
zope
else
1
<<
20
,
},
{
...
...
@@ -336,7 +340,7 @@ def popenCommunicate(command_list, input_=None, **kwargs):
return
result
class
TestHandler
(
BaseHTTPServer
.
BaseHTTPRequestHandler
):
class
TestHandler
(
six
.
moves
.
BaseHTTPServer
.
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
self
.
send_response
(
200
)
...
...
@@ -464,7 +468,7 @@ class TestDeploymentScriptInstantiation(ERP5InstanceTestCase):
ip
,
port
=
re
.
search
(
r'.*http:\
/
\/(.*):(\
d*)
\/.*'
,
portal_slap_line
).
groups
()
port
=
int
(
port
)
server
=
BaseHTTPServer
.
HTTPServer
((
ip
,
port
),
TestHandler
)
server
=
six
.
moves
.
BaseHTTPServer
.
HTTPServer
((
ip
,
port
),
TestHandler
)
server_process
=
multiprocessing
.
Process
(
target
=
server
.
serve_forever
,
name
=
'HTTPServer'
)
server_process
.
start
()
...
...
software/slapos-master/test/test/test_mariadb.py
View file @
550f1417
...
...
@@ -26,10 +26,11 @@
#
##############################################################################
from
__future__
import
absolute_import
import
os
import
json
import
glob
import
url
parse
import
six.moves.urllib.
parse
import
socket
import
sys
import
time
...
...
@@ -80,7 +81,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
def
getDatabaseConnection
(
self
):
connection_parameter_dict
=
json
.
loads
(
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
.
assertTrue
(
db_url
.
path
.
startswith
(
'/'
))
...
...
software/slapos-master/test/test/test_wcfs.py
View file @
550f1417
...
...
@@ -16,6 +16,7 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from
__future__
import
absolute_import
import
json
import
os.path
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