def tmp_storage(monkeypatch, tmpdir): """ Provide a temporary storage for creating temporary block devices, and patch vsdm to use it instead of multipath device. """ storage = tmpstorage.TemporaryStorage(str(tmpdir)) # Get devices from our temporary storage instead of multipath. monkeypatch.setattr(multipath, "getMPDevNamesIter", storage.devices) # Use custom /run/vdsm/storage directory, used to keep symlinks to active # lvs. storage_dir = str(tmpdir.join("storage")) os.mkdir(storage_dir) monkeypatch.setattr(sc, "P_VDSM_STORAGE", storage_dir) with closing(storage): # Don't let other test break us... lvm.invalidateCache() try: yield storage finally: # and don't break other tests. lvm.invalidateCache() stats = lvm.cache_stats() log.info("LVM cache hit ratio: %.2f%% (hits: %d misses: %d)", stats["hit_ratio"], stats["hits"], stats["misses"])
def check_stats(hits, misses): stats = lvm.cache_stats() assert stats["hits"] == hits assert stats["misses"] == misses
def _check_lvm_stats(self): stats = lvm.cache_stats() self.log.info("LVM cache hit ratio: %.2f%% (hits: %d misses: %d)", stats["hit_ratio"], stats["hits"], stats["misses"])