Skip to content

Commit

Permalink
Merge pull request openstack-charmers#300 from gnuoy/refactor-designa…
Browse files Browse the repository at this point in the history
…te-tests

Refactor Designate tests so API tests can be called
  • Loading branch information
ajkavanagh authored May 28, 2020
2 parents 0de2faf + 9eefa08 commit 6494047
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions zaza/openstack/charm_tests/designate/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,15 @@ def setUpClass(cls, application_name=None, model_alias=None):
cls.server_delete = cls.designate.servers.delete


class DesignateTests(BaseDesignateTest):
"""Designate charm restart and pause tests."""
class DesignateAPITests(BaseDesignateTest):
"""Tests interact with designate api."""

TEST_DOMAIN = 'amuletexample.com.'
TEST_NS1_RECORD = 'ns1.{}'.format(TEST_DOMAIN)
TEST_NS2_RECORD = 'ns2.{}'.format(TEST_DOMAIN)
TEST_WWW_RECORD = "www.{}".format(TEST_DOMAIN)
TEST_RECORD = {TEST_WWW_RECORD: '10.0.0.23'}

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
"""
# Services which are expected to restart upon config change,
# and corresponding config files affected by the change
conf_file = '/etc/designate/designate.conf'

# Make config change, check for service restarts
self.restart_on_changed_debug_oslo_config_file(
conf_file,
self.designate_svcs,
)

def test_910_pause_and_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.designate_svcs,
pgrep_full=False):
logging.info("Testing pause resume")

def _get_server_id(self, server_name=None, server_id=None):
for srv in self.server_list():
if isinstance(srv, dict):
Expand Down Expand Up @@ -245,3 +218,40 @@ def test_400_domain_creation(self):
logging.debug('Tidy up delete test record')
self._wait_on_domain_gone(domain_id)
logging.debug('OK')


class DesignateCharmTests(BaseDesignateTest):
"""Designate charm restart and pause tests."""

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
"""
# Services which are expected to restart upon config change,
# and corresponding config files affected by the change
conf_file = '/etc/designate/designate.conf'

# Make config change, check for service restarts
self.restart_on_changed_debug_oslo_config_file(
conf_file,
self.designate_svcs,
)

def test_910_pause_and_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.designate_svcs,
pgrep_full=False):
logging.info("Testing pause resume")


class DesignateTests(DesignateAPITests, DesignateCharmTests):
"""Collection of all Designate test classes."""

pass

0 comments on commit 6494047

Please sign in to comment.