Exemple #1
0
 def setUp(self):
     super(TestRGWAdminClient, self).setUp()
     self.client = RGWAdminClient('http://127.0.0.1:8080/admin', 'abcde',
                                  'secret')
     self.get_resp = mock.MagicMock()
     self.get = mock.patch('requests.get',
                           return_value=self.get_resp).start()
Exemple #2
0
 def test_get_buckets(self):
     self.get_resp.status_code = 200
     self.get_resp.json.return_value = buckets_json
     actual = self.client.get_bucket('foo')
     bucket_list = [RGWAdminClient.Bucket('somefoo', 1000, 1000),
                    RGWAdminClient.Bucket('somefoo31', 1, 42),
                    ]
     expected = {'num_buckets': 2, 'size': 1042, 'num_objects': 1001,
                 'buckets': bucket_list}
     self.assertEqual(expected, actual)
 def setUp(self):
     super(TestRGWAdminClient, self).setUp()
     self.client = RGWAdminClient('http://127.0.0.1:8080/admin',
                                  'abcde', 'secret')
     self.get_resp = mock.MagicMock()
     self.get = mock.patch('requests.get',
                           return_value=self.get_resp).start()
Exemple #4
0
class TestRGWAdminClient(base.BaseTestCase):
    def setUp(self):
        super(TestRGWAdminClient, self).setUp()
        self.client = RGWAdminClient('http://127.0.0.1:8080/admin', 'abcde',
                                     'secret')
        self.get_resp = mock.MagicMock()
        self.get = mock.patch('requests.get',
                              return_value=self.get_resp).start()

    def test_make_request_exception(self):
        self.get_resp.status_code = 403
        self.assertRaises(RGWAdminAPIFailed, self.client._make_request,
                          *('foo', {}))

    def test_make_request(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = buckets_json
        actual = self.client._make_request('foo', [])
        self.assertEqual(buckets_json, actual)

    def test_get_buckets(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = buckets_json
        actual = self.client.get_bucket('foo')
        bucket_list = [
            RGWAdminClient.Bucket('somefoo', 1000, 1000),
            RGWAdminClient.Bucket('somefoo31', 1, 42),
        ]
        expected = {
            'num_buckets': 2,
            'size': 1042,
            'num_objects': 1001,
            'buckets': bucket_list
        }
        self.assertEqual(expected, actual)

    def test_get_usage(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = usage_json
        actual = self.client.get_usage('foo')
        expected = 7
        self.assertEqual(expected, actual)
class TestRGWAdminClient(base.BaseTestCase):

    def setUp(self):
        super(TestRGWAdminClient, self).setUp()
        self.client = RGWAdminClient('http://127.0.0.1:8080/admin',
                                     'abcde', 'secret')
        self.get_resp = mock.MagicMock()
        self.get = mock.patch('requests.get',
                              return_value=self.get_resp).start()

    def test_make_request_exception(self):
        self.get_resp.status_code = 403
        self.assertRaises(RGWAdminAPIFailed, self.client._make_request,
                          *('foo', {}))

    def test_make_request(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = buckets_json
        actual = self.client._make_request('foo', [])
        self.assertEqual(buckets_json, actual)

    def test_get_buckets(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = buckets_json
        actual = self.client.get_bucket('foo')
        bucket_list = [RGWAdminClient.Bucket('somefoo', 1000, 1000),
                       RGWAdminClient.Bucket('somefoo31', 1, 42),
                       ]
        expected = {'num_buckets': 2, 'size': 1042, 'num_objects': 1001,
                    'buckets': bucket_list}
        self.assertEqual(expected, actual)

    def test_get_usage(self):
        self.get_resp.status_code = 200
        self.get_resp.json.return_value = usage_json
        actual = self.client.get_usage('foo')
        expected = 7
        self.assertEqual(expected, actual)
Exemple #6
0
    def _get_account_info(self, ksclient, tenants):
        endpoint = self._get_endpoint(ksclient)
        if not endpoint:
            raise StopIteration()

        try:
            from ceilometer.objectstore.rgw_client import RGWAdminClient
            rgw_client = RGWAdminClient(endpoint, self.access_key, self.secret)
        except ImportError:
            raise plugin_base.PollsterPermanentError(tenants)

        for t in tenants:
            api_method = 'get_%s' % self.METHOD
            yield t.id, getattr(rgw_client, api_method)(t.id)
# License for the specific language governing permissions and limitations
# under the License.

import collections

from keystoneauth1 import exceptions
import mock
from oslotest import base
from oslotest import mockpatch
import testscenarios.testcase

from ceilometer.agent import manager
from ceilometer.objectstore import rgw
from ceilometer.objectstore.rgw_client import RGWAdminClient as rgw_client

bucket_list1 = [rgw_client.Bucket('somefoo1', 10, 7)]
bucket_list2 = [rgw_client.Bucket('somefoo2', 2, 9)]
bucket_list3 = [rgw_client.Bucket('unlisted', 100, 100)]

GET_BUCKETS = [('tenant-000', {
    'num_buckets': 2,
    'size': 1042,
    'num_objects': 1001,
    'buckets': bucket_list1
}),
               ('tenant-001', {
                   'num_buckets': 2,
                   'size': 1042,
                   'num_objects': 1001,
                   'buckets': bucket_list2
               }),