Esempio n. 1
0
    def test_900_restart_on_config_change(self):
        """Checking restart happens on config change."""
        # Expected default and alternate values
        current_value = openstack_utils.get_application_config_option(
            'glance', 'debug')
        # this is bool, not str
        assert type(current_value) == bool
        new_value = not current_value

        # convert bool to str
        current_value = str(current_value)
        new_value = str(new_value)

        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/glance/glance-api.conf'

        # Services which are expected to restart upon config change
        services = {'glance-api': conf_file}
        current_release = openstack_utils.get_os_release()
        bionic_stein = openstack_utils.get_os_release('bionic_stein')
        if current_release < bionic_stein:
            services.update({'glance-registry': conf_file})

        # Make config change, check for service restarts
        logging.info('changing config: {}'.format(set_alternate))
        self.restart_on_changed(conf_file, set_default, set_alternate,
                                default_entry, alternate_entry, services)
    def test_900_restart_on_config_change(self):
        """Checking restart happens on config change."""
        config_name = 'debug'

        if self.application_name == 'ceilometer-agent':
            config_name = 'use-internal-endpoints'

        # Expected default and alternate values
        current_value = openstack_utils.get_application_config_option(
            self.application_name, config_name)
        assert type(current_value) == bool
        new_value = not current_value

        # Convert bool to str
        current_value = str(current_value)
        new_value = str(new_value)

        set_default = {config_name: current_value}
        set_alternate = {config_name: new_value}

        default_entry = {'DEFAULT': {'debug': [current_value]}}
        alternate_entry = {'DEFAULT': {'debug': [new_value]}}

        if self.application_name == 'ceilometer-agent':
            default_entry = None
            alternate_entry = {
                'service_credentials': {
                    'interface': ['internalURL']
                }
            }

        logging.info('changing config: {}'.format(set_alternate))
        self.restart_on_changed(CeilometerTest.CONF_FILE, set_default,
                                set_alternate, default_entry, alternate_entry,
                                self.restartable_services)
Esempio n. 3
0
 def setUpClass(cls):
     """Run class setup for running tests."""
     super(CinderLVMTest, cls).setUpClass(application_name='cinder-lvm')
     cls.model_name = zaza.model.get_juju_model()
     cls.cinder_client = openstack_utils.get_cinder_session_client(
         cls.keystone_session)
     cls.block_device = openstack_utils.get_application_config_option(
         'cinder-lvm', 'block-device', model_name=cls.model_name)
Esempio n. 4
0
    def test_900_restart_on_config_change(self):
        """Checking restart happens on config change."""
        # Expected default and alternate values
        current_value = openstack_utils.get_application_config_option(
            'ceilometer', 'debug')
        assert type(current_value) == bool
        new_value = not current_value

        # Convert bool to str
        current_value = str(current_value)
        new_value = str(new_value)

        set_default = {'debug': current_value}
        set_alternate = {'debug': new_value}
        default_entry = {'DEFAULT': {'debug': [current_value]}}
        alternate_entry = {'DEFAULT': {'debug': [new_value]}}

        logging.info('changing config: {}'.format(set_alternate))
        self.restart_on_changed(CeilometerTest.CONF_FILE, set_default,
                                set_alternate, default_entry, alternate_entry,
                                self.services)
Esempio n. 5
0
    def __get_expected_metric_names(self, current_os_release):
        expected_metric_names = {
            'compute.instance.booting.time',
            'disk.ephemeral.size',
            'disk.root.size',
            'image.download',
            'image.serve',
            'image.size',
            'memory',
            'vcpus',
        }

        all_polsters_are_enabled = (
            openstack_utils.get_application_config_option(
                self.application_name, 'enable-all-pollsters'))

        if all_polsters_are_enabled:
            expected_metric_names |= {
                'disk.device.allocation',
                'disk.device.capacity',
                'disk.device.read.latency',
                'disk.device.usage',
                'disk.device.write.latency',
                'memory.resident',
                'memory.swap.in',
                'memory.swap.out',
                'network.incoming.packets.drop',
                'network.incoming.packets.error',
                'network.outgoing.packets.drop',
                'network.outgoing.packets.error',
            }

        openstack_queens_or_older = (
            current_os_release <=
            openstack_utils.get_os_release('bionic_queens'))
        openstack_rocky_or_older = (
            current_os_release <=
            openstack_utils.get_os_release('bionic_rocky'))
        openstack_victoria_or_older = (
            current_os_release <=
            openstack_utils.get_os_release('groovy_victoria'))

        if openstack_victoria_or_older:
            expected_metric_names |= {
                'cpu',
                'disk.device.read.bytes',
                'disk.device.read.requests',
                'disk.device.write.bytes',
                'disk.device.write.requests',
                'memory.usage',
                'network.incoming.bytes',
                'network.incoming.packets',
                'network.outgoing.bytes',
                'network.outgoing.packets',
            }

        if openstack_rocky_or_older:
            expected_metric_names |= {
                'cpu.delta',
                'cpu_util',
                'disk.device.read.bytes.rate',
                'disk.device.read.requests.rate',
                'disk.device.write.bytes.rate',
                'disk.device.write.requests.rate',
                'network.incoming.bytes.rate',
                'network.incoming.packets.rate',
                'network.outgoing.bytes.rate',
                'network.outgoing.packets.rate',
            }
            if all_polsters_are_enabled:
                expected_metric_names |= {
                    'disk.allocation',
                    'disk.capacity',
                    'disk.read.bytes',
                    'disk.read.bytes.rate',
                    'disk.read.requests',
                    'disk.read.requests.rate',
                    'disk.usage',
                    'disk.write.bytes',
                    'disk.write.bytes.rate',
                    'disk.write.requests',
                    'disk.write.requests.rate',
                }

        if openstack_queens_or_older:
            expected_metric_names |= {
                'cpu_l3_cache',
                'disk.allocation',
                'disk.capacity',
                'disk.device.allocation',
                'disk.device.capacity',
                'disk.device.iops',
                'disk.device.latency',
                'disk.device.read.latency',
                'disk.device.usage',
                'disk.device.write.latency',
                'disk.iops',
                'disk.latency',
                'disk.read.bytes',
                'disk.read.bytes.rate',
                'disk.read.requests',
                'disk.read.requests.rate',
                'disk.usage',
                'disk.write.bytes',
                'disk.write.bytes.rate',
                'disk.write.requests',
                'disk.write.requests.rate',
                'memory.bandwidth.local',
                'memory.bandwidth.total',
                'memory.resident',
                'memory.swap.in',
                'memory.swap.out',
                'network.incoming.packets.drop',
                'network.incoming.packets.error',
                'network.outgoing.packets.drop',
                'network.outgoing.packets.error',
                'perf.cache.misses',
                'perf.cache.references',
                'perf.cpu.cycles',
                'perf.instructions',
            }

        return expected_metric_names
Esempio n. 6
0
    def test_400_gnocchi_metrics(self):
        """Verify that ceilometer-agent publishes metrics to gnocchi."""
        current_os_release = openstack_utils.get_os_release()
        openstack_pike_or_older = (
            current_os_release <=
            openstack_utils.get_os_release('xenial_pike'))
        if openstack_pike_or_older:
            # Both the charm and Ceilometer itself had different behaviors in
            # terms of which metrics were published and how fast, which would
            # lead to a combinatorial explosion if we had to maintain test
            # expectations for these old releases.
            logging.info('OpenStack Pike or older, skipping')
            return

        # ceilometer-agent-compute reports metrics for each existing VM, so at
        # least one VM is needed:
        self.RESOURCE_PREFIX = 'zaza-ceilometer-agent'
        self.launch_guest('ubuntu', instance_key=glance_setup.LTS_IMAGE_NAME)

        logging.info('Instantiating gnocchi client...')
        overcloud_auth = openstack_utils.get_overcloud_auth()
        keystone = openstack_utils.get_keystone_client(overcloud_auth)
        gnocchi_ep = keystone.service_catalog.url_for(service_type='metric',
                                                      interface='publicURL')
        gnocchi = gnocchi_client.Client(
            session=openstack_utils.get_overcloud_keystone_session(),
            adapter_options={
                'endpoint_override': gnocchi_ep,
            })

        expected_metric_names = self.__get_expected_metric_names(
            current_os_release)

        min_timeout_seconds = 500
        polling_interval_seconds = (
            openstack_utils.get_application_config_option(
                self.application_name, 'polling-interval'))
        timeout_seconds = max(10 * polling_interval_seconds,
                              min_timeout_seconds)
        logging.info('Giving ceilometer-agent {}s to publish all metrics to '
                     'gnocchi...'.format(timeout_seconds))

        max_time = time.time() + timeout_seconds
        while time.time() < max_time:
            found_metric_names = {
                metric['name']
                for metric in gnocchi.metric.list()
            }
            missing_metric_names = expected_metric_names - found_metric_names
            if len(missing_metric_names) == 0:
                logging.info('All expected metrics found.')
                break
            time.sleep(polling_interval_seconds)

        unexpected_found_metric_names = (found_metric_names -
                                         expected_metric_names)
        if len(unexpected_found_metric_names) > 0:
            logging.info('Unexpected metrics '
                         'published: ' +
                         ', '.join(unexpected_found_metric_names))

        if len(missing_metric_names) > 0:
            self.fail('These metrics should have been published but '
                      "weren't: " + ', '.join(missing_metric_names))