def test_create_erasure_profile(self, mock_create_erasure):
     req = json.dumps(
         {
             "api-version": 1,
             "ops": [
                 {
                     "op": "create-erasure-profile",
                     "name": "foo",
                     "erasure-type": "jerasure",
                     "failure-domain": "rack",
                     "k": 3,
                     "m": 2,
                 }
             ],
         }
     )
     rc = ceph_broker.process_requests(req)
     mock_create_erasure.assert_called_with(
         service="admin",
         profile_name="foo",
         coding_chunks=2,
         data_chunks=3,
         locality=None,
         failure_domain="rack",
         erasure_plugin_name="jerasure",
     )
     self.assertEqual(json.loads(rc), {"exit-code": 0})
 def test_remove_pool_snapshot(self, mock_snapshot_pool):
     reqs = json.dumps(
         {"api-version": 1, "ops": [{"op": "remove-pool-snapshot", "name": "foo", "snapshot-name": "foo-snap1"}]}
     )
     mock_snapshot_pool.return_value = {"exit-code": 0}
     rc = ceph_broker.process_requests(reqs)
     mock_snapshot_pool.assert_called_with(service="admin", pool_name="foo", snapshot_name="foo-snap1")
     self.assertEqual(json.loads(rc), {"exit-code": 0})
 def test_set_pool_value(self, mock_set_pool):
     reqs = json.dumps(
         {"api-version": 1, "ops": [{"op": "set-pool-value", "name": "foo", "key": "size", "value": 3}]}
     )
     mock_set_pool.return_value = {"exit-code": 0}
     rc = ceph_broker.process_requests(reqs)
     mock_set_pool.assert_called_with(service="admin", pool_name="foo", key="size", value=3)
     self.assertEqual(json.loads(rc), {"exit-code": 0})
    def test_process_requests_remove_cache_tier(self, mock_pool, mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps({"api-version": 1, "ops": [{"op": "remove-cache-tier", "hot-pool": "foo-ssd"}]})
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service="admin", name="foo-ssd")

        mock_pool.assert_called_with(cache_pool="foo-ssd")
        self.assertEqual(json.loads(rc), {"exit-code": 0})
Пример #5
0
 def test_set_invalid_pool_value(self):
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'set-pool-value',
                            'name': 'foo',
                            'key': 'size',
                            'value': 'abc',
                        }]})
     rc = ceph_broker.process_requests(reqs)
     self.assertEqual(json.loads(rc)['exit-code'], 1)
Пример #6
0
 def test_process_requests_delete_pool(self,
                                       mock_delete_pool):
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'delete-pool',
                            'name': 'foo',
                        }]})
     mock_delete_pool.return_value = {'exit-code': 0}
     rc = ceph_broker.process_requests(reqs)
     mock_delete_pool.assert_called_with(service='admin', name='foo')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
 def test_process_requests_create_replicated_pool(self, mock_replicated_pool, mock_pool_exists, mock_get_osds):
     mock_get_osds.return_value = 0
     mock_pool_exists.return_value = False
     reqs = json.dumps(
         {"api-version": 1, "ops": [{"op": "create-pool", "pool-type": "replicated", "name": "foo", "replicas": 3}]}
     )
     rc = ceph_broker.process_requests(reqs)
     mock_pool_exists.assert_called_with(service="admin", name="foo")
     calls = [call(pg_num=None, name=u"foo", service="admin", replicas=3)]
     mock_replicated_pool.assert_has_calls(calls)
     self.assertEqual(json.loads(rc), {"exit-code": 0})
Пример #8
0
 def test_process_requests_delete_pool(self, mock_delete_pool, mock_log):
     reqs = json.dumps({
         'api-version': 1,
         'ops': [{
             'op': 'delete-pool',
             'name': 'foo',
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     mock_delete_pool.assert_called_with(service='admin', name='foo')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #9
0
 def test_remove_pool_snapshot(self, mock_snapshot_pool, mock_broker):
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'remove-pool-snapshot',
                            'name': 'foo',
                            'snapshot-name': 'foo-snap1',
                        }]})
     rc = ceph_broker.process_requests(reqs)
     mock_snapshot_pool.assert_called_with(service='admin',
                                           pool_name='foo',
                                           snapshot_name='foo-snap1')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #10
0
 def test_rename_pool(self, mock_rename_pool, mock_log):
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'rename-pool',
                            'name': 'foo',
                            'new-name': 'foo2',
                        }]})
     rc = ceph_broker.process_requests(reqs)
     mock_rename_pool.assert_called_with(service='admin',
                                         old_name='foo',
                                         new_name='foo2')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #11
0
    def test_process_requests_remove_cache_tier(self, mock_pool,
                                                mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps({'api-version': 1,
                           'ops': [{
                               'op': 'remove-cache-tier',
                               'hot-pool': 'foo-ssd',
                           }]})
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service='admin', name='foo-ssd')

        mock_pool.assert_called_with(cache_pool='foo-ssd')
        self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #12
0
 def test_set_invalid_pool_value(self):
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'set-pool-value',
             'name': 'foo',
             'key': 'size',
             'value': 'abc',
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     self.assertEqual(json.loads(rc)['exit-code'], 1)
 def test_process_requests_create_erasure_pool(self, mock_profile_exists, mock_erasure_pool, mock_pool_exists):
     mock_pool_exists.return_value = False
     reqs = json.dumps(
         {
             "api-version": 1,
             "ops": [{"op": "create-pool", "pool-type": "erasure", "name": "foo", "erasure-profile": "default"}],
         }
     )
     rc = ceph_broker.process_requests(reqs)
     mock_profile_exists.assert_called_with(service="admin", name="default")
     mock_pool_exists.assert_called_with(service="admin", name="foo")
     mock_erasure_pool.assert_called_with()
     self.assertEqual(json.loads(rc), {"exit-code": 0})
Пример #14
0
 def test_set_pool_value(self, mock_set_pool, mock_broker):
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'set-pool-value',
                            'name': 'foo',
                            'key': 'size',
                            'value': 3,
                        }]})
     rc = ceph_broker.process_requests(reqs)
     mock_set_pool.assert_called_with(service='admin',
                                      pool_name='foo',
                                      key='size',
                                      value=3)
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #15
0
 def test_remove_pool_snapshot(self, mock_snapshot_pool, mock_broker):
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'remove-pool-snapshot',
             'name': 'foo',
             'snapshot-name': 'foo-snap1',
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     mock_snapshot_pool.assert_called_with(service='admin',
                                           pool_name='foo',
                                           snapshot_name='foo-snap1')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #16
0
 def test_process_requests_create_erasure_pool(self, mock_profile_exists,
                                               mock_erasure_pool,
                                               mock_pool_exists):
     mock_pool_exists.return_value = False
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'create-pool',
                            'pool-type': 'erasure',
                            'name': 'foo',
                            'erasure-profile': 'default'
                        }]})
     rc = ceph_broker.process_requests(reqs)
     mock_profile_exists.assert_called_with(service='admin', name='default')
     mock_pool_exists.assert_called_with(service='admin', name='foo')
     mock_erasure_pool.assert_called_with()
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #17
0
    def test_process_requests_remove_cache_tier(self, mock_pool,
                                                mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps({
            'api-version':
            1,
            'ops': [{
                'op': 'remove-cache-tier',
                'hot-pool': 'foo-ssd',
            }]
        })
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service='admin', name='foo-ssd')

        mock_pool.assert_called_with(cache_pool='foo-ssd')
        self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #18
0
 def test_rename_pool(self, mock_rename_pool):
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'rename-pool',
             'name': 'foo',
             'new-name': 'foo2',
         }]
     })
     mock_rename_pool.return_value = {'exit-code': 0}
     rc = ceph_broker.process_requests(reqs)
     mock_rename_pool.assert_called_with(service='admin',
                                         old_name='foo',
                                         new_name='foo2')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #19
0
    def test_process_requests_create_cache_tier(self, mock_pool,
                                                mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps({'api-version': 1,
                           'ops': [{
                               'op': 'create-cache-tier',
                               'cold-pool': 'foo',
                               'hot-pool': 'foo-ssd',
                               'mode': 'writeback',
                               'erasure-profile': 'default'
                           }]})
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service='admin', name='foo')
        mock_pool_exists.assert_any_call(service='admin', name='foo-ssd')

        mock_pool.assert_called_with(cache_pool='foo-ssd', mode='writeback')
        self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #20
0
 def test_set_pool_value(self, mock_set_pool, mock_broker):
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'set-pool-value',
             'name': 'foo',
             'key': 'size',
             'value': 3,
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     mock_set_pool.assert_called_with(service='admin',
                                      pool_name='foo',
                                      key='size',
                                      value=3)
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #21
0
 def test_process_requests_create_replicated_pool(self,
                                                  mock_replicated_pool,
                                                  mock_pool_exists,
                                                  mock_get_osds):
     mock_get_osds.return_value = 0
     mock_pool_exists.return_value = False
     reqs = json.dumps({'api-version': 1,
                        'ops': [{
                            'op': 'create-pool',
                            'pool-type': 'replicated',
                            'name': 'foo',
                            'replicas': 3
                        }]})
     rc = ceph_broker.process_requests(reqs)
     mock_pool_exists.assert_called_with(service='admin', name='foo')
     calls = [call(pg_num=None, name=u'foo', service='admin', replicas=3)]
     mock_replicated_pool.assert_has_calls(calls)
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #22
0
 def test_process_requests_create_erasure_pool(self, mock_profile_exists,
                                               mock_erasure_pool,
                                               mock_pool_exists):
     mock_pool_exists.return_value = False
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'create-pool',
             'pool-type': 'erasure',
             'name': 'foo',
             'erasure-profile': 'default'
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     mock_profile_exists.assert_called_with(service='admin', name='default')
     mock_pool_exists.assert_called_with(service='admin', name='foo')
     mock_erasure_pool.assert_called_with()
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #23
0
 def test_create_erasure_profile(self, mock_create_erasure):
     req = json.dumps({'api-version': 1,
                       'ops': [{
                           'op': 'create-erasure-profile',
                           'name': 'foo',
                           'erasure-type': 'jerasure',
                           'failure-domain': 'rack',
                           'k': 3,
                           'm': 2,
                       }]})
     rc = ceph_broker.process_requests(req)
     mock_create_erasure.assert_called_with(service='admin',
                                            profile_name='foo',
                                            coding_chunks=2,
                                            data_chunks=3,
                                            locality=None,
                                            failure_domain='rack',
                                            erasure_plugin_name='jerasure')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #24
0
    def test_process_requests_create_cache_tier(self, mock_pool,
                                                mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps({
            'api-version':
            1,
            'ops': [{
                'op': 'create-cache-tier',
                'cold-pool': 'foo',
                'hot-pool': 'foo-ssd',
                'mode': 'writeback',
                'erasure-profile': 'default'
            }]
        })
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service='admin', name='foo')
        mock_pool_exists.assert_any_call(service='admin', name='foo-ssd')

        mock_pool.assert_called_with(cache_pool='foo-ssd', mode='writeback')
        self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #25
0
 def test_process_requests_create_replicated_pool(self,
                                                  mock_replicated_pool,
                                                  mock_pool_exists,
                                                  mock_get_osds):
     mock_get_osds.return_value = 0
     mock_pool_exists.return_value = False
     reqs = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'create-pool',
             'pool-type': 'replicated',
             'name': 'foo',
             'replicas': 3
         }]
     })
     rc = ceph_broker.process_requests(reqs)
     mock_pool_exists.assert_called_with(service='admin', name='foo')
     calls = [call(pg_num=None, name=u'foo', service='admin', replicas=3)]
     mock_replicated_pool.assert_has_calls(calls)
     self.assertEqual(json.loads(rc), {'exit-code': 0})
Пример #26
0
 def test_create_erasure_profile(self, mock_create_erasure):
     req = json.dumps({
         'api-version':
         1,
         'ops': [{
             'op': 'create-erasure-profile',
             'name': 'foo',
             'erasure-type': 'jerasure',
             'failure-domain': 'rack',
             'k': 3,
             'm': 2,
         }]
     })
     rc = ceph_broker.process_requests(req)
     mock_create_erasure.assert_called_with(service='admin',
                                            profile_name='foo',
                                            coding_chunks=2,
                                            data_chunks=3,
                                            locality=None,
                                            failure_domain='rack',
                                            erasure_plugin_name='jerasure')
     self.assertEqual(json.loads(rc), {'exit-code': 0})
    def test_process_requests_create_cache_tier(self, mock_pool, mock_pool_exists):
        mock_pool_exists.return_value = True
        reqs = json.dumps(
            {
                "api-version": 1,
                "ops": [
                    {
                        "op": "create-cache-tier",
                        "cold-pool": "foo",
                        "hot-pool": "foo-ssd",
                        "mode": "writeback",
                        "erasure-profile": "default",
                    }
                ],
            }
        )
        rc = ceph_broker.process_requests(reqs)
        mock_pool_exists.assert_any_call(service="admin", name="foo")
        mock_pool_exists.assert_any_call(service="admin", name="foo-ssd")

        mock_pool.assert_called_with(cache_pool="foo-ssd", mode="writeback")
        self.assertEqual(json.loads(rc), {"exit-code": 0})
 def test_set_invalid_pool_value(self):
     reqs = json.dumps(
         {"api-version": 1, "ops": [{"op": "set-pool-value", "name": "foo", "key": "size", "value": "abc"}]}
     )
     rc = ceph_broker.process_requests(reqs)
     self.assertEqual(json.loads(rc)["exit-code"], 1)
 def test_process_requests_delete_pool(self, mock_delete_pool):
     reqs = json.dumps({"api-version": 1, "ops": [{"op": "delete-pool", "name": "foo"}]})
     mock_delete_pool.return_value = {"exit-code": 0}
     rc = ceph_broker.process_requests(reqs)
     mock_delete_pool.assert_called_with(service="admin", name="foo")
     self.assertEqual(json.loads(rc), {"exit-code": 0})