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
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
Lisa Casino
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
Show 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
...
@@ -28,7 +28,8 @@ from setuptools import setup, find_packages
version
=
'0.0.1.dev0'
version
=
'0.0.1.dev0'
name
=
'slapos.test.erp5'
name
=
'slapos.test.erp5'
long_description
=
open
(
"README.md"
).
read
()
with
open
(
"README.md"
)
as
f
:
long_description
=
f
.
read
()
setup
(
name
=
name
,
setup
(
name
=
name
,
version
=
version
,
version
=
version
,
...
...
software/erp5/test/test/__init__.py
View file @
7a988a85
...
@@ -25,15 +25,24 @@
...
@@ -25,15 +25,24 @@
#
#
##############################################################################
##############################################################################
import
json
import
os
import
os
import
unittest
import
logging
if
os
.
environ
.
get
(
'DEBUG'
):
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
raise
ValueError
(
"Don't set DEBUG - it breaks postfix compilation - set SLAPOS_TEST_DEBUG instead."
)
debug_mode
=
os
.
environ
.
get
(
'SLAPOS_TEST_DEBUG'
)
setUpModule
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
# for development: debugging logs and install Ctrl+C handler
os
.
path
.
abspath
(
if
debug_mode
:
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'software.cfg'
)))
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
unittest
.
installHandler
()
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
...
@@ -29,28 +29,15 @@ import os
import
json
import
json
import
glob
import
glob
import
urlparse
import
urlparse
import
logging
import
socket
import
socket
import
time
import
time
import
psutil
import
psutil
import
requests
import
requests
from
utils
import
SlapOSInstanceTestCase
from
.
import
ERP5InstanceTestCase
from
.
import
setUpModule
setUpModule
# pyflakes
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
()[
'_'
])
class
TestPublishedURLIsReachableMixin
(
object
):
class
TestPublishedURLIsReachableMixin
(
object
):
...
@@ -91,13 +78,13 @@ class TestPublishedURLIsReachableMixin(object):
...
@@ -91,13 +78,13 @@ class TestPublishedURLIsReachableMixin(object):
urlparse
.
urljoin
(
param_dict
[
'family-default'
],
param_dict
[
'site-id'
]))
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
"""Test ERP5 can be instanciated with no parameters
"""
"""
__partition_reference__
=
'defp'
__partition_reference__
=
'defp'
class
TestMedusa
(
ERP5TestCase
,
TestPublishedURLIsReachableMixin
):
class
TestMedusa
(
ERP5
Instance
TestCase
,
TestPublishedURLIsReachableMixin
):
"""Test ERP5 Medusa server
"""Test ERP5 Medusa server
"""
"""
__partition_reference__
=
'medusa'
__partition_reference__
=
'medusa'
...
@@ -107,7 +94,7 @@ class TestMedusa(ERP5TestCase, TestPublishedURLIsReachableMixin):
...
@@ -107,7 +94,7 @@ class TestMedusa(ERP5TestCase, TestPublishedURLIsReachableMixin):
return
{
'_'
:
json
.
dumps
({
'wsgi'
:
False
})}
return
{
'_'
:
json
.
dumps
({
'wsgi'
:
False
})}
class
TestApacheBalancerPorts
(
ERP5TestCase
):
class
TestApacheBalancerPorts
(
ERP5
Instance
TestCase
):
"""Instanciate with two zope families, this should create for each family:
"""Instanciate with two zope families, this should create for each family:
- a balancer entry point with corresponding haproxy
- a balancer entry point with corresponding haproxy
- a balancer entry point for test runner
- a balancer entry point for test runner
...
@@ -159,8 +146,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
...
@@ -159,8 +146,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_zope_listen
(
self
):
def
test_zope_listen
(
self
):
# we requested 3 zope in family1 and 5 zopes in family2, we should have 8 zope running.
# we requested 3 zope in family1 and 5 zopes in family2, we should have 8 zope running.
all_process_info
=
self
.
getSupervisorRPCServer
(
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
).
supervisor
.
getAllProcessInfo
()
all_process_info
=
supervisor
.
getAllProcessInfo
()
self
.
assertEqual
(
self
.
assertEqual
(
3
+
5
,
3
+
5
,
len
([
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'zope-'
)]))
len
([
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'zope-'
)]))
...
@@ -168,8 +155,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
...
@@ -168,8 +155,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_apache_listen
(
self
):
def
test_apache_listen
(
self
):
# We have 2 families, apache should listen to a total of 3 ports per family
# 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
# normal access on ipv4 and ipv6 and test runner access on ipv4 only
all_process_info
=
self
.
getSupervisorRPCServer
(
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
).
supervisor
.
getAllProcessInfo
()
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -182,8 +169,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
...
@@ -182,8 +169,8 @@ class TestApacheBalancerPorts(ERP5TestCase):
def
test_haproxy_listen
(
self
):
def
test_haproxy_listen
(
self
):
# There is one haproxy per family
# There is one haproxy per family
all_process_info
=
self
.
getSupervisorRPCServer
(
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
).
supervisor
.
getAllProcessInfo
()
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'haproxy-'
)
p
for
p
in
all_process_info
if
p
[
'name'
].
startswith
(
'haproxy-'
)
]
]
...
@@ -193,7 +180,7 @@ class TestApacheBalancerPorts(ERP5TestCase):
...
@@ -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.
"""Test ERP5 can be instanciated without test runner.
"""
"""
__partition_reference__
=
'distr'
__partition_reference__
=
'distr'
...
@@ -215,8 +202,8 @@ class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin):
...
@@ -215,8 +202,8 @@ class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin):
def
test_no_apache_testrunner_port
(
self
):
def
test_no_apache_testrunner_port
(
self
):
# Apache only listen on two ports, there is no apache ports allocated for test runner
# Apache only listen on two ports, there is no apache ports allocated for test runner
all_process_info
=
self
.
getSupervisorRPCServer
(
with
self
.
slap
.
instance_supervisor_rpc
as
supervisor
:
).
supervisor
.
getAllProcessInfo
()
all_process_info
=
supervisor
.
getAllProcessInfo
()
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
process_info
,
=
[
p
for
p
in
all_process_info
if
p
[
'name'
]
==
'apache'
]
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
apache_process
=
psutil
.
Process
(
process_info
[
'pid'
])
self
.
assertEqual
(
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