Add erp5cluster-in-webrunner resiliency test.

TODO: erp5-bootstrap executable disappears, preventing it to be run when all other processes are ready.
parent 71115f74
...@@ -66,9 +66,9 @@ class ERP5TestSuite(SlaprunnerTestSuite): ...@@ -66,9 +66,9 @@ class ERP5TestSuite(SlaprunnerTestSuite):
self.logger.info('Retrieved erp5 url is:\n%s' % url) self.logger.info('Retrieved erp5 url is:\n%s' % url)
return url return url
def _connectToERP5(self, url, data=None): def _connectToERP5(self, url, data=None, password='insecure'):
auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm='Zope', uri=url, user='zope', passwd='insecure') auth_handler.add_password(realm='Zope', uri=url, user='zope', passwd=password)
ssl_context = ssl._create_unverified_context() ssl_context = ssl._create_unverified_context()
opener_director = urllib2.build_opener( opener_director = urllib2.build_opener(
auth_handler, auth_handler,
...@@ -85,12 +85,12 @@ class ERP5TestSuite(SlaprunnerTestSuite): ...@@ -85,12 +85,12 @@ class ERP5TestSuite(SlaprunnerTestSuite):
raise NotHttpOkException(result.getcode()) raise NotHttpOkException(result.getcode())
return result.read() return result.read()
def _createRandomERP5Document(self): def _createRandomERP5Document(self, password='insecure'):
""" Create a document with random content in erp5 site.""" """ Create a document with random content in erp5 site."""
# XXX currently only sets erp5 site title. # XXX currently only sets erp5 site title.
# XXX could be simplified to /erp5/setTitle?title=slapos # XXX could be simplified to /erp5/setTitle?title=slapos
erp5_site_title = self.slaprunner_user erp5_site_title = self.slaprunner_user
url = "%s/erp5?__ac_name=zope&__ac_password=insecure" % self._getERP5Url() url = "%s/erp5?__ac_name=zope&__ac_password=%s" % (self._getERP5Url(), password)
form = 'title%%3AUTF-8:string=%s&manage_editProperties%%3Amethod=Save+Changes' % erp5_site_title form = 'title%%3AUTF-8:string=%s&manage_editProperties%%3Amethod=Save+Changes' % erp5_site_title
self._connectToERP5(url, form) self._connectToERP5(url, form)
return erp5_site_title return erp5_site_title
...@@ -127,6 +127,9 @@ class ERP5TestSuite(SlaprunnerTestSuite): ...@@ -127,6 +127,9 @@ class ERP5TestSuite(SlaprunnerTestSuite):
time.sleep(15) time.sleep(15)
# In case erp5 bootstrap (in erp5-cluster) couldn't connect to zope through HAProxy
self._connectToSlaprunner('/startAllPartition')
def generateData(self): def generateData(self):
self.slaprunner_password = ''.join( self.slaprunner_password = ''.join(
random.SystemRandom().sample(string.ascii_lowercase, 8) random.SystemRandom().sample(string.ascii_lowercase, 8)
...@@ -163,6 +166,7 @@ class ERP5TestSuite(SlaprunnerTestSuite): ...@@ -163,6 +166,7 @@ class ERP5TestSuite(SlaprunnerTestSuite):
) )
self._login() self._login()
time.sleep(10)
self._gitClone() self._gitClone()
self._openSoftwareRelease('erp5') self._openSoftwareRelease('erp5')
......
...@@ -43,7 +43,7 @@ class ERP5ClusterTestSuite(ERP5TestSuite): ...@@ -43,7 +43,7 @@ class ERP5ClusterTestSuite(ERP5TestSuite):
""" """
self._connectToSlaprunner( self._connectToSlaprunner(
resource='saveParameterXml', resource='saveParameterXml',
data='software_type=create-erp5-site&parameter=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3Cinstance%3E%0A%3Cparameter+id%3D%22_%22%3E%7B%22zodb-zeo%22%3A+%7B%22backup-periodicity%22%3A+%22hourly%22%7D%2C+%22mariadb%22%3A+%7B%22backup-periodicity%22%3A+%22hourly%22%7D%7D%3C%2Fparameter%3E%0A%3C%2Finstance%3E%0A' data='software_type=create-erp5-site&parameter=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3Cinstance%3E%0A%3Cparameter+id%3D%22_%22%3E%7B%22zodb-zeo%22%3A+%7B%22backup-periodicity%22%3A+%22minutely%22%7D%2C+%22mariadb%22%3A+%7B%22backup-periodicity%22%3A+%22minutely%22%7D%7D%3C%2Fparameter%3E%0A%3C%2Finstance%3E%0A'
) )
def _getERP5Url(self): def _getERP5Url(self):
...@@ -55,10 +55,18 @@ class ERP5ClusterTestSuite(ERP5TestSuite): ...@@ -55,10 +55,18 @@ class ERP5ClusterTestSuite(ERP5TestSuite):
data = self._connectToSlaprunner( data = self._connectToSlaprunner(
resource='getConnectionParameter/slappart7' resource='getConnectionParameter/slappart7'
) )
url = json.loads(data)['_']['default'] url = json.loads(json.loads(data)['_'])['default-v6']
self.logger.info('Retrieved erp5 url is:\n%s' % url) self.logger.info('Retrieved erp5 url is:\n%s' % url)
return url return url
def _getERP5Password(self):
data = self._connectToSlaprunner(
resource='getConnectionParameter/slappart0'
)
password = json.loads(json.loads(data)['_'])['inituser-password']
self.logger.info('Retrieved erp5 password is:\n%s' % password)
return password
def _editHAProxyconfiguration(self): def _editHAProxyconfiguration(self):
""" """
XXX pure hack. XXX pure hack.
...@@ -93,20 +101,21 @@ class ERP5ClusterTestSuite(ERP5TestSuite): ...@@ -93,20 +101,21 @@ class ERP5ClusterTestSuite(ERP5TestSuite):
data='project=workspace%2Fslapos&name=erp5-cluster&create=0' data='project=workspace%2Fslapos&name=erp5-cluster&create=0'
) )
def _createRandomERP5Document(self):
""" Create a document with random content in erp5 site.""" def _connectToERP5(self, url, data=None, password=None):
# XXX currently only sets erp5 site title. if password is None:
# XXX could be simplified to /erp5/setTitle?title=slapos password = self._getERP5Password()
return ERP5TestSuite._connectToERP5(self, url, data, password)
def _createRandomERP5Document(self, password=None):
if password is None:
password = self._getERP5Password()
import rpdb import rpdb
debugger = rpdb.Rpdb(port=12349) debugger = rpdb.Rpdb(port=12349)
debugger.set_trace() debugger.set_trace()
erp5_site_title = self.slaprunner_user return ERP5TestSuite._createRandomERP5Document(self, password)
url = "%s/erp5?__ac_name=zope&__ac_password=insecure" % self._getERP5Url()
form = 'title%%3AUTF-8:string=%s&manage_editProperties%%3Amethod=Save+Changes' % erp5_site_title
self._connectToERP5(url, form)
return erp5_site_title
def _getCreatedERP5Document(self): def _getCreatedERP5Document(self):
""" Fetch and return content of ERP5 document created above.""" """ Fetch and return content of ERP5 document created above."""
......
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