Ejemplo n.º 1
0
 def test_init_storage_structure(self, mkdir_mock):
     mount_point = Mock()
     app = couch_service.CouchbaseApp(Mock())
     app.init_storage_structure(mount_point)
     mkdir_mock.assert_called_once_with(
         mount_point, user=app.couchbase_owner, group=app.couchbase_owner,
         as_root=True)
Ejemplo n.º 2
0
 def test_build_command_options(self):
     app = couch_service.CouchbaseApp(Mock())
     opts = app.build_admin()._build_command_options({
         'bucket': 'bucket1',
         'bucket-replica': 0,
         'wait': None
     })
     self.assertEqual(
         set(['--bucket=bucket1', '--bucket-replica=0', '--wait']),
         set(opts))
Ejemplo n.º 3
0
    def test_write_password_to_file2(self, mock_logging):
        self.original_mkstemp = tempfile.mkstemp
        self.tempname = None

        with mock.patch.object(tempfile, 'mkstemp', self.__fake_mkstemp_raise):

            app = couch_service.CouchbaseApp()

            self.assertRaises(RuntimeError, app._write_password_to_file,
                              'mypassword')
Ejemplo n.º 4
0
    def test_ramsize_quota_mb(self):
        app = couch_service.CouchbaseApp(Mock())

        with patch.object(couch_service.CouchbaseApp,
                          'available_ram_mb',
                          new_callable=PropertyMock) as available_ram_mock:
            available_ram_mock.return_value = 1024
            self.assertEqual('819', str(app.ramsize_quota_mb))

            available_ram_mock.return_value = 128
            self.assertEqual('256', str(app.ramsize_quota_mb))
Ejemplo n.º 5
0
    def test_write_password_to_file1(self):
        self.original_mkstemp = tempfile.mkstemp
        self.tempname = None

        with mock.patch.object(tempfile, 'mkstemp', self.__fake_mkstemp):
            self.addCleanup(self.__cleanup_tempfile)

            app = couch_service.CouchbaseApp()
            app._write_password_to_file('mypassword')

            filepermissions = os.stat(self.tempname).st_mode
            self.assertEqual(stat.S_IRUSR, filepermissions & 0o777)
Ejemplo n.º 6
0
 def test_parse_bucket_list(self):
     app = couch_service.CouchbaseApp(Mock())
     bucket_list = app.build_admin()._parse_bucket_list(
         "bucket1\n saslPassword: password1\n ramQuota: 268435456\n"
         "bucket2\n saslPassword: password2\n ramQuota: 134217728")
     self.assertEqual(
         {
             'bucket1': {
                 'saslPassword': '******',
                 'ramQuota': '268435456'
             },
             'bucket2': {
                 'saslPassword': '******',
                 'ramQuota': '134217728'
             }
         }, bucket_list)
Ejemplo n.º 7
0
    def test_enable_root(self):
        app = couch_service.CouchbaseApp(Mock())

        with patch.multiple(BaseDbStatus,
                            begin_restart=DEFAULT,
                            end_restart=DEFAULT):
            with patch.object(app, 'reset_admin_credentials'):
                app.enable_root()
                app.status.begin_restart.assert_called_once_with()
                app.status.end_restart.assert_called_once_with()

        with patch.multiple(BaseDbStatus,
                            begin_restart=DEFAULT,
                            end_restart=DEFAULT):
            with patch.object(app,
                              'reset_admin_credentials',
                              side_effect=ProcessExecutionError):
                self.assertRaises(ProcessExecutionError, app.enable_root)
                app.status.begin_restart.assert_called_once_with()
                app.status.end_restart.assert_called_once_with()
Ejemplo n.º 8
0
 def __init__(self):
     self.appStatus = service.CouchbaseAppStatus()
     self.app = service.CouchbaseApp(self.appStatus)
Ejemplo n.º 9
0
 def __init__(self):
     self.appStatus = service.CouchbaseAppStatus()
     self.app = service.CouchbaseApp(self.appStatus)
     super(Manager, self).__init__('couchbase')
Ejemplo n.º 10
0
 def build_app(self):
     return service.CouchbaseApp()
Ejemplo n.º 11
0
 def __init__(self, filename, **kwargs):
     self.app = service.CouchbaseApp()
     super(CbBackup, self).__init__(filename, **kwargs)
Ejemplo n.º 12
0
 def __init__(self, *args, **kwargs):
     self.app = service.CouchbaseApp()
     super(CbBackup, self).__init__(*args, **kwargs)