resiliency test suite: do takeover from web interface.

parent 30947369
...@@ -26,16 +26,14 @@ ...@@ -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 slapos.slap
import logging import logging
import time
import os import os
import subprocess import subprocess
import sys import sys
import time
import urllib2
UNIT_TEST_ERP5TESTNODE = 'UnitTest' UNIT_TEST_ERP5TESTNODE = 'UnitTest'
...@@ -73,23 +71,29 @@ class ResiliencyTestSuite(object): ...@@ -73,23 +71,29 @@ class ResiliencyTestSuite(object):
self.logger = logging.getLogger('SlaprunnerResiliencyTest') self.logger = logging.getLogger('SlaprunnerResiliencyTest')
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)
def _doTakeover(self, target_clone): def _doTakeover(self, namebase, target_clone):
""" """
Private method. Private method.
Make the specified clone instance takeover the main instance. Make the specified clone instance takeover the main instance.
""" """
self.logger.info('Replacing main instance by clone instance %s%s...' % ( self.logger.info('Replacing main instance by clone instance %s%s...' % (
self.namebase, target_clone)) self.namebase, target_clone))
takeover(
server_url=self.server_url, # Request
key_file=self.key_file, root_partition_parameter_dict = self._getPartitionParameterDict()
cert_file=self.cert_file, takeover_url = root_partition_parameter_dict['takeover-%s-%s-url' % (namebase, target_clone)]
computer_guid=self.computer_id, takeover_password = root_partition_parameter_dict['takeover-%s-%s-password' % (namebase, target_clone)]
partition_id=self.partition_id, # Connect to takeover web interface
software_release=self.software, takeover_page_content = urllib2.urlopen(takeover_url).read()
namebase=self.namebase, # Wait for importer script to be not running
winner_instance_suffix=str(target_clone), 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.') self.logger.info('Done.')
def generateData(self): def generateData(self):
...@@ -156,7 +160,7 @@ class ResiliencyTestSuite(object): ...@@ -156,7 +160,7 @@ class ResiliencyTestSuite(object):
Private method. Private method.
Launch takeover and check for a specific clone. 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)) self.logger.info('Testing %s%s instance.' % (self.namebase, clone))
# Wait for XX minutes so that replication is done # Wait for XX minutes so that replication is done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment