Пример #1
0
 def test_config_changed(self,
                         _config,
                         _check_for_upgrade,
                         _get_mon_hosts,
                         _relations_of_type,
                         _is_leader,
                         _leader_get,
                         _emit_cephconf,
                         _is_bootstrapped,
                         _notify_client):
     config = copy.deepcopy(CHARM_CONFIG)
     _config.side_effect = \
         lambda key=None: config.get(key, None) if key else config
     _relations_of_type.return_value = False
     _is_leader.return_value = False
     _leader_get.side_effect = ['fsid', 'monsec']
     _is_bootstrapped.return_value = True
     ceph_hooks.config_changed()
     _check_for_upgrade.assert_called_once_with()
     _get_mon_hosts.assert_called_once_with()
     _leader_get.assert_has_calls([
         call('fsid'),
         call('monitor-secret'),
     ])
     _emit_cephconf.assert_called_once_with()
     _is_bootstrapped.assert_called_once_with()
     _notify_client.assert_called_once_with()
Пример #2
0
 def test_config_changed_no_bootstrap_changed(
         self, bootstrap_source_rel_changed, get_mon_hosts,
         check_for_upgrade, create_sysctl, emit_ceph_conf):
     """Tests that changing no-bootstrap invokes the bs relation changed"""
     self.relations_of_type.return_value = []
     self.is_relation_made.return_value = True
     self.test_config.set_changed('no-bootstrap', True)
     ceph_hooks.config_changed()
     bootstrap_source_rel_changed.assert_called_once()
Пример #3
0
 def test_config_changed_with_default_autotune(
         self, cmp_pkgrevno, relations_of_type,
         bootstrap_source_rel_changed, get_mon_hosts, check_for_upgrade,
         create_sysctl, emit_ceph_conf, mgr_enable_module, list_pools):
     relations_of_type.return_value = False
     cmp_pkgrevno.return_value = 1
     self.test_config.set('pg-autotune', 'auto')
     ceph_hooks.config_changed()
     mgr_enable_module.assert_not_called()
Пример #4
0
 def test_config_changed_with_autotune(
         self, cmp_pkgrevno, relations_of_type,
         bootstrap_source_rel_changed, get_mon_hosts, check_for_upgrade,
         create_sysctl, emit_ceph_conf, mgr_enable_module, list_pools,
         monitor_key_set):
     relations_of_type.return_value = False
     cmp_pkgrevno.return_value = 1
     self.test_config.set('pg-autotune', 'true')
     ceph_hooks.config_changed()
     mgr_enable_module.assert_called_once_with('pg_autoscaler')
     monitor_key_set.assert_called_once_with('admin', 'autotune', 'true')
Пример #5
0
    def test_update_apt_source(self, mock_package_install, mock_emit_cephconf):

        previous_test_config = test_utils.TestConfig()
        previous_test_config.set('source', 'distro')
        previous_test_config.set('key', '')
        previous = mock.MagicMock().return_value
        previous.previous.side_effect = lambda x: previous_test_config.get(x)
        self.config.side_effect = [previous, "cloud:cosmic-mimic", ""]
        hooks.config_changed()
        mock_package_install.assert_called_with()
        mock_emit_cephconf.assert_called_with()
Пример #6
0
 def test_config_get_skips_package_update(self, mock_package_install,
                                          mock_emit_cephconf):
     previous_test_config = test_utils.TestConfig()
     previous_test_config.set('source', 'distro')
     previous_test_config.set('key', '')
     previous = mock.MagicMock().return_value
     previous.previous.side_effect = lambda x: previous_test_config.get(x)
     self.config.side_effect = [previous, "distro", ""]
     hooks.config_changed()
     mock_package_install.assert_not_called()
     mock_emit_cephconf.assert_any_call()
Пример #7
0
    def test_update_apt_source(self, mock_package_install, mock_emit_cephconf):

        previous_test_config = test_utils.TestConfig()
        previous_test_config.set('source', 'distro')
        previous_test_config.set('key', '')
        previous = mock.MagicMock().return_value
        previous.previous.side_effect = lambda x: previous_test_config.get(x)
        self.config.side_effect = [previous, "cloud:cosmic-mimic", ""]
        hooks.config_changed()
        mock_package_install.assert_called_with()
        mock_emit_cephconf.assert_called_with()
Пример #8
0
 def test_config_changed_no_bootstrap_changed(self,
                                              bootstrap_source_rel_changed,
                                              get_mon_hosts,
                                              check_for_upgrade,
                                              create_sysctl,
                                              emit_ceph_conf):
     """Tests that changing no-bootstrap invokes the bs relation changed"""
     self.relations_of_type.return_value = []
     self.is_relation_made.return_value = True
     self.test_config.set_changed('no-bootstrap', True)
     ceph_hooks.config_changed()
     bootstrap_source_rel_changed.assert_called_once()
Пример #9
0
 def test_config_get_skips_package_update(self,
                                          mock_package_install,
                                          mock_emit_cephconf):
     previous_test_config = test_utils.TestConfig()
     previous_test_config.set('source', 'distro')
     previous_test_config.set('key', '')
     previous = mock.MagicMock().return_value
     previous.previous.side_effect = lambda x: previous_test_config.get(x)
     self.config.side_effect = [previous, "distro", ""]
     hooks.config_changed()
     mock_package_install.assert_not_called()
     mock_emit_cephconf.assert_any_call()
Пример #10
0
 def test_config_changed(self, _config, _check_for_upgrade, _get_mon_hosts,
                         _relations_of_type, _is_leader, _leader_get,
                         _emit_cephconf, _is_bootstrapped, _notify_client):
     config = copy.deepcopy(CHARM_CONFIG)
     _config.side_effect = \
         lambda key=None: config.get(key, None) if key else config
     _relations_of_type.return_value = False
     _is_leader.return_value = False
     _leader_get.side_effect = ['fsid', 'monsec']
     _is_bootstrapped.return_value = True
     ceph_hooks.config_changed()
     _check_for_upgrade.assert_called_once_with()
     _get_mon_hosts.assert_called_once_with()
     _leader_get.assert_has_calls([
         call('fsid'),
         call('monitor-secret'),
     ])
     _emit_cephconf.assert_called_once_with()
     _is_bootstrapped.assert_called_once_with()
     _notify_client.assert_called_once_with()