Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Boxiang Sun
slapos.toolbox
Commits
245932ae
Commit
245932ae
authored
Nov 24, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resiliencytest: adapt abstract test suite to work with erp5testnode.
parent
144d41b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
16 deletions
+50
-16
slapos/resiliencytest/suites/resiliencytestsuite.py
slapos/resiliencytest/suites/resiliencytestsuite.py
+50
-16
No files found.
slapos/resiliencytest/suites/resiliencytestsuite.py
View file @
245932ae
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
##############################################################################
##############################################################################
# XXX: takeover module should be in slapos.toolbox, not in slapos.cookbook
# XXX: takeover module should be in slapos.toolbox, not in slapos.cookbook
# XXX: use web interface for takeover to really simulate user behavior.
from
slapos.recipe.addresiliency.takeover
import
takeover
from
slapos.recipe.addresiliency.takeover
import
takeover
import
slapos.slap
import
slapos.slap
...
@@ -34,6 +35,8 @@ import logging
...
@@ -34,6 +35,8 @@ import logging
import
time
import
time
import
os
import
os
UNIT_TEST_ERP5TESTNODE
=
'UnitTest'
class
ResiliencyTestSuite
(
object
):
class
ResiliencyTestSuite
(
object
):
"""
"""
Abstract class supposed to be extended by Resiliency Test Suites.
Abstract class supposed to be extended by Resiliency Test Suites.
...
@@ -44,7 +47,8 @@ class ResiliencyTestSuite(object):
...
@@ -44,7 +47,8 @@ class ResiliencyTestSuite(object):
namebase
,
namebase
,
root_instance_name
,
root_instance_name
,
sleep_time_between_test
=
600
,
sleep_time_between_test
=
600
,
total_instance_count
=
"3"
):
total_instance_count
=
"2"
,
type
=
None
):
self
.
server_url
=
server_url
self
.
server_url
=
server_url
self
.
key_file
=
key_file
self
.
key_file
=
key_file
self
.
cert_file
=
cert_file
self
.
cert_file
=
cert_file
...
@@ -55,6 +59,7 @@ class ResiliencyTestSuite(object):
...
@@ -55,6 +59,7 @@ class ResiliencyTestSuite(object):
self
.
total_instance_count
=
total_instance_count
self
.
total_instance_count
=
total_instance_count
self
.
root_instance_name
=
root_instance_name
self
.
root_instance_name
=
root_instance_name
self
.
sleep_time_between_test
=
sleep_time_between_test
self
.
sleep_time_between_test
=
sleep_time_between_test
self
.
suite_type
=
type
slap
=
slapos
.
slap
.
slap
()
slap
=
slapos
.
slap
.
slap
()
slap
.
initializeConnection
(
server_url
,
key_file
,
cert_file
)
slap
.
initializeConnection
(
server_url
,
key_file
,
cert_file
)
...
@@ -64,7 +69,6 @@ class ResiliencyTestSuite(object):
...
@@ -64,7 +69,6 @@ class ResiliencyTestSuite(object):
)
)
self
.
logger
=
logging
.
getLogger
(
'SlaprunnerResiliencyTest'
)
self
.
logger
=
logging
.
getLogger
(
'SlaprunnerResiliencyTest'
)
# XXX Quite hardcoded...
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
_doTakeover
(
self
,
target_clone
):
def
_doTakeover
(
self
,
target_clone
):
...
@@ -132,16 +136,55 @@ class ResiliencyTestSuite(object):
...
@@ -132,16 +136,55 @@ class ResiliencyTestSuite(object):
Wait for the new parameter (of old-clone new-main instance) to appear.
Wait for the new parameter (of old-clone new-main instance) to appear.
Check than it is different from the old parameter
Check than it is different from the old parameter
"""
"""
# if we are inside of a classical erp5testnode: just return the same parameter.
if
self
.
test_type
==
UNIT_TEST_ERP5TESTNODE
:
return
old_parameter_value
self
.
logger
.
info
(
'Waiting for new main instance to be ready...'
)
self
.
logger
.
info
(
'Waiting for new main instance to be ready...'
)
new_parameter_value
=
None
new_parameter_value
=
None
while
not
new_parameter_value
or
new_parameter_value
==
'None'
or
new_parameter_value
==
old_parameter_value
:
while
not
new_parameter_value
or
new_parameter_value
==
'None'
or
new_parameter_value
==
old_parameter_value
:
self
.
logger
.
info
(
'Not ready yet. SlapOS says new parameter value is %s'
%
new_parameter_value
)
self
.
logger
.
info
(
'Not ready yet. SlapOS says new parameter value is %s'
%
new_parameter_value
)
new_parameter_value
=
self
.
_getPartitionParameterDict
().
get
(
parameter_key
,
None
)
new_parameter_value
=
self
.
_getPartitionParameterDict
().
get
(
parameter_key
,
None
)
time
.
sleep
(
12
0
)
time
.
sleep
(
3
0
)
self
.
logger
.
info
(
'New parameter value of instance is %s'
%
new_parameter_value
)
self
.
logger
.
info
(
'New parameter value of instance is %s'
%
new_parameter_value
)
return
new_parameter_value
return
new_parameter_value
def
_testClone
(
self
,
clone
):
"""
Private method.
Launch takeover and check for a specific clone.
"""
self
.
_doTakeover
(
clone
)
self
.
logger
.
info
(
'Testing %s%s instance.'
%
(
self
.
namebase
,
clone
))
# Wait for XX minutes so that replication is done
self
.
logger
.
info
(
'Sleeping for %s seconds before testing clone %s.'
%
(
self
.
sleep_time_between_test
,
current_clone
))
time
.
sleep
(
self
.
sleep_time_between_test
)
if
self
.
test_type
==
UNIT_TEST_ERP5TESTNODE
:
# Run by classical erp5testnode using slapproxy
# Run manually slapos node instance
# XXX hardcoded path
self
.
logger
.
info
(
'Running "slapos node instance"...'
)
slapos_configuration_file_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
'..'
,
'..'
,
'..'
,
'slapos.cfg'
)
command
=
[
'/opt/slapos/bin/slapos'
,
'node'
,
'instance'
,
'--cfg=%s'
%
slapos_configuration_file_path
,
'--pidfile=slapos.pid'
]
subprocess
.
Popen
(
command
).
wait
()
subprocess
.
Popen
(
command
).
wait
()
subprocess
.
Popen
(
command
).
wait
()
new_ip
=
ip
success
=
self
.
checkDataOnCloneInstance
()
if
success
:
return
True
return
False
def
runTestSuite
(
self
):
def
runTestSuite
(
self
):
"""
"""
...
@@ -160,22 +203,13 @@ class ResiliencyTestSuite(object):
...
@@ -160,22 +203,13 @@ class ResiliencyTestSuite(object):
# So first clone starts from 1.
# So first clone starts from 1.
current_clone
=
1
current_clone
=
1
# Wait for XX minutes so that replication is done
self
.
logger
.
info
(
'Sleeping for %s seconds before testing clone %s.'
%
(
self
.
sleep_time_between_test
,
current_clone
))
time
.
sleep
(
self
.
sleep_time_between_test
)
# Test each clone
# Test each clone
while
current_clone
<=
clone_count
:
while
current_clone
<=
clone_count
:
self
.
_doTakeover
(
current_clone
)
success
=
self
.
_test_clone
(
current_clone
)
self
.
logger
.
info
(
'Testing %s%s instance.'
%
(
self
.
namebase
,
current_clone
))
success
=
self
.
checkDataOnCloneInstance
()
if
not
success
:
if
not
success
:
return
Fa
ls
e
return
Fa
sl
e
current_clone
=
current_clone
+
1
current_clone
=
current_clone
+
1
# All clones have been successfully tested: success.
# All clones have been successfully tested: success.
return
True
return
True
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