예제 #1
0
from cloudkitty import tests
from cloudkitty.tests.utils import is_functional_test


class FakeKeystoneClient(object):
    class FakeTenants(object):
        def list(self):
            return [
                'f266f30b11f246b589fd266f85eeec39',
                '4dfb25b0947c4f5481daf7b948c14187'
            ]

    tenants = FakeTenants()


@testtools.skipIf(is_functional_test(), 'Not a functional test')
class OrchestratorTest(tests.TestCase):
    def setUp(self):
        super(OrchestratorTest, self).setUp()
        messaging_conf = self.useFixture(conffixture.ConfFixture(self.conf))
        messaging_conf.transport_url = 'fake:/'
        self.conf.set_override('backend', 'keystone', 'fetcher')
        self.conf.import_group('keystone_fetcher',
                               'cloudkitty.fetcher.keystone')

    def setup_fake_modules(self):
        fake_module1 = tests.FakeRatingModule()
        fake_module1.module_name = 'fake1'
        fake_module1.set_priority(3)
        fake_module2 = tests.FakeRatingModule()
        fake_module2.module_name = 'fake2'
예제 #2
0
 def stop_fixture(self):
     if not is_functional_test():
         self.patch.assert_called_with(self.namespace, **self.assert_args)
     self.mock.stop()
예제 #3
0
 def start_fixture(self):
     if is_functional_test():
         raise SkipTest
예제 #4
0
    Example:
    >>> mydict = {'a': 'A', 'b': 'B'}
    >>> checker = PermissiveDict('A', key='a')
    >>> checker == mydict
    True
    """
    def __init__(self, value, key='name'):
        self.key = key
        self.value = value

    def __eq__(self, other):
        return self.value == other.get(self.key)


@testtools.skipIf(test_utils.is_functional_test(), 'Not a functional test')
class HybridStorageTestGnocchi(BaseHybridStorageTest):

    def setUp(self):
        super(HybridStorageTestGnocchi, self).setUp()

    def tearDown(self):
        super(HybridStorageTestGnocchi, self).tearDown()

    def _init_storage(self, archive_policy=False, res_type=False):
        with mock.patch.object(self.storage.storage._hybrid_backend._conn,
                               'archive_policy',
                               spec=['get', 'create']) as pol_mock:
            if not archive_policy:
                pol_mock.get.side_effect = gexc.ArchivePolicyNotFound
            else:
예제 #5
0
# @author: Luka Peschke
#
import testtools
from time import sleep

from gnocchiclient import exceptions as gexceptions
from oslo_log import log

from cloudkitty.tests.storage.v2 import base_functional
from cloudkitty.tests.utils import is_functional_test


LOG = log.getLogger(__name__)


@testtools.skipUnless(is_functional_test(), 'Test is not a functional test')
class GnocchiBaseFunctionalStorageTest(
        base_functional.BaseFunctionalStorageTest):

    storage_backend = 'gnocchi'
    storage_version = 2

    def setUp(self):
        super(GnocchiBaseFunctionalStorageTest, self).setUp()
        self.conf.import_group(
            'storage_gnocchi', 'cloudkitty.storage.v2.gnocchi')

    @classmethod
    def _get_status(cls):
        status = cls.storage._conn.status.get()
        return status['storage']['summary']['measures']
예제 #6
0
        for data_part in frames['dataframes']:
            for usage_part in data_part['usage'].values():
                retrieved_length += len(usage_part)

        self.assertEqual(expected_length, retrieved_length)

    def test_retrieve_one_scope_two_types_one_period(self):
        expected_total, expected_qty, expected_length = \
            self._expected_total_qty_len([self.data[0]], self._project_id,
                                         types=['image.size', 'instance'])

        begin = datetime.datetime(2018, 1, 1)
        end = datetime.datetime(2018, 1, 1, 1)

        group_filters = {'project_id': self._project_id}
        frames = self.storage.retrieve(begin=begin, end=end,
                                       group_filters=group_filters,
                                       metric_types=['image.size', 'instance'])
        self.assertEqual(frames['total'], expected_length)

        retrieved_length = 0
        for data_part in frames['dataframes']:
            for usage_part in data_part['usage'].values():
                retrieved_length += len(usage_part)

        self.assertEqual(expected_length, retrieved_length)


if not test_utils.is_functional_test():
    StorageUnitTest.generate_scenarios()