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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.toolbox
Commits
1b38e187
Commit
1b38e187
authored
Feb 10, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resiliency test suite: do takeover from web interface.
parent
30947369
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
slapos/resiliencytest/suites/resiliencytestsuite.py
slapos/resiliencytest/suites/resiliencytestsuite.py
+20
-16
No files found.
slapos/resiliencytest/suites/resiliencytestsuite.py
View file @
1b38e187
...
...
@@ -26,16 +26,14 @@
#
##############################################################################
# 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
import
slapos.slap
import
logging
import
time
import
os
import
subprocess
import
sys
import
time
import
urllib2
UNIT_TEST_ERP5TESTNODE
=
'UnitTest'
...
...
@@ -73,23 +71,29 @@ class ResiliencyTestSuite(object):
self
.
logger
=
logging
.
getLogger
(
'SlaprunnerResiliencyTest'
)
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
def
_doTakeover
(
self
,
target_clone
):
def
_doTakeover
(
self
,
namebase
,
target_clone
):
"""
Private method.
Make the specified clone instance takeover the main instance.
"""
self
.
logger
.
info
(
'Replacing main instance by clone instance %s%s...'
%
(
self
.
namebase
,
target_clone
))
takeover
(
server_url
=
self
.
server_url
,
key_file
=
self
.
key_file
,
cert_file
=
self
.
cert_file
,
computer_guid
=
self
.
computer_id
,
partition_id
=
self
.
partition_id
,
software_release
=
self
.
software
,
namebase
=
self
.
namebase
,
winner_instance_suffix
=
str
(
target_clone
),
)
# Request
root_partition_parameter_dict
=
self
.
_getPartitionParameterDict
()
takeover_url
=
root_partition_parameter_dict
[
'takeover-%s-%s-url'
%
(
namebase
,
target_clone
)]
takeover_password
=
root_partition_parameter_dict
[
'takeover-%s-%s-password'
%
(
namebase
,
target_clone
)]
# Connect to takeover web interface
takeover_page_content
=
urllib2
.
urlopen
(
takeover_url
).
read
()
# Wait for importer script to be not running
while
'Importer script(s) of backup in progress: True'
in
takeover_page_content
:
time
.
sleep
(
10
)
takeover_page_content
=
urllib2
.
urlopen
(
takeover_url
).
read
()
# Do takeover
takeover_result
=
urllib2
.
urlopen
(
'%s?password=%s'
%
(
takeover_url
,
takeover_password
)).
read
()
if
'Error'
in
takeover_result
:
raise
Exception
(
'Error while doing takeover: %s'
%
takeover_result
)
self
.
logger
.
info
(
'Done.'
)
def
generateData
(
self
):
...
...
@@ -156,7 +160,7 @@ class ResiliencyTestSuite(object):
Private method.
Launch takeover and check for a specific clone.
"""
self
.
_doTakeover
(
clone
)
self
.
_doTakeover
(
self
.
namebase
,
clone
)
self
.
logger
.
info
(
'Testing %s%s instance.'
%
(
self
.
namebase
,
clone
))
# Wait for XX minutes so that replication is done
...
...
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