Browse Source

Fix multiple issues for pre-provioned nodes

1. Add option to skip enrollment tests -- not applicable without novajoin
2. Fix skip-tripleo option
3. Fix mysql test - podman ps instead of podman ls
4. For pre-provisioned nodes,
   - add ability to read server metadata from the mistral yanl file.
   - add ability to get server ip from hosts/dns
5. Fix hard-coded heat-admin

Change-Id: I051b08b02d7cfedecd28ccabb47c22d141ae7d8c
changes/33/729833/2
Ade Lee 1 month ago
parent
commit
c8a180f215
5 changed files with 109 additions and 35 deletions
  1. +11
    -4
      novajoin_tempest_plugin/config.py
  2. +25
    -4
      novajoin_tempest_plugin/tests/scenario/novajoin_manager.py
  3. +6
    -0
      novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py
  4. +46
    -11
      novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py
  5. +21
    -16
      novajoin_tempest_plugin/tests/scenario/test_tripleo_tls.py

+ 11
- 4
novajoin_tempest_plugin/config.py View File

@@ -30,15 +30,22 @@ NovajoinGroup = [
cfg.IntOpt('connect_retries',
default=5,
help='Number of connection attempts to IPA'),
cfg.BoolOpt('enrollment',
default='True',
help='Run enrollment tests'),
cfg.StrOpt('flavor_tag',
default='vm',
help='Flavor tag to use in novajoin enrollment tests'),
cfg.StrOpt('keytab',
default=os.path.expanduser('~/novajoin.keytab'),
help='Keytab to connect to IPA as the novajoin user'),
cfg.StrOpt('tripleo',
default='True',
help='Run triple-O config tests'),
cfg.BoolOpt('tripleo',
default='True',
help='Run triple-O config tests'),
cfg.StrOpt('tripleo_controller_file',
help='File for group vars for controllers'),
cfg.StrOpt('tripleo_compute_file',
help='File for group vars for computes'),
cfg.ListOpt('tripleo_controllers',
default=['overcloud-controller-0'],
help='List of overcloud controller short host names'),
@@ -55,7 +62,7 @@ NovajoinGroup = [
default="sudo podman exec ",
help='container exec command'),
cfg.StrOpt('mysql_container_find_command',
default=("sudo podman ls |"
default=("sudo podman ps |"
"grep galera-bundle-podman|"
"awk '{print \$NF}'"),
help='mysql container find command')


+ 25
- 4
novajoin_tempest_plugin/tests/scenario/novajoin_manager.py View File

@@ -15,8 +15,10 @@
import functools
import json
import six
import socket
import subprocess
import time
import yaml

from oslo_log import log as logging
from tempest import config
@@ -173,6 +175,15 @@ class NovajoinScenarioTest(manager.ScenarioTest):
result = self.ipa_client.show_cert(serial)['result']
return result['revoked']

def get_server_metadata_from_file(self, fname):
with open(fname, 'r') as gvars_in:
gvars = yaml.safe_load(gvars_in)
data = gvars['service_metadata_settings']
metadata = {}
for (key, value) in data.items():
metadata[key] = json.dumps(value)
return metadata

def get_compact_services(self, metadata):
# compact key-per-service
compact_services = {key.split('_', 2)[-1]: json.loads(value)
@@ -241,7 +252,7 @@ class NovajoinScenarioTest(manager.ScenarioTest):
network = 'storage_mgmt'
cmd = ('sudo hiera -c /etc/puppet/hiera.yaml fqdn_{network}'.format(
network=network))
result = self.execute_on_controller('heat-admin', host_ip, cmd)
result = self.execute_on_controller(self.get_ssh_user(), host_ip, cmd)
return result.strip() != 'nil'

def verify_managed_services(self, services, verify_certs=False):
@@ -275,9 +286,19 @@ class NovajoinScenarioTest(manager.ScenarioTest):
return None

def get_overcloud_server_ip(self, host):
host_id = self.get_server_id(host)
host_data = self.servers_client.show_server(host_id)['server']
return self.get_server_ip(host_data)
# getting the server ip and id from nova doesn't work when
# we use pre-provisioned nodes. Lets check dns/hosts file
# first
try:
host_net = host + '.' + CONF.validation.network_for_ssh
return socket.gethostbyname(host_net)
except socket.gaierror:
host_id = self.get_server_id(host)
host_data = self.servers_client.show_server(host_id)['server']
return self.get_server_ip(host_data)

def get_ssh_user(self):
return CONF.validation.image_ssh_user or 'heat-admin'

def get_haproxy_cfg(self, user, controller_ip):
try:


+ 6
- 0
novajoin_tempest_plugin/tests/scenario/test_novajoin_enrollment.py View File

@@ -63,6 +63,12 @@ class ServerTest(novajoin_manager.NovajoinScenarioTest):

credentials = ['primary', 'admin']

@classmethod
def skip_checks(cls):
super(ServerTest, cls).skip_checks()
if not CONF.novajoin.enrollment:
raise cls.skipException('Enrollment tests are not enabled')

@classmethod
def setup_credentials(cls):
cls.set_network_resources()


+ 46
- 11
novajoin_tempest_plugin/tests/scenario/test_tripleo_deployment.py View File

@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import json

from novajoin_tempest_plugin.tests.scenario import novajoin_manager
from oslo_log import log as logging
from tempest import config
@@ -73,13 +75,38 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest):
self.verify_host_registered_with_ipa(host)
self.verify_host_has_keytab(host)

def test_verify_compact_services_created(self):
def test_verify_controller_compact_services_created(self):
hosts = list(CONF.novajoin.tripleo_controllers)
hosts.extend(CONF.novajoin.tripleo_computes)
for host in hosts:
host_ip = self.get_overcloud_server_ip(host)
metadata = self.servers_client.list_server_metadata(
self.get_server_id(host))['metadata']
group_vars_file = CONF.novajoin.tripleo_controller_file
if group_vars_file:
metadata = self.get_server_metadata_from_file(
group_vars_file)
else:
metadata = self.servers_client.list_server_metadata(
self.get_server_id(host))['metadata']
compact_services = self.get_compact_services(metadata)
LOG.debug(compact_services)
self.verify_compact_services(
services=compact_services,
host=host,
host_ip=host_ip,
verify_certs=True
)

def test_verify_compute_compact_services_created(self):
hosts = list(CONF.novajoin.tripleo_computes)
print(CONF.novajoin)
for host in hosts:
host_ip = self.get_overcloud_server_ip(host)
group_vars_file = CONF.novajoin.tripleo_compute_file
if group_vars_file:
metadata = self.get_server_metadata_from_file(
group_vars_file)
else:
metadata = self.servers_client.list_server_metadata(
self.get_server_id(host))['metadata']
compact_services = self.get_compact_services(metadata)
LOG.debug(compact_services)
self.verify_compact_services(
@@ -91,10 +118,18 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest):

def test_verify_controller_managed_services(self):
for host in CONF.novajoin.tripleo_controllers:
metadata = self.servers_client.list_server_metadata(
self.get_server_id(host))['metadata']
managed_services = [metadata[key] for key in metadata.keys()
if key.startswith('managed_service_')]
group_vars_file = CONF.novajoin.tripleo_controller_file
if group_vars_file:
metadata = self.get_server_metadata_from_file(
group_vars_file)
managed_services = [
json.loads(metadata[key]) for key in metadata.keys()
if key.startswith('managed_service_')]
else:
metadata = self.servers_client.list_server_metadata(
self.get_server_id(host))['metadata']
managed_services = [metadata[key] for key in metadata.keys()
if key.startswith('managed_service_')]
LOG.debug(managed_services)
self.verify_managed_services(
services=managed_services,
@@ -106,7 +141,7 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest):
for tag in CONTROLLER_CERT_TAGS:
self.verify_overcloud_cert_tracked(
server_ip,
'heat-admin',
self.get_ssh_user(),
tag
)

@@ -116,7 +151,7 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest):
for tag in COMPUTE_CERT_TAGS:
self.verify_overcloud_cert_tracked(
server_ip,
'heat-admin',
self.get_ssh_user(),
tag
)

@@ -127,5 +162,5 @@ class TripleOTest(novajoin_manager.NovajoinScenarioTest):
server_ip = self.get_overcloud_server_ip(host)
self.verify_overcloud_host_is_ipaclient(
server_ip,
'heat-admin'
self.get_ssh_user()
)

+ 21
- 16
novajoin_tempest_plugin/tests/scenario/test_tripleo_tls.py View File

@@ -76,7 +76,7 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
def test_haproxy_tls_connections(self):
for controller in CONF.novajoin.tripleo_controllers:
controller_ip = self.get_overcloud_server_ip(controller)
haproxy = self.get_haproxy_cfg('heat-admin', controller_ip)
haproxy = self.get_haproxy_cfg(self.get_ssh_user(), controller_ip)
services = self.parse_haproxy_cfg(haproxy)

for tag, params in services.items():
@@ -99,7 +99,10 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
# contains the vip

vip_node = self.get_pcs_node(
host_ip, controller_ip, 'heat-admin', hostport)
host_ip,
controller_ip,
self.get_ssh_user(),
hostport)
print("vip_node={vip_node}".format(vip_node=vip_node))

if controller != vip_node:
@@ -109,7 +112,7 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):

self.verify_overcloud_tls_connection(
controller_ip=controller_ip,
user='heat-admin',
user=self.get_ssh_user(),
hostport=hostport
)

@@ -122,13 +125,13 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
def test_rabbitmq_tls_connection(self):
for controller in CONF.novajoin.tripleo_controllers:
controller_ip = self.get_overcloud_server_ip(controller)
rabbitmq_host = self.get_rabbitmq_host('heat-admin',
rabbitmq_host = self.get_rabbitmq_host(self.get_ssh_user(),
controller_ip)
rabbitmq_port = self.get_rabbitmq_port('heat-admin',
rabbitmq_port = self.get_rabbitmq_port(self.get_ssh_user(),
controller_ip)
self.verify_overcloud_tls_connection(
controller_ip=controller_ip,
user='heat-admin',
user=self.get_ssh_user(),
hostport="{host}:{port}".format(host=rabbitmq_host,
port=rabbitmq_port)
)
@@ -136,12 +139,14 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
def test_libvirt_tls_connection(self):
for compute in CONF.novajoin.tripleo_computes:
compute_ip = self.get_overcloud_server_ip(compute)
libvirt_port = self.get_libvirt_port('heat-admin', compute_ip)
libvirt_port = self.get_libvirt_port(
self.get_ssh_user(),
compute_ip)

# TODO(alee) Is the host correct?
self.verify_overcloud_tls_connection(
controller_ip=compute_ip,
user='heat-admin',
user=self.get_ssh_user(),
hostport="{host}.internalapi.{domain}:{port}".format(
host=compute,
domain=self.ipa_client.domain,
@@ -152,16 +157,16 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
def test_mysql_nova_connection_with_ssl(self):
for controller in CONF.novajoin.tripleo_controllers:
controller_ip = self.get_overcloud_server_ip(controller)
dbuser = self.get_hiera('heat-admin',
dbuser = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_USER)
dbhost = self.get_hiera('heat-admin',
dbhost = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_HOST)
dbpassword = self.get_hiera('heat-admin',
dbpassword = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_PASSWORD)
self.verify_mysql_access_with_ssl('heat-admin',
self.verify_mysql_access_with_ssl(self.get_ssh_user(),
controller_ip,
dbuser,
dbhost,
@@ -170,16 +175,16 @@ class TripleOTLSTest(novajoin_manager.NovajoinScenarioTest):
def test_mysql_nova_connection_without_ssl(self):
for controller in CONF.novajoin.tripleo_controllers:
controller_ip = self.get_overcloud_server_ip(controller)
dbuser = self.get_hiera('heat-admin',
dbuser = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_USER)
dbhost = self.get_hiera('heat-admin',
dbhost = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_HOST)
dbpassword = self.get_hiera('heat-admin',
dbpassword = self.get_hiera(self.get_ssh_user(),
controller_ip,
NOVADB_PASSWORD)
self.verify_mysql_access_without_ssl('heat-admin',
self.verify_mysql_access_without_ssl(self.get_ssh_user(),
controller_ip,
dbuser,
dbhost,


Loading…
Cancel
Save