diff --git a/zaza/openstack/charm_tests/designate_bind/__init__.py b/zaza/openstack/charm_tests/designate_bind/__init__.py new file mode 100644 index 0000000..f00dc9f --- /dev/null +++ b/zaza/openstack/charm_tests/designate_bind/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2021 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Collection of code for setting up and testing designate-bind.""" diff --git a/zaza/openstack/charm_tests/designate_bind/tests.py b/zaza/openstack/charm_tests/designate_bind/tests.py new file mode 100644 index 0000000..7526fc7 --- /dev/null +++ b/zaza/openstack/charm_tests/designate_bind/tests.py @@ -0,0 +1,56 @@ +# Copyright 2021 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Encapsulate designate-bind testing.""" +import logging +import os + +import zaza.model as zaza_model +import zaza.openstack.charm_tests.test_utils as test_utils + + +class DesignateBindServiceIPsTest(test_utils.OpenStackBaseTest): + """Tests for configuration of Service IPs.""" + + VIP = "" + APPLICATION = "designate-bind" + UNIT = "designate-bind/0" + + def setUp(self): + """Verify that TEST_VIP00 env variable is set.""" + super().setUp() + self.VIP = os.environ.get("TEST_VIP00", None) + if self.VIP is None: + self.fail("Environment variable 'TEST_VIP00' is required.") + + def test_configure_ips(self): + """Configure and un-configure 'service_ips' option.""" + config = {"service_ips": self.VIP} + + logging.info("Configuring %s as a Service IP for %s unit.", + self.VIP, self.UNIT) + zaza_model.set_application_config(self.APPLICATION, config) + zaza_model.wait_for_application_states() + + configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") + self.assertIn(self.VIP, configured_ips["Stdout"]) + + logging.info("Removing service IP configuration from %s unit.", + self.UNIT) + config["service_ips"] = "" + zaza_model.set_application_config(self.APPLICATION, config) + zaza_model.wait_for_application_states() + + configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") + self.assertNotIn(self.VIP, configured_ips["Stdout"])