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
106
Merge Requests
106
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
7a988a85
Commit
7a988a85
authored
Mar 26, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5/test: use slapos.testing
parent
f986e3ba
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
369 deletions
+35
-369
software/erp5/test/setup.py
software/erp5/test/setup.py
+2
-1
software/erp5/test/test/__init__.py
software/erp5/test/test/__init__.py
+18
-9
software/erp5/test/test/test_erp5.py
software/erp5/test/test/test_erp5.py
+15
-28
software/erp5/test/utils.py
software/erp5/test/utils.py
+0
-331
No files found.
software/erp5/test/setup.py
View file @
7a988a85
...
...
@@ -28,7 +28,8 @@ from setuptools import setup, find_packages
version
=
'0.0.1.dev0'
name
=
'slapos.test.erp5'
long_description
=
open
(
"README.md"
).
read
()
with
open
(
"README.md"
)
as
f
:
long_description
=
f
.
read
()
setup
(
name
=
name
,
version
=
version
,
...
...
software/erp5/test/test/__init__.py
View file @
7a988a85
...
...
@@ -25,15 +25,24 @@
#
##############################################################################
import
json
import
os
import
unittest
import
logging
if
os
.
environ
.
get
(
'DEBUG'
):
raise
ValueError
(
"Don't set DEBUG - it breaks postfix compilation - set SLAPOS_TEST_DEBUG instead."
)
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
debug_mode
=
os
.
environ
.
get
(
'SLAPOS_TEST_DEBUG'
)
# for development: debugging logs and install Ctrl+C handler
if
debug_mode
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
unittest
.
installHandler
()
setUpModule
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'software.cfg'
)))
class
ERP5InstanceTestCase
(
SlapOSInstanceTestCase
):
"""ERP5 base test case
"""
# ERP5 instanciation needs to run several times before being ready, as
# the root instance request more instances.
instance_max_retry
=
7
# XXX how many times ?
def
getRootPartitionConnectionParameterDict
(
self
):
"""Return the output paramters from the root partition"""
return
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])
software/erp5/test/test/test_erp5.py
View file @
7a988a85
...
...
@@ -29,28 +29,15 @@ import os
import
json
import
glob
import
urlparse
import
logging
import
socket
import
time
import
psutil
import
requests
from
utils
import
SlapOSInstanceTestCase
class
ERP5TestCase
(
SlapOSInstanceTestCase
):
"""Test the remote driver on a minimal web server.
"""
logger
=
logging
.
getLogger
(
__name__
)
@
classmethod
def
getSoftwareURLList
(
cls
):
return
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'software.cfg'
)),
)
def
getRootPartitionConnectionParameterDict
(
self
):
"""Return the output paramters from the root partition"""
return
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])
from
.
import
ERP5InstanceTestCase
from
.
import
setUpModule
setUpModule
# pyflakes
class
TestPublishedURLIsReachableMixin
(
object
):
...
...
@@ -91,13 +78,13 @@ class TestPublishedURLIsReachableMixin(object):
urlparse
.
urljoin
(
param_dict
[
'family-default'
],
param_dict
[
'site-id'
]))
class
TestDefaultParameters
(
ERP5TestCase
,
TestPublishedURLIsReachableMixin
):
class
TestDefaultParameters
(
ERP5
Instance
TestCase
,
TestPublishedURLIsReachableMixin
):
"""Test ERP5 can be instanciated with no parameters
"""
__partition_reference__
=
'defp'
class
TestMedusa
(
ERP5TestCase
,
TestPublishedURLIsReachableMixin
):
class
TestMedusa
(
ERP5
Instance
TestCase
,
TestPublishedURLIsReachableMixin
):
"""Test ERP5 Medusa server
"""
__partition_reference__
=
'medusa'
...
...
@@ -107,7 +94,7 @@ class TestMedusa(ERP5TestCase, TestPublishedURLIsReachableMixin):
return
{
'_'
:
json
.
dumps
({
'wsgi'
:
False
})}
class
TestApacheBalancerPorts
(
ERP5TestCase
):
class
TestApacheBalancerPorts
(
ERP5
Instance
TestCase
):
"""Instanciate with two zope families, this should create for each family:
- a balancer entry point with corresponding haproxy
- a balancer entry point for test runner
...
...
@@ -159,8 +146,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_zope_listen
(
self
):
# we requested 3 zope in family1 and 5 zopes in family2, we should have 8 zope running.
all_process_info
=
self
.
getSupervisorRPCServer
(
).
supervisor
.
getAllProcessInfo
()
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
all_process_info
=
supervisor
.
getAllProcessInfo
()
self
.
assertEqual
(
3
+
5
,
len
([
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'zope-'
)]))
...
...
@@ -168,8 +155,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_apache_listen
(
self
):
# We have 2 families, apache should listen to a total of 3 ports per family
# normal access on ipv4 and ipv6 and test runner access on ipv4 only
all_process_info
=
self
.
getSupervisorRPCServer
(
).
supervisor
.
getAllProcessInfo
()
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
self
.
assertEqual
(
...
...
@@ -182,8 +169,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_haproxy_listen
(
self
):
# There is one haproxy per family
all_process_info
=
self
.
getSupervisorRPCServer
(
).
supervisor
.
getAllProcessInfo
()
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'haproxy-'
)
]
...
...
@@ -193,7 +180,7 @@ class TestApacheBalancerPorts(ERP5TestCase):
])
class
TestDisableTestRunner
(
ERP5TestCase
,
TestPublishedURLIsReachableMixin
):
class
TestDisableTestRunner
(
ERP5
Instance
TestCase
,
TestPublishedURLIsReachableMixin
):
"""Test ERP5 can be instanciated without test runner.
"""
__partition_reference__
=
'distr'
...
...
@@ -215,8 +202,8 @@ class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin):
def
test_no_apache_testrunner_port
(
self
):
# Apache only listen on two ports, there is no apache ports allocated for test runner
all_process_info
=
self
.
getSupervisorRPCServer
(
).
supervisor
.
getAllProcessInfo
()
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
self
.
assertEqual
(
...
...
software/erp5/test/utils.py
deleted
100644 → 0
View file @
f986e3ba
This diff is collapsed.
Click to expand it.
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