Ceph failover HA
Change-Id: I41945fa48f5de97c472392b22e0efc6319b5aefb
diff --git a/tcp_tests/managers/openstack_manager.py b/tcp_tests/managers/openstack_manager.py
index 2780d9b..bac459a 100644
--- a/tcp_tests/managers/openstack_manager.py
+++ b/tcp_tests/managers/openstack_manager.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
+import requests
from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
from tcp_tests import logger
@@ -39,6 +40,55 @@
self.execute_commands(commands,
label='Install OpenStack services')
self.__config.openstack.openstack_installed = True
+ h_data = self.get_horizon_data()
+ self.__config.openstack.horizon_host = h_data['horizon_host']
+ self.__config.openstack.horizon_port = h_data['horizon_port']
+ self.__config.openstack.horizon_user = h_data['horizon_user']
+ self.__config.openstack.horizon_password = h_data['horizon_password']
+ self.auth_in_horizon(
+ h_data['horizon_host'],
+ h_data['horizon_port'],
+ h_data['horizon_user'],
+ h_data['horizon_password'])
+
+ def get_horizon_data(self):
+ horizon_data = {}
+ tgt = 'I@nginx:server and not cfg*'
+ pillar_host = ('nginx:server:site:nginx_ssl_redirect'
+ '_openstack_web:host:name')
+ pillar_port = ('nginx:server:site:nginx_ssl_redirect'
+ '_openstack_web:host:port')
+ hosts = self._salt.get_pillar(tgt=tgt, pillar=pillar_host)
+ host = set([ip for item in hosts for node, ip
+ in item.items() if ip])
+ if host:
+ host = host.pop()
+ ports = self._salt.get_pillar(tgt=tgt, pillar=pillar_port)
+
+ port = set([port for item in ports for node, port
+ in item.items() if port])
+ if port:
+ port = port.pop()
+ tgt = 'I@keystone:server and ctl01*'
+ pillar_user = 'keystone:server:admin_name'
+ pillar_password = 'keystone:server:admin_password'
+ users = self._salt.get_pillar(tgt=tgt, pillar=pillar_user)
+ user = set([user for item in users for node, user
+ in item.items() if user])
+ if user:
+ user = user.pop()
+ passwords = self._salt.get_pillar(tgt=tgt, pillar=pillar_password)
+ pwd = set([pwd for item in passwords for node, pwd
+ in item.items() if pwd])
+ if pwd:
+ pwd = pwd.pop()
+ horizon_data.update({'horizon_host': host})
+ horizon_data.update({'horizon_port': port})
+ horizon_data.update({'horizon_user': user})
+ horizon_data.update({'horizon_password': pwd})
+ LOG.info("Data from pillars {}".format(horizon_data))
+
+ return horizon_data
def run_tempest(
self,
@@ -121,3 +171,37 @@
LOG.info('Reboot (warm restart) nodes {0}'.format(node_names))
self.warm_shutdown_openstack_nodes(node_names, timeout=timeout)
self.warm_start_nodes(node_names)
+
+ def auth_in_horizon(self, host, port, user, password):
+ client = requests.session()
+ url = "http://{0}:{1}".format(
+ self.__config.openstack.horizon_host,
+ self.__config.openstack.horizon_port)
+ # Retrieve the CSRF token first
+ client.get(url, verify=False) # sets cookie
+ if not len(client.cookies):
+ login_data = dict(
+ username=self.__config.openstack.horizon_user,
+ password=self.__config.openstack.horizon_password,
+ next='/')
+ resp = client.post(url, data=login_data,
+ headers=dict(Referer=url), verify=False)
+ LOG.debug("Horizon resp {}".format(resp))
+ assert 200 == resp.status_code, ("Failed to auth in "
+ "horizon. Response "
+ "{0}".format(resp.status_code))
+ else:
+ login_data = dict(
+ username=self.__config.openstack.horizon_user,
+ password=self.__config.openstack.horizon_password,
+ next='/')
+ csrftoken = client.cookies.get('csrftoken', None)
+ if csrftoken:
+ login_data['csrfmiddlewaretoken'] = csrftoken
+
+ resp = client.post(url, data=login_data,
+ headers=dict(Referer=url), verify=False)
+ LOG.debug("Horizon resp {}".format(resp))
+ assert 200 == resp.status_code, ("Failed to auth in "
+ "horizon. Response "
+ "{0}".format(resp.status_code))
diff --git a/tcp_tests/managers/rallymanager.py b/tcp_tests/managers/rallymanager.py
index fc56afa..ae72941 100644
--- a/tcp_tests/managers/rallymanager.py
+++ b/tcp_tests/managers/rallymanager.py
@@ -173,7 +173,8 @@
# Updated to replace the OpenStackManager method run_tempest
def run_tempest(self, conf_name='/var/lib/lvm_mcp.conf',
pattern='set=smoke', concurrency=0, timeout=None,
- report_prefix='', report_types=None):
+ report_prefix='', report_types=None,
+ designate_plugin=True):
"""Run tempest tests
:param conf_name: tempest config placed in the rally container
@@ -182,6 +183,7 @@
to take the amount of the cores on the node
<self._node_name>.
:param timeout: stop tempest tests after specified timeout.
+ :param designate_plugin: enabled by default plugin for designate
:param report_prefix: str, prefix for report filenames. Usually the
output of the fixture 'func_name'
:param report_types: list of the report types that need to download
@@ -189,23 +191,36 @@
None by default.
"""
report_types = report_types or []
-
- cmd = (
- "cat > /root/rally/install_tempest.sh << EOF\n"
- "rally verify create-verifier"
- " --type tempest "
- " --name tempest-verifier"
- " --source /var/lib/tempest"
- " --version {tempest_tag}"
- " --system-wide\n"
- "rally verify add-verifier-ext"
- " --source /var/lib/designate-tempest-plugin"
- " --version {designate_tag}\n"
- "rally verify configure-verifier --extend {tempest_conf}\n"
- "rally verify configure-verifier --show\n"
- "EOF".format(tempest_tag=self.tempest_tag,
- designate_tag=self.designate_tag,
- tempest_conf=conf_name))
+ if not designate_plugin:
+ cmd = (
+ "cat > /root/rally/install_tempest.sh << EOF\n"
+ "rally verify create-verifier"
+ " --type tempest "
+ " --name tempest-verifier"
+ " --source /var/lib/tempest"
+ " --version {tempest_tag}"
+ " --system-wide\n"
+ "rally verify configure-verifier --extend {tempest_conf}\n"
+ "rally verify configure-verifier --show\n"
+ "EOF".format(tempest_tag=self.tempest_tag,
+ tempest_conf=conf_name))
+ else:
+ cmd = (
+ "cat > /root/rally/install_tempest.sh << EOF\n"
+ "rally verify create-verifier"
+ " --type tempest "
+ " --name tempest-verifier"
+ " --source /var/lib/tempest"
+ " --version {tempest_tag}"
+ " --system-wide\n"
+ "rally verify add-verifier-ext"
+ " --source /var/lib/designate-tempest-plugin"
+ " --version {designate_tag}\n"
+ "rally verify configure-verifier --extend {tempest_conf}\n"
+ "rally verify configure-verifier --show\n"
+ "EOF".format(tempest_tag=self.tempest_tag,
+ designate_tag=self.designate_tag,
+ tempest_conf=conf_name))
with self._underlay.remote(node_name=self._node_name) as remote:
LOG.info("Create install_tempest.sh")
remote.check_call(cmd)