コード例 #1
0
    def test_get_memcached_client(self, mock_cacheregion):
        self.flags(memcached_servers=None)
        self.flags(group='cache', enabled=False)
        self.assertRaises(RuntimeError,
                          cache_utils.get_memcached_client,
                          expiration_time=60)

        self.flags(memcached_servers=['localhost:11211'])
        self.assertIsNotNone(
            cache_utils.get_memcached_client(expiration_time=60))

        self.flags(memcached_servers=['localhost:11211'])
        self.assertIsNotNone(
            cache_utils.get_memcached_client(expiration_time=60))

        self.flags(memcached_servers=None)
        self.flags(group='cache', enabled=True)
        self.flags(group='cache', memcache_servers=['localhost:11211'])
        self.assertIsNotNone(
            cache_utils.get_memcached_client(expiration_time=60))

        mock_cacheregion.assert_has_calls([
            mock.call('dogpile.cache.memcached',
                      arguments={'url': ['localhost:11211']},
                      expiration_time=60),
            mock.call('dogpile.cache.memcached',
                      arguments={'url': ['localhost:11211']},
                      expiration_time=60),
            mock.call('dogpile.cache.null',
                      _config_argument_dict=mock.ANY,
                      _config_prefix='cache.oslo.arguments.',
                      expiration_time=60,
                      wrap=None)
        ])
コード例 #2
0
ファイル: test_cache.py プロジェクト: 375670450/nova
    def test_get_memcached_client(self, mock_cacheregion):
        self.flags(memcached_servers=None)
        self.flags(group='cache', enabled=False)
        self.assertRaises(
                RuntimeError,
                cache_utils.get_memcached_client,
                expiration_time=60)

        self.flags(memcached_servers=['localhost:11211'])
        self.assertIsNotNone(
                cache_utils.get_memcached_client(expiration_time=60))

        self.flags(memcached_servers=['localhost:11211'])
        self.assertIsNotNone(
                cache_utils.get_memcached_client(expiration_time=60))

        self.flags(memcached_servers=None)
        self.flags(group='cache', enabled=True)
        self.flags(group='cache', memcache_servers=['localhost:11211'])
        self.assertIsNotNone(
                cache_utils.get_memcached_client(expiration_time=60))

        mock_cacheregion.assert_has_calls(
                [mock.call('dogpile.cache.memcached',
                           arguments={'url': ['localhost:11211']},
                           expiration_time=60),
                 mock.call('dogpile.cache.memcached',
                           arguments={'url': ['localhost:11211']},
                           expiration_time=60),
                 mock.call('dogpile.cache.null',
                           _config_argument_dict=mock.ANY,
                           _config_prefix='cache.oslo.arguments.',
                           expiration_time=60, wrap=None)]
        )
コード例 #3
0
ファイル: test_cache.py プロジェクト: Juniper/nova
    def test_get_memcached_client(self, mock_cacheregion):
        self.flags(group='cache', enabled=True)
        self.flags(group='cache', memcache_servers=['localhost:11211'])
        self.assertIsNotNone(
                cache_utils.get_memcached_client(expiration_time=60))

        methods_called = [a[0] for n, a, k in mock_cacheregion.mock_calls]
        self.assertEqual(['dogpile.cache.null'], methods_called)
コード例 #4
0
 def __init__(self, *args, **kwargs):
     self.mc = cache_utils.get_memcached_client(
         expiration_time=CONF.service_down_time)
コード例 #5
0
ファイル: mc.py プロジェクト: Chillisystems/nova
 def __init__(self, *args, **kwargs):
     self.mc = cache_utils.get_memcached_client(
             expiration_time=CONF.service_down_time)