Example #1
0
 def test_block_until_services_restarted_not_running(self):
     self.block_until_services_restarted_base(gu_raise_exception=True)
     with self.assertRaises(asyncio.futures.TimeoutError):
         model.block_until_services_restarted(
             'app',
             12,
             ['svc1', 'svc2'])
Example #2
0
 def test_block_until_services_restarted_fail(self):
     self.block_until_services_restarted_base(gu_return=10)
     with self.assertRaises(asyncio.futures.TimeoutError):
         model.block_until_services_restarted(
             'app',
             12,
             ['svc1', 'svc2'])
Example #3
0
    def restart_on_changed(self, config_file, default_config, alternate_config,
                           default_entry, alternate_entry, services):
        """Run restart on change tests.

        Test that changing config results in config file being updates and
        services restarted. Return config to default_config afterwards

        :param config_file: Config file to check for settings
        :type config_file: str
        :param default_config: Dict of charm settings to set on completion
        :type default_config: dict
        :param alternate_config: Dict of charm settings to change to
        :type alternate_config: dict
        :param default_entry: Config file entries that correspond to
                              default_config
        :type default_entry: dict
        :param alternate_entry: Config file entries that correspond to
                                alternate_config
        :type alternate_entry: dict
        :param services: Services expected to be restarted when config_file is
                         changed.
        :type services: list
        """
        # lead_unit is only useed to grab a timestamp, the assumption being
        # that all the units times are in sync.

        mtime = model.get_unit_time(self.lead_unit, model_name=self.model_name)
        logging.debug('Remote unit timestamp {}'.format(mtime))

        with self.config_change(default_config, alternate_config):
            logging.debug(
                'Waiting for updates to propagate to {}'.format(config_file))
            model.block_until_oslo_config_entries_match(
                self.application_name,
                config_file,
                alternate_entry,
                model_name=self.model_name)

            # Config update has occured and hooks are idle. Any services should
            # have been restarted by now:
            logging.debug(
                'Waiting for services ({}) to be restarted'.format(services))
            model.block_until_services_restarted(self.application_name,
                                                 mtime,
                                                 services,
                                                 model_name=self.model_name)

            logging.debug(
                'Waiting for updates to propagate to '.format(config_file))
            model.block_until_oslo_config_entries_match(
                self.application_name,
                config_file,
                default_entry,
                model_name=self.model_name)
Example #4
0
 def test_block_until_services_restarted(self):
     self.block_until_services_restarted_base(gu_return=10)
     model.block_until_services_restarted('app', 8, ['svc1', 'svc2'])