Example #1
0
 def test_no_implementations(self):
     with mask_modules('pylibmc', 'memcache'):
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             with self.assertRaises(ImproperlyConfigured):
                 cache.get_best_memcache()
Example #2
0
 def test_cached(self):
     with self.mock_pylibmc():
         with reset_modules("celery.backends.cache"):
             from celery.backends import cache
             cache.get_best_memcache(behaviors={"foo": "bar"})
             self.assertTrue(cache._imp[0])
             cache.get_best_memcache()
Example #3
0
 def test_no_implementations(self):
     with mask_modules('pylibmc', 'memcache'):
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             with self.assertRaises(ImproperlyConfigured):
                 cache.get_best_memcache()
Example #4
0
 def test_cached(self):
     with self.mock_pylibmc():
         with mock.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             cache.get_best_memcache()[0](behaviors={'foo': 'bar'})
             assert cache._imp[0]
             cache.get_best_memcache()[0]()
Example #5
0
 def test_cached(self):
     with self.mock_pylibmc():
         with reset_modules("celery.backends.cache"):
             from celery.backends import cache
             cache._imp = [None]
             cache.get_best_memcache(behaviors={"foo": "bar"})
             self.assertTrue(cache._imp[0])
             cache.get_best_memcache()
Example #6
0
 def test_cached(self):
     with self.mock_pylibmc():
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             cache.get_best_memcache()[0](behaviors={'foo': 'bar'})
             self.assertTrue(cache._imp[0])
             cache.get_best_memcache()[0]()
Example #7
0
 def test_pylibmc(self):
     pylibmc = self.mock_pylibmc()
     pylibmc.next()
     sys.modules.pop("celery.backends.cache", None)
     from celery.backends import cache
     self.assertEqual(cache.get_best_memcache().__module__, "pylibmc")
     pylibmc.next()
Example #8
0
 def test_memcache(self, mask_modules):
     with self.mock_memcache():
         with conftest.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             assert (cache.get_best_memcache()[0]().__module__ ==
                     'memcache')
Example #9
0
 def test_pylibmc(self):
     pylibmc = self.mock_pylibmc()
     pylibmc.next()
     from celery.backends import cache
     cache._imp = [None]
     self.assertEqual(cache.get_best_memcache().__module__, "pylibmc")
     pylibmc.next()
 def test_pylibmc(self):
     with self.mock_pylibmc():
         with mock.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             self.assertEqual(cache.get_best_memcache()[0].__module__,
                              'pylibmc')
Example #11
0
 def test_pylibmc(self):
     with self.mock_pylibmc():
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             self.assertEqual(cache.get_best_memcache()[0].__module__,
                              'pylibmc')
Example #12
0
 def test_pylibmc(self):
     pylibmc = self.mock_pylibmc()
     pylibmc.next()
     from celery.backends import cache
     cache._imp = [None]
     self.assertEqual(cache.get_best_memcache().__module__, "pylibmc")
     pylibmc.next()
Example #13
0
 def test_pylibmc(self):
     with reset_modules("celery.backends.cache"):
         with self.mock_pylibmc():
             from celery.backends import cache
             cache._imp = [None]
             self.assertEqual(cache.get_best_memcache().__module__,
                              "pylibmc")
 def test_pylibmc(self):
     pylibmc = self.mock_pylibmc()
     pylibmc.next()
     sys.modules.pop("celery.backends.cache", None)
     from celery.backends import cache
     self.assertEqual(cache.get_best_memcache().__module__, "pylibmc")
     pylibmc.next()
Example #15
0
 def test_memcache(self):
     with self.mock_memcache():
         with reset_modules("celery.backends.cache"):
             with mask_modules("pylibmc"):
                 from celery.backends import cache
                 cache._imp = [None]
                 self.assertEqual(cache.get_best_memcache().__module__,
                                  "memcache")
Example #16
0
 def test_memcache(self):
     with self.mock_memcache():
         with mock.reset_modules('celery.backends.cache'):
             with mock.mask_modules('pylibmc'):
                 from celery.backends import cache
                 cache._imp = [None]
                 assert (cache.get_best_memcache()[0]().__module__ ==
                         'memcache')
Example #17
0
def get_harness(pool):
    mc = get_best_memcache()[0](CONFIG.memcache)
    key = CONFIG.web._MC_KEY + pool
    try:
        i = mc.incr(key)
    except:
        i = mc.set(key, 0)
    harnesses = CONFIG.web.harnesses[pool]
    return os.path.join(config_dir, harnesses[i % len(harnesses)])
Example #18
0
def get_harness(pool):
    mc = get_best_memcache()[0](CONFIG.memcache)
    key = CONFIG.web._MC_KEY + pool
    try:
        i = mc.incr(key)
    except:
        i = mc.set(key, 0)
    harnesses = CONFIG.web.harnesses[pool]
    return os.path.join(config_dir, harnesses[i % len(harnesses)])
Example #19
0
def get_harness(config, pool):
    """ Determine which of the set of harness should be selected for this
        task.
    """
    mc = get_best_memcache()[0](config.memcache)
    # returns a Celery Config object, then not sure what happens, no
    # docs online for this Celery method.
    key = config.web._MC_KEY + pool
    try:
        i = mc.incr(key)
    except:
        LOG.warning("Exception in Celery Memcache, defaulting to first harness")
        i = mc.set(key, 0)
    harnesses = config.web.harnesses[pool]
    harness_path = os.path.join(config.dir, harnesses[i % len(harnesses)])
    LOG.info("Selected the test harness: " + harness_path)
    return harness_path
Example #20
0
 def with_no_pylibmc():
     from celery.backends import cache
     cache._imp = [None]
     self.assertEqual(cache.get_best_memcache().__module__, "memcache")
Example #21
0
 def with_no_pylibmc():
     from celery.backends import cache
     cache._imp = [None]
     self.assertEqual(cache.get_best_memcache().__module__, "memcache")
Example #22
0
 def test_pylibmc(self):
     with self.mock_pylibmc():
         with conftest.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             assert cache.get_best_memcache()[0].__module__ == 'pylibmc'
Example #23
0
 def with_no_pylibmc():
     sys.modules.pop("celery.backends.cache", None)
     from celery.backends import cache
     self.assertEqual(cache.get_best_memcache().__module__, "memcache")
 def with_no_pylibmc():
     sys.modules.pop("celery.backends.cache", None)
     from celery.backends import cache
     self.assertEqual(cache.get_best_memcache().__module__, "memcache")
Example #25
0
 def test_no_implementations(self, mask_modules):
     with conftest.reset_modules('celery.backends.cache'):
         from celery.backends import cache
         cache._imp = [None]
         with pytest.raises(ImproperlyConfigured):
             cache.get_best_memcache()