Commit cfdbaaf1 authored by Nicolas Wavrant's avatar Nicolas Wavrant

resiliencytest: remove some slapparts hardcoded in test code

As these slapparts are unstable and are updated every couples of months.
Do so by using the API-ification of inspectInstance which can now
return a JSON (thus output can be easily processed)
parent b7194616
......@@ -76,6 +76,12 @@ class ERP5TestSuite(SlaprunnerTestSuite):
self.logger.info('Retrieved erp5 password is:\n%s' % password)
return password
def _getSlaprunnerServiceInformationList(self):
result = self._connectToSlaprunner(
resource='/inspectInstance',
)
return json.loads(result)
def _editHAProxyconfiguration(self):
"""
XXX pure hack.
......@@ -85,20 +91,31 @@ class ERP5TestSuite(SlaprunnerTestSuite):
"""
self.logger.info('Editing HAProxy configuration...')
service_information_list = self._getSlaprunnerServiceInformationList()
# We expect only one service haproxy
haproxy_service, = [
x['service_name'] for x in service_information_list
if 'haproxy' in x['service_name']
]
haproxy_slappart = haproxy_service.split(':', 1)[0]
result = self._connectToSlaprunner(
resource='/getFileContent',
data='file=runner_workdir%2Finstance%2Fslappart7%2Fetc%2Fhaproxy.cfg'
data='file=runner_workdir%2Finstance%2F{slappart}%2Fetc%2Fhaproxy.cfg'.format(slappart=haproxy_slappart)
)
file_content = json.loads(result)['result']
file_content = file_content.replace('var/run/haproxy.sock', 'ha.sock')
self._connectToSlaprunner(
resource='/saveFileContent',
data='file=runner_workdir%%2Finstance%%2Fslappart7%%2Fetc%%2Fhaproxy.cfg&content=%s' % urllib.quote(file_content)
data='file=runner_workdir%%2Finstance%%2F%s%%2Fetc%%2Fhaproxy.cfg&content=%s' % (
haproxy_slappart,
urllib.quote(file_content),
)
)
# Restart HAProxy
self._connectToSlaprunner(
resource='/startStopProccess/name/slappart7:*/cmd/RESTART'
resource='/startStopProccess/name/%s:*/cmd/RESTART' % haproxy_slappart
)
......
......@@ -102,7 +102,12 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
def _login(self):
self.logger.debug('Logging in...')
b64string = base64.encodestring('%s:%s' % (self.slaprunner_user, self.slaprunner_password))[:-1]
self._opener_director.addheaders = [('Authorization', 'Basic %s'%b64string)]
self._opener_director.addheaders = [
('Authorization', 'Basic %s' % b64string),
# By default we will prefer to receive JSON to simplify
# treatments of the response
("Accept", "application/json"),
]
def _retrieveInstanceLogFile(self):
"""
......
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