First NovaCloudController test cases
Not yet covering the same amount as nova-cloud-controller's Amulet tests. https://launchpad.net/bugs/1828424
This commit is contained in:
@@ -20,9 +20,10 @@ import logging
|
||||
import unittest
|
||||
|
||||
import zaza.model
|
||||
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||
import zaza.openstack.charm_tests.glance.setup as glance_setup
|
||||
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||
import zaza.openstack.configure.guest
|
||||
import zaza.openstack.utilities.openstack as openstack_utils
|
||||
|
||||
|
||||
class BaseGuestCreateTest(unittest.TestCase):
|
||||
@@ -156,6 +157,94 @@ class NovaCompute(test_utils.OpenStackBaseTest):
|
||||
self.assertFalse(int(run['Code']) == 0)
|
||||
|
||||
|
||||
class NovaCloudController(test_utils.OpenStackBaseTest):
|
||||
"""Run nova-cloud-controller specific tests."""
|
||||
|
||||
XENIAL_MITAKA = openstack_utils.get_os_release('xenial_mitaka')
|
||||
XENIAL_NEWTON = openstack_utils.get_os_release('xenial_newton')
|
||||
XENIAL_OCATA = openstack_utils.get_os_release('xenial_ocata')
|
||||
BIONIC_QUEENS = openstack_utils.get_os_release('bionic_queens')
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run class setup for running nova-cloud-controller tests."""
|
||||
super(NovaCloudController, cls).setUpClass()
|
||||
cls.current_release = openstack_utils.get_os_release()
|
||||
|
||||
@property
|
||||
def services(self):
|
||||
"""Return a list of services for the selected OpenStack release."""
|
||||
services = ['nova-scheduler', 'nova-conductor']
|
||||
if self.current_release <= self.BIONIC_QUEENS:
|
||||
services.append('nova-api-os-compute')
|
||||
if self.current_release <= self.XENIAL_MITAKA:
|
||||
services.append('nova-cert')
|
||||
if self.current_release >= self.XENIAL_OCATA:
|
||||
services.append('apache2')
|
||||
return services
|
||||
|
||||
def test_104_compute_api_functionality(self):
|
||||
"""Verify basic compute API functionality."""
|
||||
logging.info('Instantiating nova client...')
|
||||
keystone_session = openstack_utils.get_overcloud_keystone_session()
|
||||
nova = openstack_utils.get_nova_session_client(keystone_session)
|
||||
|
||||
logging.info('Checking api functionality...')
|
||||
|
||||
actual_service_names = [service['binary'] for service in
|
||||
nova.services.list()]
|
||||
for expected_service_name in ('nova-scheduler', 'nova-conductor',
|
||||
'nova-compute'):
|
||||
assert(expected_service_name in actual_service_names)
|
||||
|
||||
# Thanks to setup.create_flavors we should have a few flavors already:
|
||||
assert(len(nova.flavors.list()) > 0)
|
||||
|
||||
# Just checking it's not raising and returning an iterable:
|
||||
assert(len(nova.servers.list()) >= 0)
|
||||
|
||||
def test_900_restart_on_config_change(self):
|
||||
"""Checking restart happens on config change.
|
||||
|
||||
Change debug mode and assert that change propagates to the correct
|
||||
file and that services are restarted as a result
|
||||
"""
|
||||
# Expected default and alternate values
|
||||
current_value = zaza.model.get_application_config(
|
||||
'nova-cloud-controller')['debug']['value']
|
||||
new_value = str(not bool(current_value)).title()
|
||||
current_value = str(current_value).title()
|
||||
|
||||
set_default = {'debug': current_value}
|
||||
set_alternate = {'debug': new_value}
|
||||
default_entry = {'DEFAULT': {'debug': [current_value]}}
|
||||
alternate_entry = {'DEFAULT': {'debug': [new_value]}}
|
||||
|
||||
# Config file affected by juju set config change
|
||||
conf_file = '/etc/nova/nova.conf'
|
||||
|
||||
# Make config change, check for service restarts
|
||||
logging.info(
|
||||
'Setting verbose on nova-cloud-controller {}'.format(
|
||||
set_alternate))
|
||||
self.restart_on_changed(
|
||||
conf_file,
|
||||
set_default,
|
||||
set_alternate,
|
||||
default_entry,
|
||||
alternate_entry,
|
||||
self.services)
|
||||
|
||||
def test_901_pause_resume(self):
|
||||
"""Run pause and resume tests.
|
||||
|
||||
Pause service and check services are stopped then resume and check
|
||||
they are started
|
||||
"""
|
||||
with self.pause_resume(self.services):
|
||||
logging.info("Testing pause resume")
|
||||
|
||||
|
||||
class SecurityTests(test_utils.OpenStackBaseTest):
|
||||
"""nova-compute and nova-cloud-controller security tests."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user