def test_superuser_password_reset(self, _, enable_service_on_boot, disable_service_on_boot): fake_status = MagicMock() fake_status.is_running = False test_app = cass_service.CassandraApp() test_app.status = fake_status with patch.multiple( test_app, start_db=DEFAULT, stop_db=DEFAULT, restart=DEFAULT, _CassandraApp__disable_remote_access=DEFAULT, _CassandraApp__enable_remote_access=DEFAULT, _CassandraApp__disable_authentication=DEFAULT, _CassandraApp__enable_authentication=DEFAULT, _CassandraApp__reset_user_password_to_default=DEFAULT, secure=DEFAULT) as calls: test_app._reset_admin_password() disable_service_on_boot.assert_called_once_with( test_app.service_candidates) calls[ '_CassandraApp__disable_remote_access'].assert_called_once_with( ) calls[ '_CassandraApp__disable_authentication'].assert_called_once_with( ) calls['start_db'].assert_called_once_with(update_db=False, enable_on_boot=False), calls[ '_CassandraApp__enable_authentication'].assert_called_once_with( ) pw_reset_mock = calls[ '_CassandraApp__reset_user_password_to_default'] pw_reset_mock.assert_called_once_with(test_app._ADMIN_USER) calls['secure'].assert_called_once_with( update_user=pw_reset_mock.return_value) calls['restart'].assert_called_once_with() calls['stop_db'].assert_called_once_with() calls[ '_CassandraApp__enable_remote_access'].assert_called_once_with( ) enable_service_on_boot.assert_called_once_with( test_app.service_candidates)
def test_apply_post_restore_updates(self, _, conf_mock): fake_status = MagicMock() fake_status.is_running = False test_app = cass_service.CassandraApp() test_app.status = fake_status with patch.multiple(test_app, start_db=DEFAULT, stop_db=DEFAULT, _update_cluster_name_property=DEFAULT, _reset_admin_password=DEFAULT, change_cluster_name=DEFAULT) as calls: backup_info = {'instance_id': 'old_id'} conf_mock.guest_id = 'new_id' test_app._apply_post_restore_updates(backup_info) calls['_update_cluster_name_property'].assert_called_once_with( 'old_id') calls['_reset_admin_password'].assert_called_once_with() calls['start_db'].assert_called_once_with(update_db=False) calls['change_cluster_name'].assert_called_once_with('new_id') calls['stop_db'].assert_called_once_with()
def test_change_cluster_name(self, _): fake_status = MagicMock() fake_status.is_running = True test_app = cass_service.CassandraApp() test_app.status = fake_status with patch.multiple( test_app, start_db=DEFAULT, stop_db=DEFAULT, restart=DEFAULT, _update_cluster_name_property=DEFAULT, _CassandraApp__reset_cluster_name=DEFAULT) as calls: sample_name = NonCallableMagicMock() test_app.change_cluster_name(sample_name) calls['_CassandraApp__reset_cluster_name'].assert_called_once_with( sample_name) calls['_update_cluster_name_property'].assert_called_once_with( sample_name) calls['restart'].assert_called_once_with()
def setUp(self, *args, **kwargs): super(GuestAgentCassandraDBManagerTest, self).setUp('cassandra') conn_patcher = patch.multiple(cass_service.CassandraConnection, _connect=DEFAULT, is_active=Mock(return_value=True)) self.addCleanup(conn_patcher.stop) conn_patcher.start() self.real_status = cass_service.CassandraAppStatus.set_status class FakeInstanceServiceStatus(object): status = ServiceStatuses.NEW def save(self): pass cass_service.CassandraAppStatus.set_status = MagicMock( return_value=FakeInstanceServiceStatus()) self.context = trove_testtools.TroveTestContext(self) self.manager = cass_manager.Manager() self.manager._app = cass_service.CassandraApp() self.manager._admin = cass_service.CassandraAdmin( models.CassandraUser('Test')) self.admin = self.manager._admin self.admin._CassandraAdmin__client = MagicMock() self.conn = self.admin._CassandraAdmin__client self.pkg = cass_service.packager self.origin_os_path_exists = os.path.exists self.origin_format = volume.VolumeDevice.format self.origin_migrate_data = volume.VolumeDevice.migrate_data self.origin_mount = volume.VolumeDevice.mount self.origin_mount_points = volume.VolumeDevice.mount_points self.origin_stop_db = cass_service.CassandraApp.stop_db self.origin_start_db = cass_service.CassandraApp.start_db self.origin_install_db = cass_service.CassandraApp._install_db self.original_get_ip = netutils.get_my_ipv4 self.orig_make_host_reachable = ( cass_service.CassandraApp.apply_initial_guestagent_configuration)
def __init__(self, filename, **kwargs): self._app = service.CassandraApp() super(NodetoolSnapshot, self).__init__(filename, **kwargs)
def __init__(self): self.appStatus = service.CassandraAppStatus() self.app = service.CassandraApp(self.appStatus) super(Manager, self).__init__('cassandra')
def build_app(self): return service.CassandraApp()
def __init__(self, storage, **kwargs): self._app = service.CassandraApp() kwargs.update({'restore_location': self._app.cassandra_data_dir}) super(NodetoolSnapshot, self).__init__(storage, **kwargs)
def __init__(self): self._app = service.CassandraApp() self.__admin = CassandraAdmin(self.app.get_current_superuser()) super(Manager, self).__init__('cassandra')
def __init__(self): self.appStatus = service.CassandraAppStatus() self.app = service.CassandraApp(self.appStatus)